COM in .NET

  • Thread starter Thread starter Michal
  • Start date Start date
M

Michal

Hi.

I've got a big problem :(... I wrote COM dll in c# for an application. This
application works fine with this dll until i'll close that application. Then
the error occurs:

..NET-BroadcastEventWindow.1.5000.0

The instruction at "0x04489f05" referenced memory at "0x00000030". The
memory could not be "read". Click on OK to terminate the program.


Can anybody help me ?

I'll be appreciative for any suggestions.
 
Michael,

Without seeing the code for your COM object and the code that is calling
it (how it is used), it's (very) difficult to tell. Can you show the code?
 
It's OK now, I figured it out :) Before I close my application, I run
GC.Collect() - garbage collector runs, cleans and the error doesn't apear :)

Greets

Michal


Nicholas Paldino said:
Michael,

Without seeing the code for your COM object and the code that is calling
it (how it is used), it's (very) difficult to tell. Can you show the
code?
 
Michael,

That seems like only a stop-gap measure for code that didn't properly
clean itself up. Are you sure you are releasing all resources properly?
 
Did you release the COM object with Marshal.ReleaseCOMObject when you were finished with it in your code? This is the equivelent of doing IUnknown::Release in .NET terms and will hopefully get the runtime callable wrapper to release the underlying COM object at that point rather than waiting for a GC to occur.

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<[email protected]>

It's OK now, I figured it out :) Before I close my application, I run
GC.Collect() - garbage collector runs, cleans and the error doesn't apear :)

Greets

Michal
 
I've encountered this when using COM and multiple threads. You have
to change [STAThread] to [MTAThread] on your Main() function.
 
Back
Top