开发者

Using VS 2010, can I reference a project created in VS 2005?

Here's a puzzler - something that doesn't work that I assumed would (no surprise there).

We have a library project that is referenced in a few other desktop app projects. The library project is written in VS 2005 (.NET 2.0).

My problem is that some of our apps still live in VS 2005 for the time being (for various reason). I can't seem to re开发者_开发技巧ference this library project in VS 2010 without it demanding that I upgrade it to .NET 4, which if I do, then breaks my ability to include it as a reference in my VS 2005 projects.

This type of thing fries my brain. Is there any way I can make this work?


Hmm, that doesn't make a lot of sense. You don't reference a 'library project', you reference the DLL that it produces. Project + Add Reference, Browse tab. There's no known problem with that, within a 95% accuracy guess, mixed mode assemblies have a few hairs.

If you actually try to load a vs2005 project into a vs2010 solution, then yes, it's going to try to convert the project file. And that turns vs2005 catatonic, it doesn't have the time machine to guess what a vs2010 project looks like. Just making a copy of the project directory solves that problem.


Can you change the .NET version back to 3.5 or 2.0 in VS.NET 2010 after it revises the project version to .NET 4.0?


Use a file reference to the built dll, rather than a project reference.

You may also find you need to add an extra bit of compatible-framework info to your manifest file to tell .net to allow your .exe to use .net 4 and .net 2 assemblies alongside each other - if it's not there you'll just get an error on startup. (Sorry, I can't remember the exact details and I'm not at my work machine right now to be able to find them - but if you have problems at runtime, the error message should lead you to the exact solution you need)

Correction: I was thinking of this 'useLegacy' startup setting, which you may need to add to your app.config if you want to use a mixture of .net 2.0 and .net 4.0 assemblies in your application:

<startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>


On option, that is a complete PITA, but should work is:

Create a new project file in 2010 that includes everything the 2005 project file has. Just call it MyProject2010.csproj or whatever.

Then, add this project to your 2010 solution.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜