C++/CLI Missing MSVCR90.DLL - visual-studio

I have a c++/cli dll that I load at runtime and which works great in debug mode. If I try and load the dll in release mode it fails to load stating that one or more dependencies are missing. If I run depends against it I am missing MSVCR90.DLL from MSVCM90.DLL. If I check the debug version of the dll it also has the missing dependency, but against the debug (D) version.
I have made sure debug/release embed the manifest file. I read something about there being issues with the app loading the dll being build as Any CPU and the dll being built as x86, but I don't see how to set them both to x86.
I am using VS2010.
Anyway, I've been messing around for a while now and have no idea what is wrong. I'm sure someone out there knows what is going on. Let me know if I need to include additional info.
alt text http://www.freeimagehosting.net/uploads/fb31c0e256.png
UPDATE:
This ended up being the resolution to my problem: http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/07794679-159b-4363-ae94-a68fe258d827

MSVCR90 is the runtime for Visual Studio 2008. If you are running your application on your development PC, then you should have the debug and release runtimes installed (as part of Visual Studio) but it is possible something has gone awry with your install, or that VS2010 doesn't actually include the older runtimes. If you're trying to run the Release on a different PC, then it just needs the runtime installed.
Either way, you may be able to fix it by installing the Visual Studio 2008 redistributable - but make sure you get the right download for your PC (x86 or x64).
In previous versions of VS, you needed the runtime for the version you were compiling with, so if VS2010 follows this precedent you'd need MSVCR100, not MSVCR90 - which suggests that you may not have recompiled the dll with VS2010 - doing so may be another approach to get it running on your PC (using the redist that is in your VS2010 install) but beware that you will still need other users to install the appropriate (VS2010) redistributable on their PC.
As for "Any CPU" versus "x86", this is a problem only on a 64-bit computer. On those systems a 64-bit application can't link dynamically to 32-bit dlls. If you compile your application as "Any CPU" it will be JIT compiled to be 64-bit on an 64-bit OS, so will crash if it tries to call any 32-bit dlls directly. THe solution is to build the application targeting "x86" as that forces the JIT compiler to generate 32-bit code (even on a 64-bit machine) and thus ensures compatibility with the dll you wish to call. If the DLL is a managed assembly, then you can use Any CPU on both the app an dll as they will both be JITted to the same format.

It happened to me something similar running a website in Vistual Studio 2012, after migrating from Visual Studio 2010. The error message was saying that MSVCR90.DLL was missing. The solution was:
1) Delete the folder _bindeployable located at the project path.
2) Rebuild.
I hope it helps.

Related

Directing an application to find a DLL in a specific location

I'm working with a native C++/Win32/MFC application built using Visual Studio 2010 Pro on Windows 7 x64. The application is linked with some other DLLs using their .lib files.
I'd like to be able to run this application and have it find the DLLs in their respective directories without 1) having to put the DLLs in the application directory or 2) add the DLL directories to the PATH or 3) resort to dynamically loading the DLLs and having to lookup stuff at runtime.
Is this even possible? Is there some way to direct the OS loader to go find the DLLs in an arbitrary location I specify without having to add that to the PATH?
Basics:
In Visual Studio project settings, keep everything default specially in Release configuration.
Ensure that you give Release build to the client (Where VS wouldn't have been installed).
If client OS is 32-bit, you must give 32-bit. Otherwise you can give 64-bit (Release build in any case).
Now comes distribution and VC++ runtime library.
You must install appropriate Visual C++ Runtime on client's machine,
ensuring that:
The version should match (VC7, VC8,.. VC14 etc.)
The bit-ness should match. If your application is 32-bit, you need 32-bit
redistributable, and same for x64.
The service pack version must also
match!
It should be noted that all of them can co-exist! VC10 RTM, VC10 SP2, VC10 x64 RTM.. all can co-exist

“MSVCP100.dll is either not designed to run on Windows or it contains an error”

I built an application in C++ using Visual Studio 2010 Express. When I tried to run it on a certain computer today I got this error:
MyApplication.exe - Bad Image
C:\Path to My Application\MSVCP100.dll is either not designed to run on Windows or it contains an error. Try installing the program again using the original installation media or contact your system administrator or the software vendor for support.
The DLL mentioned is one of the Visual C++ Redistributable DLLs. My application’s installer used to launch Microsoft’s installer for those DLLs but I recently tweaked it just to install msvcp100.dll and msvcr100.dll alongside my application. The new way worked fine on a handful of other computers, though I can’t rule out the possibility that that was only because the DLLs had already been installed at system level on those other computers.
What is causing this sudden DLL mismatch?
That's STATUS_INVALID_IMAGE_FORMAT, the Machine property in the DLL header doesn't match the architecture of the application.
Do keep in mind that you are likely to have two copies of this DLL on your build machine, the x86 and the x64 version. Later versions of VS have a 3rd copy, the ARM version. So very high odds that you picked the wrong one. Usually you'd target x86, the one you tested your program with is stored in the c:\windows\syswow64 directory. The 64-bit version is in c:\windows\system32.
How these directories got these seemingly backward names is a story for another day :) Favor using the vc/redist subdirectory of the VS install directory as a source for the copy, it is less ambiguous.
This .dll file is related to the Microsoft Visual C++ 2010 Redistributable x64 Package.
Try removing the Microsoft Visual C++ 2010 Redistributable x64 Package by using the Add or Remove Programs item in Control Panel.
Then, install the latest version Visual C++ (file name= vcredist_x64.exe) from the site:
http://www.microsoft.com/en-us/download/details.aspx?id=26999
Hope that helped..
If all above suggested solutions not worked for you than download MSVCR100.dll 32 bit or 64 bit as per your system configuration.
Download DLL from below link
https://www.sts-tutorial.com/sites/downloadCenter.php?MSVCR100
Follow da steps
1.Download the dll from here
https://www.sts-tutorial.com/sites/downloadCenter.php?MSVCR100
2.open with winrar
3.Extract MSVCR100.dll to C:\Windows\System32
hope it will work c:

The application was unable to start correctly (0xc000007b)

I have a client/server app which I have been developing on a single PC. Now it needs two serial ports, so I borrowed a PC from a friend.
When I build my app and try to run or debug it (whether in the Delphi IDE or from Windows File manager), it errors "The application was unable to start correctly (0xc000007b)".
Googling doesn't bring up much, but seems to indicate that this is nothing Delphi specific and happens with other apps. It seems to be caused by calling into a 32 bit DLL from a 64 bit app or vice versa.
both PCs are Windows 7, 64 bit
both have Delphi Xe2 starter edition which can only handle 32 bits
The app runs fine on my PC, but not on my friend's
Other Delphi apps run just fine on both PCs
Can anyone give me a hint as to how to track this down?
Normally we get the 0xC000007B error-code (which means STATUS_INVALID_IMAGE_FORMAT), if:
If a 32-bit app tried to load a 64-bit DLL.
Or if a 64-bit app tried to load a 32-bit DLL.
Or if a 64-bit app tried to run on a 32-bit Windows.
To really know, I would suggest to test whether there is a problem between your application and its dependencies using dependency walker
Note that all you need to do is open your App using said tool, and issues appear as red log-entries at buttom of screen.
(At least, at time of writting, namely 2022)
Also, make sure you run the correct version of Dependency Walker, for example, the x86 version will display incorrect results when openning x64 binaries.
A load time dependency could not be resolved. The easiest way to debug this is to use Dependency Walker. Use the Profile option to get diagnostics output of the load process. This will identify the point of failure and should guide you to a solution.
The most common cause of this error is trying to load a 64 bit DLL into a 32 bit process, or vice versa.
I tried all the things specified here and found yet another answer. I had to compile my application with 32-bit DLLs. I had built the libraries both in 32-bit and 64-bit but had my PATH set to 64-bit libraries. After I recompiled my application (with a number of changes in my code as well) I got this dreaded error and struggled for two days. Finally, after trying a number of other things, I changed my PATH to have the 32-bit DLLs before the 64-bit DLLs (they have the same names). And it worked. I am just adding it here for completeness.
It is a missing dll.
Possibly, your dll that works with com ports have an unresolved dll dependence.
You can use dependency walker and windows debugger. Check all of the mfc library, for example. Also, you can use nrCommlib - it is great components to work with com ports.
It has been mentioned in earlier answers that using dependency walker is the way to go, in my case (my application keeps failing with the error code), dependency walker showed a few dll that are NOT relevant!
Finally figured out that I can run profiling by going to "profile" menu and it will run the application and stop at the exact dll that's cause the problem! I found out a 32bit dll was picked because of path and fixed it.
I experienced the same problem developing a client-server app using Microsoft Visual Studio 2012.
If you used Visual Studio to develop the app, you must make sure the new (i.e. the computer that the software was not developed on) has the appropriate Microsoft Visual C++ Redistributable Package. By appropriate, you need the right year and bit version (i.e. x86 for 32 bit and x64 for 64 bit) of the Visual C++ Redistributable Package.
The Visual C++ Redistributable Packages install run-time components that are required to run C++ applications built using Visual Studio.
Here is a link to the Visual C++ Redistributable for Visual Studio 2015 .
You can check what versions are installed by going to Control Panel -> Programs -> Programs and Features.
Here's how I got this error and fixed it:
1) I developed a 32 bit application using Visual Studio 2012 on my computer.
Let's call my computer ComputerA.
2) I installed the .exe and the related files on a different computer we'll call ComputerB.
3) On ComputerB, I ran the .exe and got the error message.
4) On ComputerB, I looked at the Programs and Features and didn't see Visual C++ 2012 Redistributable (x64).
5) On ComputerB, I googled for Visual C++ 2012 Redistributable and selected and installed the x64 version.
6) On ComputerB, I ran the .exe on ComputerB and did not receive the error message.
I recently had an issue where I was developing an application (that used a serial port) and it worked on all the machines I tested it on but a few people were getting this error.
It turns out all the machines that the error happened on were running Win7 x64 and had NEVER ONCE been updated.
Running a Windows update fixed all of the machines in my particular case.
Actually this error indicates to an invalid image format. However, why this is happening and what the error code usually means? Actually this could be appear when you are trying to run a program that is made for or intended to work with a 64 bit Windows operating system, but your computer is running on 32 bit Operating system.
Possible Reasons:
Microsoft Visual C++
Need to restart
DirectX
.NET Framework
Need to Re-Install
Need to Run the application as an administrator
Source: http://www.solveinweb.com/solved-the-application-was-unable-to-start-correctly-0xc000007b-click-ok-to-close-the-application/
This may be a case where debugging the debugger might be useful. Essentially if you follow the instructions here you can run two ide's and one will debug into the other. If you un your application in one, you can sometimes catch errors that you otherwise miss. Its worth a try.
I have seen the error trying to run VC++ debug executable on a machine which did not have Visual C++ installed. Building a release version and using that fixed it.
In my case the error occurred when I renamed a DLL after building it (using Visual Studio 2015), so that it fits the name expected by an executable, which depended on the DLL. After the renaming the list of exported symbols displayed by Dependency Walker was empty, and the said error message "The application was unable to start correctly" was displayed.
So it could be fixed by changing the output file name in the Visual Studio linker options.
You can have this if you are trying to manifest your application that it has a dependancy on the Microsoft.Windows.Common-Controls assembly. You do this when you want to load Version 6 of the common controls library - so that visual styles are applied to common controls.
You probably followed Microsoft's original documentation way back from Windows XP days, and added the following to your application's manifest:
<!-- Dependancy on Common Controls version 6 -->
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"/>
</dependentAssembly>
</dependency>
Windows XP is no longer the OS, and you're no longer a 32-bit application. In the intervening 17 years Microsoft updated their documentation; now it's time for you to update your manifest:
<!-- Dependancy on Common Controls version 6 -->
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"/>
</dependentAssembly>
</dependency>
Raymond Chen has a lovely history of the Common Controls:
The history of the Windows XP common controls (archive)
The main problem, of course, is that a DLL file is missing, or, even more likely, corrupt. If this is the case, then I have some pretty good ideas (especially if you've downloaded and installed a DLL manually!)...
TLDR: Delete every manually copy/pasted DLL you've done, uninstall old redistributable installs, and reinstall new redistributables for both 32-bit and 64-bit installs.
What To Do
This solution of copying/pasting missing DLL's into system32, etc., used to work since I can remember in the 1990's, but it doesn't seem to work anymore (2020). So if you run into this problem recently, I suggest:
Within windows\system32 and windows\SysWOW64, delete all files that match ms*.dll, that the operating system will allow you delete as admin.
Uninstall all Visual C++ Redistributables that you have with Windows. This prevents the "You already have this!" dialogue showing up upon reinstall, as detailed in the next step when we re-install.
Reinstall the 2015-2019 Visual C++ Redistributable from a regularly available download site. If this does not work, download and install the others, but personally, the 2015-2019 covered everything for me. Regardless of your machine, install both x32 and x64 packages! (All Download Links: Collected VC++ Download Links; MSVCR120.dll Fix; MFC140U.dll Fix.)
How You Know It's Working
There's a lot of variation in coders experiencing this, so, the idea that there's one single, possible solution is often discarded, but let's be positive!
If deleting the matching ms*.dll files worked, then you will no longer get an error about error code 0xc000007b. Instead, you'll get a message about a missing .dll. This tells you that you're hitting the right code path!
If installing the redistributable works, then certain popular, DLL files should appear in the above-mentioned system32 and SysWO64 folders. For instance: MSVCR120.dll, MSVCR140.dll, MSVCR100.dll, MSVCP100.dll, MSVCP120.dll, MSVCP140.dll, and friends.
Last, Possible Best Chances
Sometimes things don't work according to plan (as we all in the Windows world know). You can also try the following!
Open the "Turn Windows Features on or off" tab in Windows (supported in Windows 8-10). Uncheck the .NET Framework installations. You'll see a small installation go by.
Restart the system. Go to the above feature again, recheck .NET Framework, and click "okay". If this works, you'll see a "installing and updating .NET framework" message that takes maybe a minute or so to go by. Once this is done, I recommend a reboot again.
Good luck!
Just solved this problem for my personal project (thanks to Dries for that). For me it was because the project path was too long. After saving the .sln to a shorter path (C:/MyProjects) and compiling from there it ran without the error.
Also download and unzip "Dependencies" into same folder where you put the wget.exe from
http://gnuwin32.sourceforge.net/packages/wget.htm
You will then have some lib*.dll files as well as wget.exe in the same folder and it should work fine.
(I also answered here https://superuser.com/a/873531/146668 which I originally found.)
I just ran into this issue. I searched for "C++" under my "Apps & Features" in Windows 10 control panel and noticed that some kind of update had just run a few days prior and installed VC++ Redistributable 2012-2017. The app that was running into the error message only required VC++ 2010. I uninstalled all of them and then reinstalled just 2010 x86/x64, and the error went away and the application functioned as expected.
That can happen if for some reason a x86 resource is loaded from a x64 machine. To avoid that explicitly, add this preprocessor directive to stdafx.h (of course, in my example the problematic resource is Windows Common Controls DLL.
#if defined(_WIN64)
#pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df'\"")
#endif
It is possible that you have multiple versions of the dll(s) on your system. You can search your system to find out. The issue may be solved by simply changing the order of the directories in your path. This was my issue. (Cannot run Qt Creator GUI outside of Qt. "The application was unable to start correctly (0xc000007b)" error)
I ran into this issue when fetching code from my repository and compiling on a new machine. Copying over the entire repository and then compiling resulted in an executable which worked. Turns out a 32bit DLL accidentally wasn't checked in. As the people above state, use "Dependency Walker" to figure out where it goes wrong.
To make it more clear what to look for see the below screenshot, with in the background the exe trying to load the wrong DLL (notice the '64') resulting in "the application was unable to start correctly 0xc00007b" and in the foreground the exe which was simply copied over (which included the correct DLL).
I came here when I was searching for: "golang Windows (0xc00007b)"
I have an app written in Golang, which uses iconv. It worked on my machine, but not in someone else's machine.
The first error was the missing DLL: libiconv-2.dll, so I guess they downloaded it on the internet but it was the 32 bit and not 64 bit version, so the 0xc00007b error appeared.
I searched the DLL on my system but I did not have success until I searched on MinGW 64 path which in my case is: C:\msys64\mingw64\bin
The solution was to distribute the DLL with the .exe, which was in the MinGW folder.

Deploy mixed code Visual Studio application

I have a problem running my application on other machines.
I am developing with Visual Studio 2008 in a Win7 x64 machine.
The solution contains several C# projects (the main application is written in C#, all others are library projects) and two c++/CLI libraries. The C++ libraries are Win32 and all C# projects are set to x86 target processor. No third party libraries used. Framework used is v3.5.
The application builds and runs fine on my machine.
I copied the whole "bin\release" folder to a Win7 x86 machine and it ran fine, too.
But when I tried on a XP x86 system, it did not start. No error message, not even showing up shortly in the task manager. The XP system has all updates installed, all available .NET frameworks installed and all Visual Studio Runtimes installed.
I checked with DependencyWalker and the only missing dlls are "IEShim.dll" and "wer.dll" which are only for Vista or higher.
I tried another of my applications that's not using C++ libraries and they work fine. So I guess I am doing something wrong deploying the C++ dlls.
Registering the C++ dlls with "regsvr32" failed with a "DllEntryPoint" not found message. Registering with "regasm" was successful, but had no effect.
What is it that I am missing?
Well, seems like I was a bit hasty stating "no third party components".
Actually it was the SQL Server Compact who was missing its runtime.

Incompatibility between x86 and x64 in Installation solution

I have installation solution that have installer project (not web installer but simple installer) that installs NT services, web service and web sites with help of additional two projects of dlls with my own code that performs my installation step. In user actions of installer project I call installer function of one of those projects, and this project calls to installer of second project: installer -> MiddleCaller -> InstallationCore.
All this developing on Windows 7 and work fine when I compile all in 32 bit.
The project must run on Windows 2008. Because of some reasons all must be in x64 bit.
For this purpose, in MiddleCaller and InstallationCore I click right button of mouse on project -> build -> targer x64. For to move installer project to 64 bit in properties of installer (when project is active) I check: Target platform: x64.
When I run installation on x86 I get error:
The installation package is not supported by this processor type"
And this is good, because now I know that my installation compiled in 64 bit, but when I run this on windows 2008 I get:
Error 1001. Exception occured while initializing the instance:
System.BadImageFormatException: could not load file or Assembly
'MiddleCaller, v...' or one of its dependencies. An attempt was
made to load a program with an incorrect format.
Any one has some idea what I need to do for run fine the installation on x64?
May be I still not moved the installer project to x64 bit, if yes, where I do this?
Thank you for ahead.
Found a quick tip on Microsoft's website that could be useful on troubleshooting setup and deployment projects:
64-bit managed custom actions throw a System.BadImageFormatException exception
If you add a 64-bit managed custom action to a Setup project, the Visual Studio build process embeds a 32-bit version of InstallUtilLib.dll into the MSI as InstallUtil. In turn, the 32-bit .NET Framework is loaded to run the 64-bit managed custom action and causes a BadImageFormatException exception.
For the workaround, replace the 32-bit InstallUtilLib.dll with the 64-bit version.
Open the resulting .msi in Orca from the Windows Installer SDK.
Select the Binary table.
Double click the cell [Binary Data] for the record InstallUtil.
Make sure "Read binary from filename" is selected and click the Browse button.
Browse to %WINDIR%\Microsoft.NET\Framework64\v2.0.50727.
Note
The Framework64 directory is only installed on 64-bit platforms and corresponds to the 64-bit processor type.
Select InstallUtilLib.dll.
Click the Open button.
Click the OK button.
There are some unclear things in this scenario. I understand that you are having difficulty running a 32-bit installer that calls on 64-bit assemblies. If this is correct, then what you are doing is not allowed. You cannot have 32-bit and 64-bit assemblies in the same process - that is illegal. If the 64-bit assemblies are being referenced by the installer directly, then the installer must also be 64-bit.
As clarification: I believe a 32-bit installer can install a 64-bit application, but it may only do so by copying the 64-bit files and not by actually making calls into the 64-bit files. The only way this is supported is if the 64-bit files are loaded into a different process and you use IPC to call into them, but even this is likely to be a bad solution.
In your case, I would encourage you to convert your installer into a 64-bit installer.
So, eventually, I compiled MiddleCaller and InstallationCore in AnyCpu mode, when all dll and executables that I need to install were compiled in x64 bit. All this I compiled on Windows 2008 x64 bit with x64 bit outer dependencies (like Oracle client).

Resources