Windows Azure not finding DLL of C++/CLI project - c#

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!

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

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. This way you can match what is on VM. Once you verify what DLL is missing in VS, select the Reference DLL and set its property "Copy Local" as "True".

You need to place all dlls in the folder which is exist on live server. 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.

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. This article has a decent walkthrough.

Related

How to make it a program work on every Windows pc?

I have created a application which connects and performs function to a database. However when I compile and publish the application my clients report a error message while trying to open the file about a missing file.
So they need to have the connector installed before they can use my application, how can I fix this?
Create an installer that ensures this dependency is met. WiX is the normal route here. The WiX tools do not depend on VS, although the VS tools make things a little easier for you.
-or-
In VS, open the references section of your project, find the reference to MySql.Data, go to properties and set "Copy Local" to true and rebuild. Now the .dll will be copied to your bin folder, ready for redistribution as you see fit.

Create a standalone .exe file

I have a console application built in visual studio 2010.
When I actually build the project I am getting .exe file under \bin\Debug\MyProj.exe.
When I Paste and run this .exe from other location it is expecting other files too.
Any thoughts how can I make this as Stand alone exe file.
There should be other DLL's in the Debug library. You need those to run your exe.
If there are no DLL's there, make sure you set the 'Copy local' property of the required references to True, and build again.
If you want to make a standalone program, you should create a new Setup project in your solution. Include the Primary Output from your application project, and the setup should include the required DLL's automatically. Once you build the setup project, you can install your application as a standalone software.
You usually distribute application with bunch of DLLs, that's nothing bad.
But if you really want to make it a single exe, you can look here - same question is answered Embed .net dll in c# .exe . (Valid if your DLLs are also .Net assemblies)
Edit: If you need to easily distribute app to not-very-computer-friendly users, consider also trying ClickOnce. It's roughly something like Java Web start - only disadvantage is that you can't get "Windows Logo" certificate from Microsoft for projects distributed that way.
I don't have Visual Studio 2010 to experiment with, but in Visual Studio 2019 this worked:
Project Properties->Configuration Properties->Advanced->Use of MFC->Use MFC in a Static Library

C# Missing MSVCR100.dll

I'm developing an app that execute another app and I received this error:
the program can't start because MSVCR100.dll is missing from your
computer
with my C# app, can I fix this problem copying this .dll into windows/system32 folder?
Or exists another method to do this?
This links below point to the proper downloads for the MSVCRT100 installer. This is likely what you want your customers to run before installing your app. This will properly install the MSVCRT DLLs in the proper directory such that all applications can use it.
Microsoft Visual C++ 2010 Redistributable Package (x86) (probably what you need for 32-bit and 64-bit os)
Microsoft Visual C++ 2010 Redistributable Package (x64) (Only if your app itself is 64-bit)
If you actually want to install the MSVCRT100 DLLs through a merge module within your own MSI - you can link your MSI to the MSMs that are located in the x86 version your "c:\program files\common files\merge modules" directory" (Assuming you have Visual Studio 2010 installed).
C:\Program Files (x86)\Common Files\Merge Modules>dir *CRT*.msm
Volume in drive C has no label.
Volume Serial Number is 60A4-1718
Directory of C:\Program Files (x86)\Common Files\Merge Modules
04/22/2011 01:18 PM 584,192 Microsoft_VC100_CRT_x64.msm
04/22/2011 01:41 PM 571,904 Microsoft_VC100_CRT_x86.msm <-- This is likely the MSM you want if your app is 32-bit.
04/22/2011 01:14 PM 847,360 Microsoft_VC100_DebugCRT_x64.msm
04/22/2011 01:39 PM 801,792 Microsoft_VC100_DebugCRT_x86.msm
Two other alternatives:
Instead of copying MSVCRT100.dll into a system directory, copy it into the directory of the EXE app you are trying to launch that depends on this DLL. This isn't recommended, but won't run the risk of breaking other apps.
Another alternative. If you actually have the source code to the EXE that you are trying to launch, you can completely bypass all of this "install msvcrt100.dll" noise by just statically linking to it. In visual studio, it's the option in the project's propery dialog under C/C++ (under the Code Generation tab). Change "runtime library" from "Multi-threaded Dll" to just "Multi-threaded". This adds the /MT compiler switch.
Whatever program you're trying to start has to be properly installed first. Msvcr100.dll is one of the DLLs that need to be deployed for programs written in C or C++ with VS2010. It is simple with a Setup and Deployment project or by building the program with the /MT option. Contact the program owner for support.
what is missing is the Visual C++ runtime.
are you starting a C++ application from your C# code? if so, make sure the proper runtime is available on the client machines.
You should be able to fix this by copying it and registering it (with command line: regsvr32 "DLLNAME") or you can ship it with your executable and it should work
WARNING: Please consult the following article before including the file with your software... http://msdn.microsoft.com/en-us/library/ms235299.aspx
I take no responsibility for your actions

VS console app - compile all libraries into an exe

I've created a basic console app in Visual Studio 2008, which references an external assembly.
When I publish and install the project, both the executable and the external assembly are installed in the target folder.
Is it possible to compile the project, and have all referenced assemblies included in the main executable - so there is only one file to distribute?
Thanks for any help,
Franko
You can use ILMerge to merge the assemblies for deployment. This lets you keep them separate during development, but put them all into one .exe file when you ship.
You can use ILMerge from Microsoft for this, or the Cecil tool from the Mono project.
You can create a setup file. so you can redistribute only one file.
But it still going to be installed into a folder with each assembly separated.
You can also consider placing your assemblies into the GAC.
If you find ILMerge is not enough because your app needs files other than .net assemblies, I have found that packaging it as self extracting exe using MakeSFX works nicely. It sounds unlikely but with correct command line flags the self extracting bit is completely transparent and it runs just like any other application.

application has failed to start because the side by side configauration is incorrect

HI
I have creted an exe by c++ using visualstudio. I have creted a com componet which discover all the instances of sqlserver on particular machine.now in c++ program using visualstudio i write main() and consume the com component.
Now it should worrk on my both workstations which are w2k3 machines.And when i try to run the same on w2k8 machine i got the error as
the application has failed to start because the side by side configauration is incorrect and for details see the application event error log
i open the application error log and found the error as
Activation context generation failed for "E:\SQLDiscovery.exe". Dependent Assembly Microsoft.VC80.DebugCRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50608.0" could not be found. Please use sxstrace.exe for detailed diagnosis.
How to resolve this one plz help me
You have to install the VC8 Runtime on W2k8. This is due to Windows Side by Side configuration.
When you build and EXE, a special file is generated called "manifest", this manifest file describe the version of the C runtime library that is needed by your application in order to run correctly.
The Manifest is then embedded into your exe/dll ( if you actually opened the .dll/exe using notepad and scrolled to the end, you will see it in xml format), you cal also use mt.exe ( manifest tool ) to view the manifest inside any executable.
When you move your application to W2k8, you have to ensure the dependent CRT is installed ( unless you statically link your app with CRT).
You can resolve this issue by either one of these
1- Install VC8 Debug CRT
2- Build you app as statically linked
Check out this blog as well
http://detritus.blogs.com/lycangeek/2006/08/diagnosis_of_wi.html
It contains useful information about how to debug winsxs issues.
Hope this helps
The problem is that the EXE requires the debug CRT DLLs and they are not present on the 2008 machine. How you fix this depends on what you want/need to do.
If you want to use the debug CRT, either link statically to the CRT (removing the need to have the DLLs on the 2008 machine) or create a directory called "Microsoft.VC80.DebugCRT" in the same directory as the EXE, and put the necessary DLLs and the debug CRT manifest file there.
The debug CRT is not redistributable, AFAIK there is no way to "install the debug CRT" other than installing all of Visual Studio.
If you don't actually need the debug CRT, link with the release version. Again, you'll need to choose between the static LIB and the DLL version. The good news is that the release CRT is redistributable, check your Visual Studio install directory for vcredist_x86.exe.
Don't ship debug builds. Build it in release, and then put that on your target machine.
If you use the CRT (you do) then you need to install the CRT redistributables. You need to install (on the target machine) the ones which match the version & SP of the compiler you used to build the application. It's very simple & standard practice
Here's a link where you can get the redists for VC8: link
And here's a link for the redists for VC8 SP1: link text
Just google "vc8 redist" or whichever version you are using and you will find your way.
Don't statically link your app just to avoid having to install the redists.

Categories

Resources