开发者

Do you need to specify to use the latest framework version?

开发者 https://www.devze.com 2023-01-15 14:07 出处:网络
Have a project compiled to use (TargetFrameworkVersion) framework version 3.0 however it looks like there are some bug fixes in th开发者_StackOverflow社区e latest v4.0 framework and HF.As we want the

Have a project compiled to use (TargetFrameworkVersion) framework version 3.0 however it looks like there are some bug fixes in th开发者_StackOverflow社区e latest v4.0 framework and HF. As we want the app to be available even if it is leaking a bit on the earlier frameworks, we don't want to just set the target to 4.0.

When you browse the project you can see it has a runtime version but the 'specific version' is flagged false.

When we run the app, can we tell what framework parts it is actually using. Will it default to 3.0 or will it use the latest assemblies. If it defaults to 3.0 is there some way of setting some policy of some sort to use the new assembly if available.

Will compiling against/targeting the 4.0 framework yield any different results on top of using it at runtime?


When you run a .NET app, it will default to the version of the Framework it was compiled for. You can specify that it can use other Frameworks by including SupportedRuntime elements in the app config file in the Configuration/Startup section. However, I do not think an application can specify that it runs on a later framework than what it's built for.

If you want the runtime to try to use v4.0, but if that's not installed you will still run on v3.5, you should compile the app in 4.0 and include a SupportedRuntime element in the app config with the full version (including build) of v3.5.


When uncertain about what libraries are actually loaded by your application, you might consider executing some code in the debugger to list the loaded assemblies, as in this reference, or open the Modules debug window while the application is running (default shortcut in VS 2010: Ctrl-Alt-U).


If you compile against the 3.0 or 3.5 framework, and the client has only framework 4, it should try to use that version unless you have specific version set. However, there may be some breaking changes that you'd need to look out for. From what I can tell, there's not a good way to selectively mix the framework versions, and this doesn't seem like a really Good Idea(tm). Framework 4 is pretty ubiquitous now, though. It's probably safe to target it in most cases.

0

精彩评论

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