开发者

Why does referncing earlier .net versions work on my local machine but not on another?

I have winforms application. When I look at the references they are all .net 4 (same as the application) apart from one which says v2.0. I can run the app locally and use functionality from the .net components but as soon as I take开发者_JAVA技巧 the app to another machine it wont fire up. Apparently this hapens when references cant be found.

Im very confused as to why this would work locally. I have checked the GAC and only .net 2.0 versions exist for the referenced dlls.?..

What are the rules around rererencing dlls from older versions on .net?


It is perfectly fine to have the two versions of the framework running on the same machine. Are both .NET 2 and .NET 4 installed on the second machine you are testing on? I suspect that they are not.


Yes you can reference .Net 2.0 dlls from .Net 4.0 project.

You might be referencing only .Net 2.0 dlls but your target framework might be .Net 4.0, which might not be available on your other machine.

To correct this: Open your project properties. Set Target framework to .Net Framework 2.0 or 4.0.

If you set it to 4.0, you must have 4.0 installed on the machine you want it to run on.

The quickest way to see which versions are installed on a machine: open VS command prompt and type clrver. (Ofcourse you'll need .Net SDK)

To see which framework your app uses type clrver you can get for your application from task manager (in process tab, click View->select columns->check PID)

Starting .NET 4.0, your app can target multiple frameworks in different AppDomains in the same process.

Remember that the framework that your application is determined automatically, but you can override this default behaviours. One way to do this is what I described above.


Note that the GAC location has changed between .Net 2.0 and .Net 4.0. You most likely have both versions installed on your machine and you have looked at the 2.0 GAC.

The second machine most likely does not have 2.0 installed, hence it fails running.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜