- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个由 Visual Studio 为我在 .NET dll 中使用的第三方 COM 对象生成的 Interop dll。
我已经在 GAC 中注册了我的消费 dll 和 Interop dll。我必须使用 GAC,因为 SharePoint 2010 工作流正在使用这些 DLL。
当执行到达我的 dll 调用 Interop dll 的点时,抛出以下错误“无法加载文件或程序集”……“系统找不到指定的文件”以及预期的版本和公钥。
如果我检查 Fusion Assembly Binding Log Viewer,Interop dll 的日志条目中会列出以下错误:
LOG: GAC Lookup was unsuccessful.
最佳答案
问题是,除了版本和公钥有效之外,处理器架构 Interop 必须与您的调用 DLL 相匹配。而且,当然,目标框架必须是相同的版本。
我的 dll 被编译到 MSIL(Agnostic,AnyCPU)处理器,但出于某种奇怪的原因,Visual Studio 坚持将 Interop 编译为 x386。
(也许这通常不会导致问题,但我的 SharePoint 服务器是 64 位,这可能导致出现症状)。
解决方案是自己编译Interop:
1 - 从 GAC 注销您的 dll 和互操作。
2 - 启动 Visual Studio 命令提示符 与 .NET 框架相关的 Visual Studio 版本的 dll 目标 (即我正在 Visual Studio 2010 中开发我的 dll,目标是 .NET 3.5。要执行此步骤,我需要启动 Visual Studio 2008 命令提示符)
3 - 使用 Tlbmp 生成互操作
tlbimp <full path and filename of COM .tlb> /out:c:\.\Interop.CoolThirdParty.dll /keyfile: <full path and filename of snk> /machine:Agnostic /Namespace:CoolThirdParty
关于.net - GAC – 程序集在 GAC 中,但 “Could not load file or assembly”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3394106/
我是一名优秀的程序员,十分优秀!