Reputation: 49
I have to create a dll written on c#. The dll will have to be used on two different types on machines: -MachineA that has got .net35 installed, but .net40 is not installed -MachineB that has bot .net40 installed, but .net35 is not installed Currently there is no option to install .net35 on MachineB, or to install .net40 on MachineA.
I would assume that creating a dll on .net35 would be able to be run on MachineB. But when I try to call any of the dll's functions, I get an error saying that the application needs .net35 to be installed
So the question is this: Is it possible to create the dll in a way that it will be compatible on both MachineA and MachineB?
Upvotes: 1
Views: 185
Reputation: 23298
You can configure your app to run on both versions of .NET (3.5 and 4.0) by adding multiple supportedRuntime
values in app.config
file
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
<supportedRuntime version="v2.0.50727"/>
</startup>
</configuration>
.NET Framework 4 and later uses v4.0
runtime, .NET Framework 2.0, 3.0, and 3.5 use v2.0.50727
runtime. Also, since you are targeting old .NET 3.5, it'll make sense to enable old runtime activation policy, useLegacyV2RuntimeActivationPolicy="true"
.
The configuration above runs your code on .NET 3.5, if only this version is installed. In case of both versions installed it'll will run on .NET 4.x
Yo can also have a look at this MSDN article for more details
Upvotes: 2