Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
151 views
in Technique[技术] by (71.8m points)

c# - 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.

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:

Could not load file or assembly 'LZGEncoder.DLL' or one of its dependencies. The specified module could not be found.

Why can't it find the DLL file? is it going to the wrong place or being compiled at all? Is there any way I can check? Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The problem was that the Visual C++ 2010 Runtime libraries were missing from the cloud side.

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. You also need this if you're using native C dll's.

Steps:

1) Download Visual C++ 2010 Redistributable Package, and add it to your project.

2) Create a new batch file and add this to it:
vcredist_x64.exe /q /norestart
exit /b 0

3) Open the ServiceDefinition.csdef file and add this under the relevant WebRole element:

<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).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...