1

通过跟踪,这意味着我需要使语言环境保持中立,以便引用的 dll 工作。关于如何设置它的任何想法?还是您将中性设置为某种东西?

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

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

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

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

我确实在文件夹中有dll。我在 google 和其他网站上不知疲倦地搜索无济于事,确实找到了 1 个有相同错误但没有人能回答的人,其他一些发现不适用于此案例,因为仍然无法正常工作。任何人都可以这么好心并阐明这件事吗?

提前致谢

编辑:我运行了 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 库吗?

有人对可能发生的事情有任何其他想法吗?任何输入都将超过 apreciatted。

4

1 回答 1

0

Now: I generate the executable and move it to test PC and it doesnt work. the program just wont load. By this I mean it never reaches the load handle and just closes. After some tweaking around for testing a message came up:

There are two potential issues.

  1. Make sure you deploy your app.Config on the deployment machine. This will be a file named YourApplication.exe.config, and needs to be next to the .exe file. This is what sets the runtime policy properly at deployment.

  2. Make sure you're targeting the proper CPU architecture, since you're using a mixed mode assembly. If your system in x86, and the deployment is x64, and your app targets AnyCPU, then the mixed mode assembly will fail to load. Setting it to explicitly use x86 will correct this.

  3. Make sure that any native DLLs the mixed mode assembly uses are also available on the target system. This often includes installing the proper VC++ runtime.

于 2013-08-30T18:06:29.437 回答