简体   繁体   English

Windows Azure未找到C ++ / CLI项目的DLL

[英]Windows Azure not finding DLL of C++/CLI project

I have a C++/CLI project that wraps around an unmanaged C compression library, and this project is referenced by an MVC3 project that calls the C++ Compress function. 我有一个包含非托管C压缩库的C ++ / CLI项目,该项目由调用C ++ Compress函数的MVC3项目引用。

Everything works fine locally, but when I publish the solution to the Azure cloud, I get an error saying it could not find the module/dll: 一切都在本地工作正常,但当我将解决方案发布到Azure云时,我得到一个错误,说它无法找到模块/ dll:

Could not load file or assembly 'LZGEncoder.DLL' or one of its dependencies. 无法加载文件或程序集“LZGEncoder.DLL”或其依赖项之一。 The specified module could not be found. 指定的模块无法找到。

Why can't it find the DLL file? 为什么找不到DLL文件? is it going to the wrong place or being compiled at all? 是去了错误的地方还是正在编译? Is there any way I can check? 有什么方法可以检查吗? Thanks! 谢谢!

The problem was that the Visual C++ 2010 Runtime libraries were missing from the cloud side. 问题是云端缺少Visual C ++ 2010 Runtime库。

What I did was add the Visual C++ 2010 Redistributable package to the project, along with a script to silently install it at start up, and now the native dll's work. 我所做的是将Visual C ++ 2010 Redistributable包添加到项目中,以及在启动时静默安装它的脚本,现在是本机dll的工作。 You also need this if you're using native C dll's. 如果你使用的是原生C dll,你也需要这个。

Steps: 脚步:

1) Download Visual C++ 2010 Redistributable Package , and add it to your project. 1) 下载Visual C ++ 2010 Redistributable Package ,并将其添加到您的项目中。

2) Create a new batch file and add this to it: 2)创建一个新的批处理文件并将其添加到它:
vcredist_x64.exe /q /norestart
exit /b 0

3) Open the ServiceDefinition.csdef file and add this under the relevant WebRole element: 3)打开ServiceDefinition.csdef文件并将其添加到相关的WebRole元素下:

<Startup>
  <Task commandLine="InstallVCRedist.bat" executionContext="elevated" taskType="simple" />  
</Startup>  

UPDATE: 更新:
Visual C++ 2012 is out and the same script works, though everyone should make sure Azure is running atleast Windows Server 2008 R2 , otherwise the start-up task will hang and the role will never start (until you kill the vcredist process in the task manager via RDP). Visual C ++ 2012已经完成并且相同的脚本可以运行,但是每个人都应该确保Azure运行至少Windows Server 2008 R2 ,否则启动任务将挂起并且该角色将永远不会启动(直到您在任务管理器中终止vcredist进程通过RDP)。

IF you want to verify about what is on Azure VM, just try to unzip your CSPKG file and then again unzip .CSSX file (just rename CSSX to zip) and match that every references is all there. 如果要验证Azure VM上的内容,只需尝试解压缩CSPKG文件,然后再解压缩.CSSX文件(只需将CSSX重命名为zip)并匹配每个引用都在那里。 This way you can match what is on VM. 这样您就可以匹配VM上的内容。 Once you verify what DLL is missing in VS, select the Reference DLL and set its property "Copy Local" as "True". 验证VS中缺少的DLL后,选择参考DLL并将其属性“Copy Local”设置为“True”。

You need to place all dlls in the folder which is exist on live server. 您需要将所有dll放在实时服务器上存在的文件夹中。 If you add refrence from your local and that location is not exist on live than you cannot build code on live. 如果您从本地添加引用并且该实时不存在该位置,则无法在实时上构建代码。 So make sure that all the dlls are exist on the live before deploy code on live. 因此,在实时部署代码之前,请确保所有dll都存在于实时。

Make sure the C++ dll and the unmanaged C library (if it's a .dll and not just source) are both included in your service package, and make sure the compiler's dumping the C++ library in the right place. 确保C ++ dll和非托管C库(如果它是.dll而不仅仅是源代码)都包含在服务包中,并确保编译器将C ++库转储到正确的位置。 This article has a decent walkthrough. 这篇文章有一个不错的演练。

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

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