Problem with System.Runtime.Serialization.SerializationException - c++

I am having a few troubles with a set of hosted code on an WS2K8 R2 box with IIS 7. I have another server running WS2008 that does not encounter the same issue. I have copied the application code from the old server so that it is identical.
The exception thrown in my server side logs is:
"ModuleLoadException: The C++ module failed to load while attempting to initialize the default appdomain."
I also have an error being returned in VS2010 at the same time:
Unable to find assembly 'msvcm80, Version=8.0.50727.4927, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
I have checked and the correct version of msvcm80 is on the server in the "C:\Windows\winsxs" folder. I have also installed Microsoft Visual C++ 2005 Redistributable (x64) and (x86).
I cannot see why the error might be thrown??
My debugging expierence is low so please bear with me.

I re-checked the version details. It appears that it was a requirement of the Microsoft Visual C++ 2005 Redistributible. I re-installed all versions of it on the server and applied the security hotfixes.
After a re-boot and testing in IIS the issue has now gone from my log files.
I did check the comparison between the two servers and wasnt that happy copying the files over. I felt it was best to try this method first.
Thanks for your help.

msvcm80 is a .NET Framework mixed assembly (microsoft visual c++ managed + unmanaged). You might try to find this file on the second server and place near your application on the first server machine.
Note: .Net Framework Runtime requires exact version of an assembly (8.0.50727.4927 in your case).

Related

Bad image format when running managed C++/CLI assembly in .NET Core 3.1

I was super excited to see that the latest previews of .NET Core 3.1 and Visual Studio 2019 add support for managed C++/CLI projects, as such a project is the only think keeping a particular project on .NET Framework.
So, I installed Visual Studio Preview 16.4.0 Preview 4, along with the "C++/CLI support for v142..." options, and as expected I see the new C++ CLR templates and have .NET Core 3.1 preview 2 installed
I created a new project using the "CLR Class Library (.NET Core)" template, copied the files an old managed C++/CLI project, tweaked a little, and the assembly built - great!
However, when I try to use the assembly in a .NET Core 3.1, I get this fatal exception:
Unhandled exception. System.BadImageFormatException: Could not load file or assembly 'MyAssembly, Version=2019.0.1.0, Culture=neutral, PublicKeyToken=null'. An attempt was made to load a program with an incorrect format.
File name: 'MyAssembly, Version=2019.0.1.0, Culture=neutral, PublicKeyToken=null'
at TestApp.Program.Main(String[] args)
Both the managed assembly and test app target X64. Any ideas what could be the problem?
Someone from Microsoft provided the solution over on the Github repo.
When the managed C++/CLI project is built, a file ijwhost.dll is placed in the output folder alongside the assembly - this file needs to be deployed with the app that uses the assembly.
After putting ijwhost.dll in the same folder as the app, it worked as expected.
As an aside, the old C++/CLI project that I built against .NET Core 3.1 preview is actually quite complex - I'm very pleasantly surprised that it basically "just worked"!
Hopefully a better error message will be used in future!
I am using .net 5.0 as the CLI runtime. I finally found that the problem I have is missing native dependency DLLs.
For native applications, there will be an error prompt telling you which DLL is missing. While in .net core C++/CLI, they only give you a BadImageFormatException.
My solution is, create a pure native console project, paste the code that will cause BadImageFormatException, run it and see which DLL is missing then add it back to C++/CLI project file list.
I just found some unexpected dependencies.
In my case c# Net 5.0 app loads managed C++ dll, which is wrapping around unmanaged C++ dll.I get this error every time i try to run on on machine with no Visual Studio installed. I debugged it with ProcessMonitor and figure out that it can't found VCRUNTIME140D.dll. Found these dlls in my dev PC, copied them (both 32 and 64 bit versions) from my dev machine to customer's one to corresponded folders, and it made the trick. Hope will help somebody. Cheers.

Using c++ dll in asp.net - Exception:Could not load file or assembly

I am using a already developed C++ dll in my asp.net code to make compression/decompression of the data. It works well on my developer machine and some other machines too. I have a client machine which is fresh(No fancy installation of various tools) and When it tries to call that dll it generates an exception.
Exception:Could not load file or assembly 'dllcode, Version=1.0.5754.25819, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
I would like to know that which dependencies are missing on Client fresh machine?
Note: I am trying to call C++ dll in a windows service which is having asp.net 4.0 framework. This call is executing perfectly on my developer machine but generates above exception on my client machine.I do not have deep knowledge about c++ library and it's dll. From basic troubleshooting I tried to install various combinations of "microsoft visual c++ 2010 runtime" but it did not help.
Update: Somehow I find source code of this C++ dll and now I am trying to check if I can build this dll any version specific.
I got this resolved. What I did is, I had to create separate setups(32-Bit & 64-Bit). Also VC++ run time was needed on server. So I installed them and it worked.
Hope this help to any one if he faces the same issue.

Air Native Extensions: Released Air App w/Windows Native Extension works fine on develpment PC but not on other computers

I'm working on an AIR app that uses a Native Extension for windows that I developed for the same project. The app calls an ANE method called pingFunction and passes it a String containing the IP address where the pingFunction will perform, believe it or not, a ping test.
The application and it's ANE work great on Flash Builder and even after making it a release, they keep working like a charm on the development PC. The problem is that I've tried on two other computers and the application is throwing the following error:
ArgumentError: Error #3500: The extension context does not have a method with the name pingFunction.
at flash.external::ExtensionContext/_call()
at flash.external::ExtensionContext/call()
at com.mycompanyname.myappname::MyAppName/sendPing()[...
At the beggining I thought I had to do with the fact that I was using a DLL I compiled using the Debug configuration on Visual Studio instead of the Release configuration, because I read that sometimes the a debug-version of a DLL can use external DLLs. So, I changed it and rebuilt the whole library as a release build. Sadly for me, I'm still experiencing the same result.
Also, I tried changing the swf-version of both the AIR app and the ANE to the AIR SDK version I'm using (14.0), and got again the same error.
The development computer is running Windows 8.1 and the others, where the app is not working, Windows 7 and Windows 7 Service Pack 1.
Any ideas about why this is happening? Any questions or comments that might lead me to the right track will be deeply appreciated.
Error#3500 is coming because you don't have the required runtime installed on those machines, which is necessary to execute any c++ code .
On your development machine you have visual studio installed and hence you also have msvcr.
Solution of the problem is:
Install msvcr i.e. Microsoft Visual c++ redistribution - 2012 from here.
you need msvcr anywhere you want to run any VS compiled c++ code.

VC C++ 2008 redistributable error

Okay so I have read a few responses about this topic and can't seem to find someone having the same issue.
Why installing vcredist_x86.exe doesn't fix SideBySide error when I develop an EXE on one machine and run it on another one?
http://www.codeproject.com/Articles/43681/Side-by-Side-Configuration-Incorrect
background: I work on Fortran code that use a few c++ libs that I don't have access to the code of. These were apparently built using VS2008, and this error has only started to occur since my machine had to be rebooted and I asked IT not to install VS2008 in addition to VS2012. I know that installing VS2008 will fix the problem, but that is not a good soultion.
The error is: unable to start program 'C:\blah\blah\blah.exe'. This application has failed to start because the application configuration is incorrect. Review the manifest file for possible errors. Reinstalling the application may fix this problem. For more details, please see the application event log. The application event log tells me the same things listed in the first link posted.
Originally I was getting the problem so I looked up these articles and I went and installed the correct version of the VC C++ redist package (it is version 9.0.21022.8 for x86 source:the manifest file for the project). I originally installed the 64 bit, quickly determined I needed the 32 bit version and then installed that one.
I have the folders and files within for
C:\Windows\winsxs\x86_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.21022.8_none_b59bae9d65014b98
C:\Windows\winsxs\x86_microsoft.vc90.mfcloc_1fc8b3b9a1e18e3b_9.0.21022.8_none_b59bae9d65014b98
C:\Windows\winsxs\x86_microsoft.vc90.atl_1fc8b3b9a1e18e3b_9.0.21022.8_none_b59bae9d65014b98
The related manifest files also seem to be there.
The program still doesn't run even though the files are there. What am I missing?

visual studio 2010: error code -2146232576 (0x80131700)

I have to convert a C++ project from visual studio 2008 running on Windows XP to 2010 running on Seven. Compilation seems to run perfectly but during the debugging I have an error: "The program 'App.exe : Native' has exited with code -2146232576 (0x80131700)."
After a few researches on the internet I found out that the issue is in relation with .NET.
I tried to update my windows with hidden updates, check what the .NET version target is 4 and a few more things that doesn't work...
Has anyone ever encountered this issue ?
Thanks a lot.
EDIT: it is a managed C++ project
It is a low-level .NET initialization error, the CLR cannot get loaded. That's pretty hard to explain since you can run VS2010 without a problem and it already uses .NET version 4. The only decent guess is that you are actually using a C++ project (not a C++/CLI one) and that it loads the CLR itself. And asks for and old version, like 1.1, one that isn't installed on the machine. Search the code for "CorBindToRuntime".
Have you installed all Windows updates lately? If not, do so - seems to be some general .NET related error - see:
http://social.msdn.microsoft.com/Forums/ta/wlgeneraldev/thread/8f9d610f-92b2-4262-8e1a-88cee8428aed
You are running native code I presume? Are you?
If that is a case this error is caused by something else.
If you are using managed C++ than you have a problem related to the .Net framework.
Remember that some error numbers returned may (and they do) indicate different causes, depending who return an error.
Giving more information about what is your application doing and what language it is written would definitely help isolation problem.