views:

82

answers:

2

Is it possible to run an application built on .NET 3.5 with a plug-in built with .NET 4? Cheers, Christian

+1  A: 

Yes/No. To run the 4.0 component you must be running in the context of the .NET 4.0 runtime. However, your 3.5 application can run in the 4.0 runtime.

Mitchel Sellers
+1  A: 

You will need to rebuild (not exactly true, check update) the .NET 3.5 application to target .NET 4.0 because by default it will start in the .NET 2.0 runtime which will then not support the plugin.

If the machine only has .NET 4.0 framework installed the application will not run unless rebuilt to target it specifically.

Update:

Well, you don't need to rebuilt after all. Chris comment got me thinking and I just tested with a console application built for .NET 3.5. You can just specify in its application configuration file the following block:

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

If this is present in the configuration the application will use the .NET 4.0 runtime.

João Angelo
Not necessarily. If this is a asp.net app, then you can simply change the app pool to execute under .net 4 framework and make the appropriate modifications to the web.config. None of which requires a purposeful rebuild. However, if it is a winforms or similar app, then yes a rebuild/redeploy is required.
Chris Lively
@Chris Lively, that one I didn't know... thanks for the information.
João Angelo
@Chris Lively, you got me thinking and if you change the configuration file manually you don't need to rebuild, I tested with a console application but I imagine that it should also be the same for winforms.
João Angelo
@João Angelo: Interesting find.
Chris Lively
Thank's for the help! However, using the suggested startup-element in my WinForms application's config file caused it to crasch when launching it.
Christian
@Christian, it seems the safest option will be to rebuild and retarget to .NET 4.0.
João Angelo