[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.interop

late binding COM process startup problem - COM exception 80080005

tb2000

9/21/2007 3:00:00 PM

I ran into this problem when trying to late bind a COM based application. (I
have an API description but no TLB to generate an RCW), so I had to remodel
the interfaces.
The COM Server resides as LocalServer (EXE). My app is a .NET console app.

I am using the Activator.CreateInstance(Type).

Now, if the COM code is running (before I start my c# based app) I can
access the object, all well. It appreas the managed code is actually loading
the COM server, I can see the process appearing.
Now (a quick hack) I wrote a workaround, checking if I already have that
process and (if not) I do a Process.Start(filepath) preload with a subsequent
Activator.CreateInstance().

Amazingly I get the same COM exception if I do this "undelayed". If I wait
until the process is alive all is ok.

I found several similar error quests searching around, many from the ASP
worlds, but no solution (yet). Maybe some people can benefit from a fixe,
even if my quick hack works for me and now...

Here's the code:

Thanx ahead!
tb

try
{ //Check for executable and start if process is not running
if (progID.ProcessName.Length > 0)
{
Process[] p =
Process.GetProcessesByName(progID.ProcessName);
if (p.Length == 0)
{
Process.Start(progID.COMpath);
int n = 10;
while (p.Length == 0 && --n > 0)
{
p =
Process.GetProcessesByName(progID.ProcessName);
System.Threading.Thread.Sleep(500);
}
}
}
}
catch (Exception e)
{
Debug.WriteLine(e.Message);
}

try
{
comObject = Activator.CreateInstance(comType);
}