简体   繁体   中英

Is it possible to run a .NET 3.5 DLL in a .NET 4.5 only environment?

I have a DLL which has been built targeted for .NET framework 3.5 and used from the COM context. However in Windows 2012 R2 onwards, 3.5 framework is not present; only 4.5 is present.

Is it possible to get it to work without a rebuild on an environment without 3.5 present? I was reading about app.config setting the preferred run-time etc. If yes, where should I be placing the config file?

(I saw a few posts regarding scenarios where the executable payload is an application eg. Running .NET 3.5 apps on .NET 4 only systems )

I haven't tried it myself.

From Microsoft website https://msdn.microsoft.com/en-us/library/windows/desktop/hh848079%28v=vs.85%29.aspx

For App developers (and IT Administrators):

IT administrators can configure .NET 3.5 apps to run on either .NET 3.5 or .NET 4.5 (depending on what's already installed). In order to run a managed app on either 3.5 or 4.5, just add a section in the application configuration file. This will ensure that if .NET 3.5 is installed, the app will run on .NET 3.5; otherwise the app will run on .NET 4.5. An example of the additional section in the configuration file is provided below:

<configuration>
   <startup>
      <supportedRuntime version="v2.0.50727"/>
      <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
   </startup>
</configuration>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM