将 ChilkatDotNet4.dll 注册到 GAC 时出现问题
我正在尝试将 .NET 4.0 .dll 添加到 GAC 中。我尝试这样做是因为它是由第三方公司作为 32 位和 64 位 .dll 发布的,我必须在不同平台上的不同应用程序中以两种格式使用它。
无论如何,我在 Windows Server 2008 环境中将此 dll 注册到 GAC 时遇到了麻烦。
我尝试将本地计算机上的“C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools”中找到的 gacutil.exe (和支持文件)复制到“C:\Windows”根据找到的建议,目标生产服务器上的 \Microsoft.NET\Framework\v4.0.30319" 文件夹 此处。
然后我尝试将它们复制到“C:\Windows\Microsoft.NET\Framework64\v4.0.30319”。
从两个位置运行都表明安装成功。事实上,注册似乎成功:
- C:\Windows\Microsoft.NET\ assembly\GAC_64\ChilkatDotNet4\v4.0_9.0.8.0__eb5fc1fc52ef09bd\ChilkatDotNet4.dll
- C:\Windows\Microsoft.NET\ assembly\GAC_32\ChilkatDotNet4\v4 .0_9.0.8.0__eb5fc1fc52ef09bd\ChilkatDotNet4.dll
但是,运行引用 dll(64 位)版本的控制台应用程序会出错,并显示以下消息:
System.IO.FileNotFoundException:可以 不加载文件或程序集 “ChilkatDotNet4.dll”或其之一 依赖关系。指定模块 找不到。文件名: 'ChilkatDotNet4.dll'
因此,我现在使用 mkdir 手动创建了以下 GAC 条目,并从命令提示符复制(这可能会或可能不会实际工作。我不知道 gacutil.exe 有什么特别之处):
- C:\ Windows\Microsoft.NET\Assembly\GAC_MSIL\ChilkatDotNet4\v4.0_9.0.8.0__eb5fc1fc52ef09bd\ChilkatDotNet4.dll(使用 64 位版本的 dll)
- C:\Windows\Assembly\GAC_64\ChilkatDotNet4\v4.0_9.0.8.0__eb5fc1fc52ef09bd \ChilkatDotNet4.dll
- C:\Windows\ assembly\GAC_32\ChilkatDotNet4\v4.0_9.0.8.0__eb5fc1fc52ef09bd\ChilkatDotNet4.dll
每次“安装”该 dll 后,我测试并收到相同的错误。欢迎任何想法!
编辑:上述 GAC 问题实际上可能并不是罪魁祸首。事实证明,即使我创建一个全新的控制台应用程序项目并直接添加 .dll(以便它位于垃圾箱中),我仍然无法在服务器上运行它。另外,我注意到控制台应用程序是针对 .NET 4.0 客户端配置文件而不是 .NET Framework 4 创建的。当我尝试针对客户端配置文件运行它时,似乎没有任何 System.Web* 库可用。但是,我尝试运行一个针对两者的非常简单测试应用程序,但在引用错误的 .dll 时,两者都不会在服务器上运行。
是否需要进行特殊类型的安装来运行 .NET 4.0 控制台应用程序?
I'm trying to add a .NET 4.0 .dll to the GAC. I am attempting to do this because it is published by a 3rd party company as both a 32 and 64bit .dll which I must use from different apps on different platforms in both formats.
At any rate, I am having trouble registering this dll to the GAC on a Windows Server 2008 environment.
I have tried copying gacutil.exe (and supporting file) found at "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools" on my local machine to the "C:\Windows\Microsoft.NET\Framework\v4.0.30319" folder on the target production server per the suggestions found here.
I then tried copying them to "C:\Windows\Microsoft.NET\Framework64\v4.0.30319".
Running from both locations indicated successful installation. And indeed, the registration appears successful:
- C:\Windows\Microsoft.NET\assembly\GAC_64\ChilkatDotNet4\v4.0_9.0.8.0__eb5fc1fc52ef09bd\ChilkatDotNet4.dll
- C:\Windows\Microsoft.NET\assembly\GAC_32\ChilkatDotNet4\v4.0_9.0.8.0__eb5fc1fc52ef09bd\ChilkatDotNet4.dll
However, running a console app that refers to the (64bit) version of the dll errors out with the following message:
System.IO.FileNotFoundException: Could
not load file or assembly
'ChilkatDotNet4.dll' or one of its
dependencies. The specified module
could not be found. File name:
'ChilkatDotNet4.dll'
So, I have now manually created the following GAC entries using mkdir and copy from a command prompt (which may or may not actually work. I have no clue what is so special about gacutil.exe):
- C:\Windows\Microsoft.NET\assembly\GAC_MSIL\ChilkatDotNet4\v4.0_9.0.8.0__eb5fc1fc52ef09bd\ChilkatDotNet4.dll (using the 64bit version of the dll)
- C:\Windows\assembly\GAC_64\ChilkatDotNet4\v4.0_9.0.8.0__eb5fc1fc52ef09bd\ChilkatDotNet4.dll
- C:\Windows\assembly\GAC_32\ChilkatDotNet4\v4.0_9.0.8.0__eb5fc1fc52ef09bd\ChilkatDotNet4.dll
After each "install" of the dll, I tested and received the same error. Any ideas welcome!
EDIT: the GAC issue above may not actually be the culprit. Turns out, even when I create a brand new Console App project and add the .dll directly (so that it lives in the bin), I still can't run it on the sever. Also, I've noted that Console apps are created targeting the .NET 4.0 Client Profile rather than the .NET Framework 4. When I try to run it targeting the client profile, it appears that none of the System.Web* libraries are available. However, I tried running a very simple test app targeting both and neither would run on the server while referencing the bad .dll.
Is there a special kind of install that was to occur to run .NET 4.0 Console Apps?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于将来可能遇到此问题的任何其他人。这不是我将 dll 注册到 GAC 的方式或我如何从项目中引用它的普遍问题。
ChilkatDotNet4.dll(以及我确定的其他版本)是用 Visual C++ 构建的。因此,部署到的服务器必须安装适用于适当处理器体系结构的 Visual C++ 运行时。
对于 2010 (.NET 4.0):
如果您在 64 位平台上运行 x86 应用程序。确保将应用程序池标记为“启用 32 位应用程序”= true。
For anyone else who may have trouble with this in the future. It was not a generalized problem with the way I was registering the dll to the GAC or how I was referring to it from my projects.
ChilkatDotNet4.dll (and the other versions I'm sure) was built in Visual C++. So, the server it is being deployed to has to have the Visual C++ Runtime installed for the appropriate processor architecture.
For 2010 (.NET 4.0):
If you're running an x86 app on a 64-bit platform. Make sure to mark the application pool with "Enable 32-bit applications" = true.