What kind of client are you talking about? Please post a simple client
that
illustrates the issue.
If the COM out-proc server ends it's because it stops running for a reason
known by the server not because of the client.
What happens if you create an instance of say Excel or Word from the same
client?
Willy.
|I have been calling the application in VB6 suing CreateObject(). It
always
| works as expected.
|
| I do not explicitly set the thread. Is that something I should do? I
just
| attempt to write a C# class that invokes that COM server.
|
| It seems that the reference to the COM server is lost when
CreateInstnace
| returns. Just do not know what has caused that.
|
| Thanks.
| jwang
|
|
|
|
|
| | > Is it possible that the managed object is being garbage collected and
| > releasing references? Then the COM server just goes away.
| > --
| > Phil Wilson
| > [Microsoft MVP-Windows Installer]
| > "Nicholas Paldino [.NET/C# MVP]" <
[email protected]>
wrote
| > in message | >> jwang,
| >>
| >> This does not indicate an issue with .NET, but rather, the COM
server
| >> (which is out of process) is being shut down.
| >>
| >> If you try and create the object through say, vb script, do you
get
| >> the same result?
| >>
| >> Also, what do you have the ApartmentState set to on your thread?
| >>
| >>
| >> --
| >> - Nicholas Paldino [.NET/C# MVP]
| >> - (e-mail address removed)
| >>
| >> | >>> Nicholas,
| >>> Thanks for responding to my question.
| >>>
| >>> CreateInstance does not throw an exception, and it returns a
| >>> System._ComObject. The COM component I try to invoke is a
| >>> out-of-process component. From the Task Manager, I can see it was
| >>> created and then went away. (I used the same method on
| >>> Excel.Application, it works fine.)
| >>>
| >>> Also, I try with ComImport to explicitly import the type, and then
use
| >>> new to instantiate the component, but get the same problem.
| >>>
| >>> jwang
| >>>
| >>>
| >>> "Nicholas Paldino [.NET/C# MVP]" <
[email protected]>
wrote
| >>> in message | >>>> jwang,
| >>>>
| >>>> Either CreateInstance should throw, or return a value. What is
the
| >>>> exception that is being thrown? I doubt it is
NullReferenceException.
| >>>>
| >>>>
| >>>> --
| >>>> - Nicholas Paldino [.NET/C# MVP]
| >>>> - (e-mail address removed)
| >>>>
| >>>> | >>>>>I am trying to instantiate a COM component in C# via late binding.
The
| >>>>>component appears to be launched, then it automatically gets
unloaded.
| >>>>>That is, the instance is unloaded after the CreateInstance returns.
| >>>>>
| >>>>> Any idea of what could be the problem? Thanks a lot.
| >>>>>
| >>>>> Here is the code segment I am using:
| >>>>>
| >>>>> Object target;
| >>>>>
| >>>>> Type oType = Type.GetTypeFromProgID("my.application", true);
| >>>>> if (oType != null)
| >>>>>
| >>>>> {
| >>>>>
| >>>>> target = Activator.CreateInstance(oType);
| >>>>>
| >>>>> if (target != null)
| >>>>>
| >>>>> {
| >>>>>
| >>>>> success = true;
| >>>>>
| >>>>> }
| >>>>>
| >>>>> }
| >>>>>
| >>>>>
| >>>>
| >>>>
| >>>
| >>>
| >>
| >>
| >
| >
|
|