Luis -
Are you setting the apartment model of the active thread in your C# code?
--
Klaus H. Probst, MVP
http://www.vbbox.com/
I wish I can explain my problem!, I'm trying to resolve a conflict problem
with an application that I create to integrate an old C application with
..NET:
Old C App --> C++.NET IJW Bridge --> C#
It's a "message" type communication integration, where I pass some
parameters from the Old C App to the C# using a C++.NET as a bridge for
interoperability. The C# process the information and sends back a
response.
On my Old C App, I'm receiving the following error message:
OleInitialize failed, rtnval=RPC_E_CHANGED_MODE. A previous call to
CoInitializeEx specified the concurrency model for this apartment as
multithreaded apartment (MTA).
This is happening under very specific circunstances, and I was able to
track
down the problem to an specific line of code in my C# class, which is:
ServiceController[] services = ServiceController.GetServices();
The main problem I have is that I'm a C# developer with a little
background
of C/C++ and threading, looking at the explanation of the error I'm
getting,
looks to me, that some how, the ServiceController is changing the
Apartment
Model of the thread that is running, what is interesting to me, is that
the
error is being reported by the Old C App which makes me believe that all
the
communication between the Old C App -> C++.NET -> C# is running under the
same thread, and that, some how, the ServiceController is changing the
Apartment Model to something different (MTA).
I know that I'm not explaining myself in a way to expect any help, but if
you or somebody have an idea I'll really appreciate it.
Thanks in advance
:
The service APIs were never COM-based. In any case, most of .NET is a
managed wrapper around some unmanaged API or COM interface.
Why is this important?
--
Klaus H. Probst, MVP
http://www.vbbox.com/
I want to know if ServiceController is a FULL MANAGE implementation or
if
is
really a proxy over native api's or COM.
Does anybody knows?
Thanks in advance