0
votes

I know this question has been answered many times but I have tried all previous suggested resolution.

1.) The target CPU is x86

2.) I have registered the ocx and dll files

The application is working fine on old machines (all OS) but not on new images.

Here is the log :

Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.Runtime.InteropServices.COMException at System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance(System.Guid ByRef, System.Object, Int32, System.Guid ByRef) at System.Windows.Forms.AxHost.CreateWithLicense(System.String, System.Guid) at System.Windows.Forms.AxHost.CreateInstanceCore(System.Guid) at System.Windows.Forms.AxHost.CreateInstance() at System.Windows.Forms.AxHost.GetOcxCreate() at System.Windows.Forms.AxHost.TransitionUpTo(Int32) at System.Windows.Forms.AxHost.CreateHandle() at System.Windows.Forms.Control.CreateControl(Boolean) at System.Windows.Forms.Control.CreateControl(Boolean) at System.Windows.Forms.AxHost.EndInit() at Restaurant.frmMain.InitializeComponent() at Restaurant.frmMain..ctor()

Exception Info: System.InvalidOperationException at Restaurant.My.MyProject+MyForms.Create__Instance__[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089] at Restaurant.frmMain.Main()

Here is how I am registering the files :

C:\Windows\Microsoft.NET\Framework\v2.0.50727\Caspol -q -machine -addgroup 1 -url file://C:/xyz/* FullTrust -name "V Drive"

regsvr32 c:\xyz\crystl32.ocx

regsvr32 c:\xyz\MSCOMCT2.OCX

regsvr32 c:\xyz\MSDATGRD.OCX

regsvr32 c:\xyz\cpeaut32.dll

regsvr32 c:\xyz\msstdfmt.dll

Crystal reports runtime engine for .NET 4 framework in installed on the system (both x86 and x64).

1

1 Answers

0
votes

I had this issue once.

I ran Visual Studio as administrator. Also make sure you know which setting your platform is for the build: AnyCPU, x86, x64

For you its x86 so try using AnyCPU!

Try debugging the issue I read an article from Microsoft which said you can debug where this exception is occurring by:

Debug > Exceptions... and use the Find option to locate System.Runtime.InteropServices.COMException. Tick the option to break when it's thrown and then debug your application.