4
votes

I have the exact same issue as the post "C++/CLI DLL namespace not found in MSVS C# Project (successfully reproducable)", but didn't make the mistake that resolved things for the posting user.

I have a C++/CLI project that I've used in VS2005 for years. It contains some native code, and some CLR wrappers (ref class) to expose the native functionality to other managed (C#) projects. I recently converted this project to 2010 (.vcxproj), got it compiling OK, got it referenced from my C# project, but compiling the C# project gives error CS0234: The type or namespace name 'MySecondLevelNamespace' does not exist in the namespace 'MyTopLevelNamespace' (are you missing an assembly reference?).

I fear the conversion, although compiling, isn't exposing the ref classes to the managed callers. Both the CLI and C# projects are configured to target 2.0 runtime. What am I missing here?

Again, this code (both the CLI project, and the C# project calling it) all compiles without issue in VS2005. Thanks for your help!

2

2 Answers

3
votes

Both the CLI and C# projects are configured to target 2.0 runtime.

That's probably where your problem lies. The VC2010 compiler can only target the .NET 4 runtime. The only way to build for .NET 2.0 is to configure Visual Studio 2010 to run the VC2005 compiler.

0
votes

The simple solution is don't upgrade the C++/CLI solution, at least until you have a reason to change the target framework, if you are making tons of changes to the solution itself.

You shoudl think about migrating to the .NET 4.0 Framework should also solve your problems.

This answer is based on Ben's response.