开发者

Namespace cannot be found after changing target framework from v4.0 to v3.5

I have 2 projects in a solution, 1 a dll, the other an exe. Both were using .net version 4.0 however no 4.0 specific libraries were used so it should be possible for me to safely change them to 3.5

I did this under both project properties, I built the dll fine. Now when i try to build the exe it cannot find the dll's namespace. I have readded the reference, but it still cant see it. When I reverted the .net ver开发者_如何学JAVAsion it did say I might have to modify the project files before it builds. I have tried to search for a solution via google but the key words I am using are too commonly used. Can anyone advise?

Many thanks, Chris

Edit: Tried the following already..

  • Reference DLL specifically whilst ensuring not 4.0 copy
  • Delete bin and obj folders
  • Restart VS


Rather than referencing the output DLL, have you tried setting it as a project reference instead.

Also, have you done a clean build of the solution incase any .Net 4.0 files were lingering? You can manually clean the project by deleting the bin and obj folders.

Have you tried removing the projects from the solution, creating a new .net 3.5 project and compiling that. Then add in the ddl project (Add -> existing project) and compile, then add in exe project without reference, compile then add in the references.

Odd question, but have you check the name spaces still. Can you call in your project the namesapce, i.e. using mydllproject.model.myengine


I would open your project files as XML. To do this, close the soltion and reopen the projects only by clicking the down arrow on the File/Open button and selecting Open With... XML (Text) Editor. Check to make sure each project has a ToolsVersion="4.0" in the header. Check the RootNamespace and TargetFrameworksVersion elements to see if they have the values that you expect. At the bottom of the file, check the ProjectReference element within the ItemGroup. Make sure the GUID in the project reference matches the GUID that is defined in your solution file.

Finally, make sure you clean your project before you rebuild it. If you're using source control, check out the project into a new, empty sandbox.

Good Luck!


-Put dll and exe in 3.5
-Compile the dll only
-Delete the reference to the dll and readd it
-Rebuild the solution


Check the DLLs that you are referencing what kind of target runtime they require, especially the "Engine.dll". You could do this with the .NET Refractor for example. If they are compiled for v4.0, then yuou need to get versions for an earlier version of .NET runtime.


I had a very similar problem to this. In my case it I had two projects, a 'class library' and a windows forms application in the same solution.

After changing the target framework of both the projects to .NET4.0 framework, and adding a reference to the class library in my windows forms application, it wouldn't detect the namespace of my class library.

Here is what I did that finally solved the problem:

  1. Created a new project with .NET 4.0 framework as the target framework. I imported all my forms and classes into this project from the original solution.

  2. Added the existing class library as a new project.

  3. Added a reference to the class library project from my windows forms project

  4. For each of the class files under the class library project, I set the 'Build Action' to 'Compile'

  5. Right-clicked the class library project and selected to 'Rebuild'.

  6. Then when I go into my windows forms projects, I can see the namespace when I use the 'using namespace_name' statement.

Note: Maybe you do not need to create a new project like I did in the first few steps. But changing the Build Action definitely did the trick.

Hope it helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜