.net 4.0 migration
Can a .net 3.5 c# project reference a .net 4.0 assembly and compile with it? What about run time? What about 4.0 compiling / running with 3.5?
EDIT: in particular, I have a 3rd party .net 开发者_运维百科assembly. It has extension points: I register my dll in app.config and it calls me (probably via reflection). Can I implement my dll in .net 4.0? when is the CLR version chosen, when the main exe comes up or when a dll needs some version of it?
No, you need to upgrade to 4.0 to reference a 4.0 assembly.
A .net 3.5 application needs to be retargeted at te 4.0 framework to become a .net 4.0 application and use .net 4.0 features. This shouldn't break anything (apart from requiring .net 4.0 on your user's PCs), but will allow you to start using .net 4.0 features.
You can retarget a .net 4.0 app down to 3.5 iff it doesn't use any .net 4.0 features. If it does, you will need to rewrite those bits of your code to work with .net 3.5.
Targeting a particular .net version is trivial - it's done by choosing the version from a drop-down list in your project properties.
Note for your particular situation, you can cause the 3rd party application to load version 4.0 of the framework using the <requiredRuntime>
configuration element. This will cause version 4.0 of the framework to load and hence your DLL can use 4.0 features.
Additionally, .NET 4.0 comes with a feature called In-Process Side-by-Site. I've never looked into this feature myself, but it might be useful for your situation as well...
精彩评论