Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio: Type or namespace name 'Properties' does not exist

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.

like image 881
RenniePet Avatar asked Apr 29 '13 03:04

RenniePet


3 Answers

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>
like image 196
RenniePet Avatar answered Sep 17 '22 02:09

RenniePet


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 ...

like image 34
SiL3NC3 Avatar answered Sep 19 '22 02:09

SiL3NC3


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.

like image 20
Mequanego Avatar answered Sep 17 '22 02:09

Mequanego