简体   繁体   English

C DLL没有在C#中加载

[英]C DLL doesn't load in C#

I have a simple C DLL (not COM). 我有一个简单的C DLL(不是COM)。 I have also a C# 2.0 application that runs it (dllimport). 我还有一个运行它的C#2.0应用程序(dllimport)。 The dll is placed in the exe of the application. dll放在应用程序的exe中。 I know that the dll is ok and also that my application that calls it success reading it, but when I move them to another computer it says that it can load the dll. 我知道dll是可以的,而且我的应用程序称它成功读取它,但是当我将它们移动到另一台计算机时它说它可以加载dll。

The error : "Unable to load the dll name.dll . This application has failed to start because the application configuration is incorrect." 错误:“无法加载dll name.dll。此应用程序无法启动,因为应用程序配置不正确。”

I used visual studio 2005 to create the dll. 我使用visual studio 2005来创建dll。 The targer computer is a side by side one. 目标计算机是一个并排的计算机。 When I took the folder of the side by side contains the CRT it didn't run. 当我拿着并排的文件夹包含它没有运行的CRT。 Thanks 谢谢

The C Dll can have various dependencies. C Dll可以具有各种依赖性。 Try using Dependency Walker tool to determine if there are any of them. 尝试使用Dependency Walker工具确定是否有任何一个。

Windows may have detected a side-by-side version configuration issue with your application. Windows可能已检测到您的应用程序的并行版本配置问题。

For example, the C dll will usually be compiled against a particular version of the Microsoft C runtime library , which might not be installed on your second computer. 例如,C dll通常将针对特定版本的Microsoft C运行时库进行编译,该库可能未安装在您的第二台计算机上。 It also doesn't have to be the C runtime library, it may be some other library. 它也不必是C运行时库,它可能是其他一些库。

How to diagnose it? 如何诊断?

Check out this article, http://blogs.msdn.com/junfeng/archive/2006/04/14/576314.aspx for a starting point, although no guarantees. 查看这篇文章, http://blogs.msdn.com/junfeng/archive/2006/04/14/576314.aspx作为起点,虽然没有保证。

I used a lot from the comments people wrote and they are right. 我从人们写的评论中使用了很多,他们是对的。 I used : Dependency Walker tool and process moniter and process explorer. 我使用:Dependency Walker工具和进程监视器和进程资源管理器。 I had a prblem of not detecting the right msvr80 at runtime by my application. 我有一个问题,就是我的应用程序在运行时没有检测到正确的msvr80。 I instaalled destributable package af VC++ amd didn't help. 我在VC ++ amd没有帮助的情况下安装了可分发的软件包。 The answear was in another discussion here and it Side-by-side configuration error (Microsoft.VC80.CRT v8.0.50608.0) It was a problem of security update : Microsoft.VC80.CRT v8.0.50727.4053 (Installed via a security update). answear在这里进行另一次讨论并且它并排配置错误(Microsoft.VC80.CRT v8.0.50608.0)这是安全更新的问题:Microsoft.VC80.CRT v8.0.50727.4053(通过安装安全更新)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM