PDA

Click to See Complete Forum and Search --> : [Exception] Class not registered


usamaalam
Sep 29th, 2005, 08:22 AM
Hello everybody,

I am getting following exception while opening a form in a separate thread.


An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in system.windows.forms.dll

Additional information: Class not registered


Exception throws on following line in InitializeComponent() method.


this.Load += new System.EventHandler(this.frm_DesingTemplate_Load);
((System.ComponentModel.ISupportInitialize)(this.axDrawingControl1)).EndInit();


Here is the code for sending methods on thread.


private void PrintAndDraw(bool IsDrawDrawing,bool IsPrintReport)
{
try
{
if(IsPrintReport)
{
ThreadStart reportThreadStart = new ThreadStart(PrintWorkOrder);
Thread reportThread = new Thread(reportThreadStart);
reportThread.Start();
}

if(IsDrawDrawing)
{
ThreadStart drawingThreadStart = new ThreadStart(DrawDrawing);
Thread drawingThread = new Thread(drawingThreadStart);
drawingThread.Start();
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}



Here is the method under which exception is thrown.

private void DrawDrawing()
{
long ComplaintCode = Convert.ToInt64(this.clsComplaintCode);
int ModelCode = Convert.ToInt32(this.cboMCModel.SelectedValue);
int ManufacturerCode = Convert.ToInt32(this.cboMCManufacturer.SelectedValue);
string strWOrder = txtMCWorkOrder.Text;

frm_DesingTemplate frmComp = new frm_DesingTemplate(ComplaintCode , ModelCode, ManufacturerCode, strWOrder);
frmComp.Show();
}



Exception is thrown in the InitializeComponent() of frm_DesingTemplate form. A visio drawing control has been used on this form.

Any ideas to resolve this issue ??

Thanks.

jmcilhinney
Sep 29th, 2005, 06:32 PM
It looks like you are trying to use an unregistered ActiveX control. I've never worked in COM specifically and only a little through .NET but I believe that COM classes need to be registered on the machine to be able to be used. I think you can have that done automatically as part of your installation routine. Have you picked up that I'm not 100% sure about this? :)

usamaalam
Sep 29th, 2005, 11:36 PM
Yes, it might be possible. But if I do not send methods on thread, application works fine. Moreover, I have tried this code on a machine where Visio is installed but the problem is same.

penagate
Sep 29th, 2005, 11:36 PM
1) Does it work in your main thread?

2) Yes you need to register COM libraries. You can do this either by using the unmanaged GetProcAddress() API to call the library's DllRegisterServer() export, or by using the regsvr32.exe tool and passing the path name of the library.

usamaalam
Sep 30th, 2005, 12:48 AM
If I do not use threading and call the two methods sequentially then code works for me.

Moreover, I tried to register all the DLLs present in my Debug folder with regsvr32 command. It says "Path of Dll\Interop.Visio.Dll was loaded, but the DllRegisterServer entry point was not found. This file cannot be registered."

Thanks.

penagate
Oct 1st, 2005, 02:14 AM
Well in that case it's not a COM library. I don't think I can help you then, sorry :(