I have a 3rd-party C++ assembly, which I need to use in my C# project. Hence I wrote a C++/CLI wrapper for the C++ assembly. Everything compiles and runs fine on my development machine.
But when I copy the content of my bin directory to one of our other machines, it crashes. The reason is, that it cannot load my C++/CLI-Wrapper assembly. It gives the typical message: FileNotFoundException: Could not load file or assembly 'MyWrapperAssembly' or one of its dependencies.
So I did some investigations: I made sure, that MyWrapperAssembly could not be found, and added an event handler to the assembly resolve event. Within that handler I loaded MyWrapperAssembly for reflection only. I then loaded all the referenced assemblies. The reflection only loading of MyWrapperAssembly works. So I am sure, that the file could be found. But when I try to load it
Assembly.LoadFrom("hiddenDirectory\MyWrapperAssembly.dll");
It crashes with the above mentioned error FileNotFoundException: Could not load file or assembly 'MyWrapperAssembly' or one of its dependencies.
Since the reflection only load worked, I was certain that there must be something wrong in the C++ layer. I compared the installed versions of the C++ Redistributable on my development machine and on the test machine and noticed, that there are some packages missing. So I downloaded and installed these packages on the test machine:
- Microsoft Visual C++ 2010 Redistributable Package (x86)
- Microsoft Visual C++ 2010 Redistributable Package (x64)
And it did not work. Then I tested 6 different PCs. My programm runs on 3 PCs and crashes on the other 3. The only thing that differentiates the PCs is the Microsoft Visual C++ 2010 Runtime. When it is installed, it seems to work.
But I can't find an installer for that package in the internet. So I installed Visual Studio 2013 on one PC where my programm crashed. After I installed Visual Studio (and with that the C++ Runtime), my program runs.
So I assume that I need that C++ runtime. It is no option to require Visual Studio on our customers PC. So I need to deploy the C++ runtime. But the question is:
Where do I get the Visual C++ Runtime from?
Or does anybody know if I am missing another thing?
If you're using Visual Studio 2013, you need the 2013 runtime, not the 2010 runtime.
Visual C++ Redistributable Packages for Visual Studio 2013