Take the 2-minute tour ×

My dll is built on VS2008 with target framework as 3.5. The main application is in C++ and use C++/CLI to talk with the .net dll. When the application is deployed on an XP system where .net 4 alone is installed, an exception occurred where two of the assemblies are missing.

System.Core Version and System.Web.Extensions

After reading, a solution is referred as adding

    <supportedRuntime version="v4.0" /> 

to the configuration to force the use of framework 4. I don't have a config file to set supportedRuntime to 4 since i built it as a class library.

Any help will be appreciated.

share|improve this question
Create an app.exe.config file where "app" is the name of your C++ .exe file. Don't forget useLegacyV2RuntimeActivationPolicy = true. –  Hans Passant Jul 4 '12 at 12:25
Thank you Hans, but this throws the famous error - "this application has failed to start because the application configuration is incorrect. reinstalling this application may fix problem." –  Jimesh Jul 4 '12 at 12:39
Seems like <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/> made some difference. The order is also important, i guess. For the app to work with a 3.5 framework if framework 4 is not present the order seems to be <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/> <supportedRuntime version="v2.0.50727" /> –  Jimesh Jul 6 '12 at 4:31

2 Answers 2

You have to set that flag at run-time (I suppose you have some kind of activation code), check this post: http://reedcopsey.com/2011/09/15/setting-uselegacyv2runtimeactivationpolicy-at-runtime/.

It worked perfectly many times.

share|improve this answer

Add the configuration to .exe.config for each single executable using the library.

In case of COM services that would be dllhost.exe.config although that is ugly security-wise and worth additional thought about alternatives if you confirm that this is your case.

share|improve this answer

Your Answer


