I am deploying a desktop application to my clients that uses the Crystal Reports API to display and print forms. I am building my installer using InstallShield 2012. I have also included the .NET 4.0 Framework along with all of the Crystal assemblies. I have 2 (kinda related) concerns:
1) Whenever I tried to run the application on the client machine, I get the following error:
The type initializer for 'CrystalDecisions.CrystalReports.Engine.ReportDocument'
threw an exception.
I have no idea what I am forgetting here. The CrystalDecisions.CrystalReports.Engine
dll is being registered in the GAC correctly, as are about 10 other Crystal assemblies.
2) I have asked this question on the SAP forums, and I was told I needed to include the .NET 2.0 Framework along with the .NET 4.0 Framework. I tried including the .NET 2.0 redistributable in my installer package, but the installer does not install it. Does the installer see that I have 4.0 installed, so it skips the 2.0 installation?
When a static constructor throws an exception, it is wrapped inside a TypeInitializationException
. You need to check the exception object's InnerException
property to see the actual exception.
In a staging / production environment (where you don't have Visual Studio installed), you'll need to either:
AppDomain.UnhandledException
event, and put your logging/tracing code there. Use System.Diagnostics.Debug.WriteLine
for tracing, or a logger (log4net, ETW). DbgView (a Sysinternals tool) can be used to view the Debug.WriteLine trace.
Thanks, this put me on the right path. I have implemented my own exception logging, but I wasnt logging the InnerExceptions correctly.
Hey! man, this is because of lack of Capability .... If you see the Inner Exception you will see this message "Access is denied. Access to speech functionality requires ID_CAP_SPEECH_RECOGNITION to be defined in the manifest." So to get rid of this exception. turn on the capability for Speech Recognition as mentioned.