2

I recently had an issue with VS2010, C#, and .Net 4 where I could not use the namespace from my referenced assembly (call it AssemblyA). It is similar to the issue here.

I was able to correct the problem by setting AssemblyA to target x86 platform instead of Any Cpu.

My question is why did changing the platform target to x86 allow me to use the namespace from AssemblyA in my project?

I want to note that I was able to reference AssemblyA in other projects without changing the platform target. Also all of my references were project references.

EDIT: Apparently I am mistaken. It is not working even when changing to x86. Any ideas what could be causing this?

Update: All my projects are using the full .NET 4 profile.

EDIT:

After doing some testing I have some more information. When I switch between Debug/Release builds (Doesnt matter the order I switch) and do a clean on AssemblyA then I am able to use the namespace no problem. As soon as I rebuild AssemblyA then I can no longer use the namespace. It doesn't seem to matter what platform I am targeting.

Community
  • 1
  • 1
MisterXero
  • 1,098
  • 2
  • 9
  • 17
  • 1
    Do both projects use "regular" profile or is one of them client profile? – Daniel Oct 22 '12 at 19:43
  • The most common error for such errors is a different profile (Client vs. Full) as it was already pointed out. What are the namespaces of your project and the class in the library? I remember having issues in certain situations before, but I can't recall exact details. – Damir Arh Oct 22 '12 at 20:42

2 Answers2

0

You need to make sure that the project in which you are referencing the assembly is set to ".NET 4 Full Profile" instead of the default "Client Profile". If your DLL is using classes from the full profile and your assembly is set to client profile, it can't reference the DLL.

So just right click on your project, then click Properties. Then under the Application tab, look at the Target Framework. Make sure it isn't set to .NET Framework 4 Client Profile

Icemanind
  • 47,519
  • 50
  • 171
  • 296
0

I am not sure what the deal is here but to workaround I just created a completely new project and copied the code. The new project is setup identical to the project that was giving me issues. However I can reference the new project in my other project with no problems.

MisterXero
  • 1,098
  • 2
  • 9
  • 17