发布不起作用,将FW 2.0 dll引用到FW 4.0 winform中



对于跟踪,这意味着我需要使语言环境中立,以便引用的dll能够工作。你知道怎么设置吗?或者你把中立设置成什么?

我做了一个测试程序。我在Windows窗体中使用VS2010、VB.net、.net Framework 4.0。这是一个本地测试应用程序,最低限度地工作(表单有几个标签和几个按钮)。我得到了一个在.net框架2.0中制作的.dll。所以我引用了它。它不起作用。因此,我搜索了解决方案,发现它与其他解决方案有点不同,因为我必须做两件事才能使其工作:

在app.config中添加"startup useLegacyV2RuntimeActivationPolicy="true",并将目标框架从".NetFW4.0 client"更改为".NetFW4.0"。这使它在我的开发PC中工作。通过VStudio或.exe.调试并正常工作

现在:我生成可执行文件并将其移动到测试PC,但它不起作用。程序就是无法加载。我的意思是,它永远不会到达负载手柄,只是关闭。经过一些测试调整后,出现了一条消息:

无法加载文件或程序集"banortepinpad.dll"或其依赖项之一。应用程序无法启动,因为它的并行配置不正确。有关详细信息,请参阅应用程序事件日志或使用命令行sxstrace.exe工具。(HRESULT:0x800736B1的异常)

我确实在文件夹里有dll。我在谷歌和其他网站上不知疲倦地搜索,但没有结果,确实找到了一个有相同错误的人,没有人能回答,其他一些发现不适用于这种情况,因为仍然不起作用。有谁能好心一点,告诉我这件事吗?

提前感谢

编辑:我运行了sxtrace,发现了这个:

=================
Start Activation context generation .
Input parameter :
Flags = 0
ProcessorArchitecture = x86
CultureFallBacks = es-ES , is
ManifestPath = C :  Banorte  BanortePinPad.dll
AssemblyDirectory = C :  Banorte 
Application Config File =
-----------------
INFO: analyzing manifest file C :  Banorte  BanortePinPad.dll .
INFORMATION : defining the identity of the manifesto is (null ) .
INFO: Reference :Microsoft.VC80.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.6195"
INFO: Reference :Microsoft.VC80.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50608.0"
INFORMATION : resolving reference Microsoft.VC80.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.6195".
INFO: x86 solving ProcessorArchitecture reference .
INFORMATION : solving Neutral culture .
INFORMATION : binding policy applied .
INFO : Find publisher policy at C:WindowsWinSxSmanifestsx86_policy.8.0.microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.4940_none_516d712b0f495a45.manifest
INFO: not found redirection binding policy .
INFO: start assembly poll .
INFORMATION : Could not find the assembly in WinSxS .
INFO : Attempt to probe manifest at C:WindowsassemblyGAC_32Microsoft.VC80.CRT8.0.50727.6195__1fc8b3b9a1e18e3bMicrosoft.VC80.CRT.DLL.
INFO : Attempt to probe manifest at C:  Banorte  Microsoft.VC80.CRT.DLL .
INFO : Attempt to probe manifest at C:  Banorte  Microsoft.VC80.CRT.manifest .
INFO : Attempt to probe manifest at C:  Banorte  Microsoft.VC80.CRT  Microsoft.VC80.CRT.DLL .
INFO : Attempt to probe manifest at C:  Banorte  Microsoft.VC80.CRT          Microsoft.VC80.CRT.manifest .
INFORMATION : Could not find the manifest of the culture Neutral .
INFORMATION : complete assembly poll .
ERROR : can not resolve the reference
ERROR: Activation context generation .
Finish Activation context generation .

以下是我的app.exe.config内容:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
    </startup>
</configuration>

这个跟踪是我在编辑和修复app.exe.config之后得到的,如上所示。

这是否意味着我需要程序集的清单才能工作?

我还没有找到方法。我已经检查了程序集,并在目标pc上安装了vc++可信任文件。有人知道安装程序包含VSMC80库吗?

有人对可能发生的事情有其他想法吗?任何输入都会被忽略。

现在:我生成可执行文件并将其移动到测试PC,但它不起作用。程序就是无法加载。我的意思是,它永远不会到达负载手柄,只是关闭。经过一些测试调整后,出现了一条消息:

有两个潜在的问题。

  1. 请确保在部署计算机上部署app.Config。这将是一个名为YourApplication.exe.config的文件,并且需要位于.exe文件旁边。这就是在部署时正确设置运行时策略的原因。

  2. 确保您的目标是正确的CPU架构,因为您使用的是混合模式程序集。如果你的系统是x86,部署是x64,并且你的应用程序以AnyCPU为目标,那么混合模式程序集将无法加载。将其设置为显式使用x86将更正此问题。

  3. 确保混合模式程序集使用的任何本机DLL在目标系统上也可用。这通常包括安装正确的VC++运行时。

最新更新