XBAP:混合模式程序集无法加载.net 4.0 [英] XBAP: Mixed mode assembly unable to load in .net 4.0

查看:90
本文介绍了XBAP:混合模式程序集无法加载.net 4.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!
我遵循了在.NET 4.0应用程序中加载.NET 2.0下编译的程序集的建议,即将此元素添加到应用程序配置文件中:
< ; startup useLegacyV2RuntimeActivationPolicy =" true">
    < supportedRuntime version =" v4.0" />
  < / startup>

我的问题是如何在WPF XBAP编译的.NET 4.0应用程序中进行此操作。我已经尝试使用此元素添加配置文件,但我仍然遇到此异常:

混合模式程序集是针对运行时的版本"v2.0.50727"构建的,无法在4.0运行时加载没有其他配置信息。

有任何建议吗?

Hi!

I've followed the advice on loading assemblies compiled under .NET 2.0 in a .NET 4.0 application, namely to add this element to the application configuration file:
<startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0"/>
  </startup>

My question is how to go about this in an WPF XBAP compiled .NET 4.0 application. I've tried adding a configuration file with this element, but I still get this exception:

Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.

Any advice?

推荐答案

您使用的是哪个版本的.NET 4? RC,Beta2,还有什么? (如果您不确定,请发布目录名称%WinDir%\ Mesrosoft.NET \ Framework \ v4.0。*)

尝试为此创建一个小的repro。我在4.0 RC上尝试了这个,它适用于我:


Which version of .NET 4 do you use? RC, Beta2, something else? (If you are not sure, please post name of directory %WinDir%\Microsoft.NET\Framework\v4.0.*)

Try to create a small repro for that. I tried this on 4.0 RC and it works for me:

; File: Library.def
EXPORTS
    PrintHelloWorld

// Library.cpp
// Compile: cl.exe /LD /clr Library.cpp /link /def:Library.def
void ManagedFunction() {
    System::Console::WriteLine(L"{0}", System::Environment::Version);
}

#pragma managed(push, off)
extern "C" {
    void PrintHelloWorld() {
        ManagedFunction();
    }
}
#pragma managed(pop)

// HelloWorld.cpp
// Compile: cl.exe HelloWorld.cpp Library.lib
extern "C" {
    void PrintHelloWorld();
}
void main() {
    PrintHelloWorld();
}

<!-- HelloWorld.exe.config -->
<configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0" />
    </startup>
</configuration>



-Karel


-Karel


这篇关于XBAP:混合模式程序集无法加载.net 4.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆