Visual Studio: Type or namespace name 'Propert

2019-06-18 03:51发布

There's another thread here about this, but my problem was different. I eventually found the solution for my particular problem, which I'm posting here in case it's of use to others.

4条回答
唯我独甜
2楼-- · 2019-06-18 04:13

The easiest ever way to force VisualStudio's re-generation process for any Designer.cs file in my opinion is: to change a value of an object's property ...

In our case:

  1. Go to Resources.resx Properties
  2. Type any text in "Custom Tool Namespace" and press Return (Resources.Designer.cs should now be re-genereated)
  3. Remove the pseudo namespace

All should work back again.

PS: Got the same issue fixed with VS2015 ...

查看更多
放荡不羁爱自由
3楼-- · 2019-06-18 04:26

In a project's Properties folder there should be (at least) two files, Resources.resx and Resources.Designer.cs, with the latter file shown at a lower level under Resources.resx in Visual Studio's Solution Explorer. In my case the Resources.Designer.cs file was somehow no longer included in the project. This can be fixed by editing (or restoring an old copy of) the .csproj file.

And credit where credit is due, I found this solution here: http://social.msdn.microsoft.com/Forums/en-US/tfsbuild/thread/ebeca7a8-c7a3-4cb6-a40e-89c5fdb70c82 in the answer by NJLASSI.

EDIT:

Fixing this isn't as simple as I first thought, so it's best if an old copy of the .csproj file is available so the relevant lines can be restored from there. Here are the applicable lines:

<Compile Include="Properties\Resources.Designer.cs">
  <AutoGen>True</AutoGen>
  <DesignTime>True</DesignTime>
  <DependentUpon>Resources.resx</DependentUpon>
</Compile>

and

<EmbeddedResource Include="Properties\Resources.resx">
  <Generator>ResXFileCodeGenerator</Generator>
  <SubType>Designer</SubType>
  <LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
查看更多
Luminary・发光体
4楼-- · 2019-06-18 04:26

If this error happened because you accidentally renamed your namespace, and you still have your Resources.Designer.cs file, a simple solution would be to open the file, and just change your namespace to the correct one:

// in my case this was accidentally changed to DummyApp.Properties
namespace Tools.Properties { 
    using System;

After changing it to the correct namespace (Tools), the error is resolved.

查看更多
你好瞎i
5楼-- · 2019-06-18 04:28

When renaming namespaces (with ctrl-r, ctrl-r in visual studio) the namespace in file Properties\Resources.Designer.cs is not always changed (VS 2012 in my case).

PhaseControlMMI was the new namespace name in my case:

namespace PhaseControlMMI.Properties {
    using System;

After this change Properties were showing and that solved it for me.

查看更多
登录 后发表回答