Reputation: 429
I have noticed that I can run some .NET applications with dll's compiled for .NET 3.5 without a change on a computer with only .NET 4.0 installed. However it's not always like this: if I use some dll's in the application that use the System.Core reference then the application won't start because it doesn't find System.Core and I have to add the following to the Name.exe.config:
<configuration>
<startup>
<supportedRuntime version="v4.0" />
</startup>
</configuration>
Why do I need to use this only if I use System.Core? I know that System.Core was added in .NET 3.5, but what difference does it make to .NET 4.0? The other references are even older from .NET 1.1 or 2.0 so why don't they give problems?
Upvotes: 3
Views: 920
Reputation: 5715
I think the reason is in .NET 4 System.Func<TResult>
has moved from System.Core.dll to mscorlib.dll. So, even you can compile the project, it may not be able to run since it cannot find that method in mscorlib.dll.
You can fix this by update your project file to reference System.Core.dll in .NET 3.5 like below.
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
Upvotes: 1