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

时间:2013-08-30 17:59:20

标签: vb.net winforms .net-assembly side-by-side

使用跟踪意味着我需要使区域设置保持中立,以便引用的dll能够工作。有关如何设置它的任何想法?或者你把中立设置为什么?

我做了一个测试程序。我在Windows窗体中使用VS2010,VB.net,.Net Framework 4.0。它是一个本地测试应用程序,只需要最少的工作(带有几个标签和几个按钮的表单)。 我得到了一个.net框架2.0中的.dll。所以我引用了它。它没用。所以我搜索了解决方案,发现它与另一个有点不同,因为我必须做两件事才能让它工作:

在app.config中添加“startup useLegacyV2RuntimeActivationPolicy =”true“”并将目标框架从“.NetFW4.0客户端”更改为“.NetFW4.0”。这使它在我的开发PC中运行。通过VStudio或.exe进行调试并正常工作。

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

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

我在文件夹中有dll。我在谷歌和其他网站上不知疲倦地搜索无济于事,确实发现有一个人有同样的错误,没有人可以回答,其他一些发现不适用于这种情况,因为仍然无法正常工作。有谁可以这么善良,并对此事有所了解?

提前致谢

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

=================
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:\Windows\WinSxS\manifests\x86_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:\Windows\assembly\GAC_32\Microsoft.VC80.CRT\8.0.50727.6195__1fc8b3b9a1e18e3b\Microsoft.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 ++ reditributable。有谁知道我的安装程序包含VSMC80库?

任何人对可能发生的事情有任何其他想法?任何输入都不会超过预期。

1 个答案:

答案 0 :(得分:0)

  

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

有两个潜在的问题。

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

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

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