What 'additional configuration' is necessary to reference a .NET 2.0 mixed mode assembly in a .NET 4.0 project?

后端 未结 17 961
死守一世寂寞
死守一世寂寞 2020-11-22 08:20

I have a project in which I\'d like to use some of the .NET 4.0 features but a core requirement is that I can use the System.Data.SQLite framework which is compiled against

相关标签:
17条回答
  • 2020-11-22 08:48

    I was facing a similar issue while migrating some code from VS 2008 to VS 2010 Making changes to the App.config file resolved the issue for me.

    <configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0.30319"
             sku=".NETFramework,Version=v4.0,Profile=Client" />
    </startup>
    </configuration>
    
    0 讨论(0)
  • 2020-11-22 08:49

    I ran into this issue when we changed to Visual Studio 2015. None of the above answers worked for us. In the end we got it working by adding the following config file to ALL sgen.exe executables on the machine

    <?xml version ="1.0"?>
        <configuration>
            <startup useLegacyV2RuntimeActivationPolicy="true">
                <supportedRuntime version="v4.0" />
            </startup>    
    </configuration>
    

    Particularly in this location, even when we were targeting .NET 4.0:

    C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools

    0 讨论(0)
  • 2020-11-22 08:53

    I found a way around this after 3-4 hours of googling. I have added the following

    <startup selegacyv2runtimeactivationpolicy="true">
      <supportedruntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client" />
    </startup>
    

    If this doesn't solve your problem then--> In the Project References Right Click on DLL where you getting error --> Select Properties--> Check the Run-time Version --> If it is v2.0.50727 then we know the problem. The Problem is :- you are having 2.0 Version of respective DLL. Solution is:- You can delete the respective DLL from the Project references and then download the latest version of DLL's from the corresponding website and add the reference of the latest version DLL reference then it will work.

    0 讨论(0)
  • 2020-11-22 08:53

    I Use

    <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0"/>
        <supportedRuntime version="v2.0.50727"/>
    </startup>
    

    It's works but just before de </configuration> tag otherwise the startup tag doesn't work properly

    0 讨论(0)
  • 2020-11-22 08:55

    I used this config:

    <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v2.0"/>
        <supportedRuntime version="v4.0"/>
    </startup>
    

    Worked for me

    0 讨论(0)
  • 2020-11-22 08:58

    If your are working in a web service and the v2.0 assembly is a dependency that has been loaded by WcfSvcHost.exe then you must include

    <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0" />
    </startup>
    

    in ..\Microsoft Visual Studio 10.0\Common7\IDE\ WcfSvcHost.exe.config file

    This way, Visual Studio will be able to send the right information through the loader at runtime.

    0 讨论(0)
提交回复
热议问题