views:

62

answers:

1

Hello all.

I meet one strange issue.

Public Class MyClass
{
    Public MyClass()
    {          
        // Some time the New Com Obj code will crush in Construcor 

        su.SUEvent += new _IaSystemMgrEvents_SuEventEventHandler(su_SuEvent);
        su.SUEventSteps += new _IaSystemMgrEvents_SuEventIemsEventHandler(su_SuEventSteps);
        su.SetHBCOMAddr();}

    public void Init()
    {   
        // If i inserted the three lines code to Init() fun, it worked very well.

        su.SUEvent += new _IaSystemMgrEvents_SuEventEventHandler(su_SuEvent);
        su.SUEventSteps += new _IaSystemMgrEvents_SuEventIemsEventHandler>(su_SuEventSteps);
        su.SetHBCOMAddr();
    }
}

su is a lib file from C++ Why i can't creat Com Obj in constructor in C#.

+1  A: 

What's the crash (crush) that you are seeing?

Is this happening with all COM objects and is this a publicly available COM object we could try out? My guess is that something is not setup fully when you are trying to run that code in the constructor. What code is calling your Init() method?

BrianLy