we have created a c# application which calls a c++ dll(sdbm.dll). It is working properly in most of the PCs except some PCs. The dll is created using VC++ 2008 and application is done in VC# 2005. Following are the errors occured when the dll functions are called from the C# application.
Error occured in one PC is as follows
=====================================
Unable to load sdbm.dll :This application has failed to start because the application configuration is incorrect.Reinstalling the application may fix this problem (Exception from HRESULT :0x800736B1)
Error occured in 2nd PC
=====================================
Error Signature
Appname:app.exe Appver:1.0.0.0 Modname:msvcr90.dll Modver:9.0.30729.4148 Offset:0002fc96
Any help would be appreciated
As the others already stated in their comment it seems to be a problem with the dependencies of your sdbm.dll. The simplest way to find out the root cause you should get a copy of DependencyWalker and throw your sdbm.dll into it. First on a machine where it runs without any problems and afterwards start DependencyWalker on one of the problematic machines to see it's output.
It gives you some informations about what DLLs it couldn't found on the current machine. Thous leading you to the problematic libraries.
Nearly always the problem is a missing Visual C++ Redistributable Package (2005, 2008, 2010) or that your library is compiled and deployed as debug version. In this case it will link to the debug versions of e.g. mfcxx.dll by using the mfcxxd.dll. But these debug versions are only installed with the corresponding SDK (or Visual Studio) and not with the redistribution package. Thus leading to problem on the user machine but not no a developer machine.
Related
I have created a C# add-in in VS2015 to import and synchronise data models from Power Designer into Enterprise Architect. It has dependencies for PDPDM, PDLDM, PDCDM, and Interop.EA.
The problem is that it crashes when I deploy and then run it on a Windows 7 Machine.
To install the add-in I do the following:
Register the add-in dll in the COM codebase entries in the registry using regasm.exe
By opening up a command prompt in folder where you copied the add-in dll and register the dll with the /codebase option. In my case that command would be: %WINDIR%\Microsoft.NET\Framework\v4.0.30319
.\RegAsm.exe -tlb -codebase
Add the registry key: Add a key to HKEY_CURRENT_USER\Software\Sparx Systems\EAAddins in the form of [ProjectName].[ClassName]
This installation works fine on both the development and deployed machines and I am able to run the add-in.
The add-in works completely fine when installed on the development machine.
However on the deployed Windows 7 machine it crashes in one specific case:
When running an import for a physical data model the add-in starts working (starts to extract Power Designer information) and then crashes unexpectedly with only the message that it Enterprise Architect has "stopped working". In the event log the information points to the .NET clr.
This is unexpected as the add-in was registered with the same version of .NET in both cases.
I have investigated source code and compared it to a working dll made using the same libraries and found no differences. I am sure it is to do with the deployment environment on the Windows 7 machine.
Any ideas on why the add-in might be crashing on the Windows 7 machine?
And any suggested fixes?
UPDATE: I have tried narrowing down and commenting out aspects of the code to make it work on the Windows 7 machine. No matter what I comment out as it starts reading any part of the Physical Model from power designer it crashes, this is not the case for all other data models (logical and conceptual).
Given the way it is behaving I am looking further into the environment and deployment.
Any help is still much appreciated...
UPDATE 2: Thank you for the help from everyone. I have used the advice and was able to eventually track down the error:
The process was terminated due to an internal error in the .NET Runtime at IP... with exit code 80131506.
I am pursuing this error code and errors with the environment/garbage collector
The problem was as Geert suspected, with Power Designer. The Power Designer type libraries used were different between machines with one patch to Power Designer upgrading the PdPDM type library to a new version. This changed the way Physical Data Models interacted with the add-in when using the PdPDM type library.
It may be helpful to note that creating and using a dump file when an enterprise architect add-in crashes was very helpful and pointed me to lines of code that could isolate the problem.
I have developed a desktop application in c# & SQL server 2012 using Visual Studio 2013. I have included the reference for Microsoft.VisualStudio.DebuggerVisualizers and set copy local : true.
The application runs perfectly on client systems with windows 8, 10.
But its showing this error while installing on a windows 7 system.
- OS Windows 7 Ultimate
- already installed .NET Framework 4.5
- installed Report Viewer.exe 2012
- installed report viewer.msi 2010
- installed sqlclr types
- the system doesnt have any microsoft c++ redistributable , i am not sure whether it has any impact.
I checked in the assembly folder, but couldnt find the Microsoft.VisualStudio.DebuggerVisualizers.dll
Am I missing any prerequisites here? How to solve this issue so that i can install the application
Error Message
It needs the Microsoft.VisualStudio.DebuggerVisualizers.dll in the global assembly cache. The GAC is the area where libs are placed which can be accessed from all of the system.
It's kinda a ugly fix but you could place this lib in the same or subdirectory of the same directory where the application is.
Is it possibly that you haven't installed VS on that Win7 machine but on the others?
Unintentionally the Microsoft.VisualStudio.DebuggerVisualizers.dll had been included in the project reference. And in the client system the specified dll could not be found even after trying to install it. Hence I removed it from reference and then it worked perfectly fine without any issues. I guess instead of report visualizer i have included debuggervisualizer. It was a manual error.
Thank you for your support
I have an InvalidProgram exception with the message
Common Language Runtime Detected an Invalid Program
This happen in an application that we didn't change in the last 3 month.
The only change is that we have change our build server (reinstall it).
The server is running Windows 8 and has Windows SDK 7.1 on it.
We package the application with ClickOnce.
This exception happen in a very specific method call, after methods of the same class as assembly are already called, so I think it rules out assembly loading issues.
I can't find a lead to where to start debug this issue. I think it related to the version of the tools I use on the build server such as MSBuild, CSC, mage.exe and such.
I found people say this error might happen when I have very long method names, but this does not seem to apply here because I don't have long methods names and I don't generate code myself.
The application use .NET 4.0
Update 1
It is for sure a problem with the compile tools (the version I think) or the ClickOnce packaging tools because when I compile and run the application on my machine it work, when I install the packaged application on my machine it show the exception above.
add this argument to your compiler: /nowin32manifest
I wrote with VS10 the following projects:
a C# (.net 4.0) program which calls
a C++ unmanaged dll, which make use of boost::thread
a setup project which includes the C# executable, the C++ dll, the boost::thread dll and some other files. Moreover during the installation there is a check if the framework .net 4.0 is installed, and if not it will be downloaded.
The compilation (x64 for each of the three projects) is ok, and the program works on my pc (Windows 7 64bit).
I tested the program on some other computers (all Windows 7 64bit) and I noted that:
in the ones with VS10 and Boost the program works
in the ones without VS10 and Boost the program gives an error in the C++ Dll
I think the problem is that some boost Dll is missing. Am I right?
Or the problem could be related to VS?
edit:
I have to mention that the structure of the program is the following:
main form (C#) in which some parameters are set, then a backgroudworker calls
the C++ DLL which do its stuff and uses boost::thread
it does some computations
when it get some results, writes them on file
continue with its computations and so on
the main form has a filesystemwatcher which looks for the results file and do some stuff with the results.
Also, when I get the error, the main form correctly loads and the parameters could be set. The error happens when the backgroundworker starts his work (calling the C++ DLL).
So I'm quite sure that there is no problem with the framework installation.
Update:
It turns out that I forgot to include some DLLs in the setup project. Now, including them the error changed.
Now, at the same point as before (and on the same computers) I get another error:
BadImageFormatException: An attempt was made to load a program with an
incorrect format
I read this article, but I have set x64 in both C# project and in C++ DLL and the setup project has as TargetPlatform x64. Any idea?
VCRedist package is missing on target machine. It should be available in VS SDK directory. Also you may need to install .Net Framework on target machine (.Net Framework contains VCRedist package). If you don't have instalation files for those, they are available on microsoft sites i.e. VC10Redist for x64 is here
In such cases I use the tool Dependency Walker
Launch it and select your executable to discover the missing libraries.
It gives clues indicating what is needed to install then.
If your C++ DLL is dynamically linked to the CRT, then you have to deploy also the VC++ CRT DLL's, i.e. MSVCR100.DLL and C++'s MSVCP100.DLL on the target machine (they are already available on your dev machine, where you have VS2010 installed, so on that machine your C++ DLL loads fine; but you can't assume that on your client's machine the CRT/C++ DLL's are available).
There are several deployment options: you may want to read this documentation on MSDN.
I finally found the solution!
The C++ DLL needs the mpfr library for multiple precision floating point computations with correct rounding.
I was including (shame on me!) the incorrect version of the library (x86) and this was the motivation for the error:
BadImageFormatException: An attempt was made to load a program with an incorrect format
Then in all the computers (three different computers!) in which the program was ok there were both (unlucky and misleading coincidence):
Boost and VS10 installed and
a x64 version of the library in a folder contained in the Path environment variable.
So, in some way the program found the right version of the DLL.
Including the right version of the library in the Setup Project fixed the problem.
Thanks to Kamil Klimek, Stephane Rolland and Mr.C64 for their precious suggestions.
We've a WPF application written in .NET 3.5 using Visual Studio 2010. The solution consists of 8 projects - all compiled in .NET 3.5. The application uses Crystal Report. Target OS is Windows 7.
Recently, the startup project is compiled in .NET 4.0 due to some 3rd party DLL dependency - those DLLs require .NET 4.0. After this change and rebuilding the solution, Crystal Report is throwing exception.
The problem occurs at the constructor of ReportClass.
Exception's message:
The type initializer for
'CrystalDecisions.CrystalReports.Engine.ReportDocument' threw an
exception.
InnerException's message:
"Retrieving the COM class factory for component with CLSID
{4DB2E2BB-78E6-4AEA-BEFB-FDAAB610FD1B} failed due to the following
error: 80040154 Class not registered (Exception from HRESULT:
0x80040154 (REGDB_E_CLASSNOTREG))."
I haven't worked in Crystal Report before. What could be the cause of this problem?
Please note that this problem doesn't occur when compiled as .NET 3.5. Crystal Report is used in the startup project.
It is likely to be X86/x64 problem.
try to compile your app to target 86 platform.
This issue got me for 2 days and its all over the place with very similar answers, however what it ended up being for me was two-fold. I am adding here in hopes it saves someone at least a day..
A lot of post mention this;
Go to IIS -> application pools -> click right button on your application pools -> go to advance setting -> Enable 32 bit application = True
Please note that in my case I was building and deploying on a 64bit machine so I set the True to False and it did it. Again, simple enough but not something I thought was related so my mind was blank to it after I made the adjustment.
The other point of interest is to make sure that you do have the CRRuntime_xx.x.x.MSI loaded on Deployment server.
Thank you everyone here for the amazing info at the end of the day it got me through.
Go to IIS -> application pools ->click right button on your application pools -> go to advance setting -> Enable 32 bit application = True
When you install CR it should install few files (JS,html etc etc) on C:\inetpub\wwwroot\aspnet_client\system_web\4_0_30319\crystalreportviewers13. Check if this folder exists on your pc. If not, I think you need to copy the folder from program files to this location.
These answers got us to the right place but not until we did some troubleshooting. It did end up being a 32/64 bit issue on our local dev machines running Visual Studio 2019 and IIS Express.
In our case the issue was that the setting for "Use the 64 bit version of IIS Express for web sites and projects" had been enabled in visual studio settings. We use the 32 bit version of crystal on our dev machines so we had to Uncheck this box for it to work correctly.