Click here to Skip to main content
15,886,199 members

Comments by ExcellentOrg (Top 3 by date)

ExcellentOrg 28-Sep-13 6:52am View    

The COM Library
[^]

Second para at the above link reads ....

Implementation-locator services through which COM determines, from a unique class identifier (CLSID), which server implements that class and where that server is located. This service includes support for a level of indirection, usually a system registry, between the identity of an object class and the packaging of the implementation so that clients are independent of the packaging, which can change in the future.

Am I correct in interpretation that in this particular context of mine, I am trying to bypass this indirection and allow client to decide the server is going to be?
ExcellentOrg 28-Sep-13 5:01am View    
David,

Yes!, It is on same machine and it is safe to assume that it will always run on the same machine. I did take a look at the URL you gave. it does not have "SystemHandleInformation" but it does have SystemProcessInformation which returns array containing Process information. Following is the code snippet that works correctly as long as only one instance is running.

private Object AccessCOMServer(String nameOfExecutable, String COMProgID)
{
Process[] proc = Process.GetProcessesByName(nameOfExecutable);
if (proc.Length == 1)
{
Type dataAppProgID = Type.GetTypeFromProgID(COMProgID);
_dataApp = Activator.CreateInstance(dataAppProgID);
String currentPath = _dataApp.GetType().InvokeMember("DatabasePath", BindingFlags.GetProperty, null, _dataApp, null).ToString();
}
}

Debugger shows

proc[0] is shown in debugger as instance of System.Diagnostics.Process with all information including process id, name of executable, path of executable and even command line arguments that were used to invoke it.

dataAppProgID is shown as instance of System.RuntimeType with many properties and assembly that originates from is shown as mscorlib
_dataApp as System.__ComObject with only visible properties Identity and m_ObjectToDataMap (Hashtable) as null
but all invoke

Even I use the second suggestion of using CreateProcess, it will execute the new instance all right and connected to correct database but how do I get the COM server to bind to correct running process.

Entire problem revolves around my limited understanding of Activator.CreateInstance which as 13 overloads and some of them do accept things like assembly domain, but Process object does not expose assembly's appdomain.
ExcellentOrg 28-Sep-13 4:06am View    
Sergey

I did not decide what 3rd party C++ app uses. I know it is C++ because I happened to get a chance to talk to one of its developer. It is a very good application (probably best in its class). It is certainly good at what it does and it provides access to its data thru COM (which maybe obsolete), is efficient. Moreover from my POV and user's POV, cost of acquiring the s/w; learning its usage is already invested, so why chase a new horse and spend unnecessary moolah?