[C# COM development] output by Regasm

G

Guest

Hello everyone,


I am debugging and learning MSDN C# COM server sample.

http://msdn2.microsoft.com/en-us/library/aa645738(vs.71).aspx

I am using Regasm to generate Windows Registry scripts, here it is,

I can understand that for C# COM Server, since it is managed code, it will
use mscoree.dll as the entry point. But I can not see anything related to the
real codebase dll (CSharpServer.dll), which contains the real implementation
of coclass and interface definition.

I am wondering how mscoree.dll find and invoke real implementation in
CSharpServer.dll?

Code:
REGEDIT4

[HKEY_CLASSES_ROOT\CSharpServer.InterfaceImplementation]
@="CSharpServer.InterfaceImplementation"

[HKEY_CLASSES_ROOT\CSharpServer.InterfaceImplementation\CLSID]
@="{C6659361-1625-4746-931C-36014B146679}"

[HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}]
@="CSharpServer.InterfaceImplementation"

[HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}\InprocServer32]
@="mscoree.dll"
"ThreadingModel"="Both"
"Class"="CSharpServer.InterfaceImplementation"
"Assembly"="CSharpServer, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null"
"RuntimeVersion"="v2.0.50727"

[HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}\InprocServer32\0.0.0.0]
"Class"="CSharpServer.InterfaceImplementation"
"Assembly"="CSharpServer, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null"
"RuntimeVersion"="v2.0.50727"

[HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}\ProgId]
@="CSharpServer.InterfaceImplementation"

[HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}\Implemented
Categories\{62C8FE65-4EBB-45E7-B440-6E39B2CDBF29}]


thanks in advance,
George
 
C

Cezary Nolewajka

Hi,

I was working lately on COM implementation in .Net and found out that
running regasm with tlb option registers as well the full path to tlb and
the directory where the dll (assembly). is placed.

When you look into registry, in the TypeLib subkey for registered classes
you have the Guid of the key that contains the information.
This is located in: \\HKCR\TypeLib\[YourGuid]

I don't know why the generated registry information does not contain this
bit.

Some good articles on .Net COM development can be found here:

http://www.codeproject.com/useritems/BuildCOMServersInDotNet.asp
http://www.codeproject.com/dotnet/nettocom.asp

Best regards,
Cezary Nolewajka

Consultant | Microsoft Services | Microsoft | Poland
 
B

Ben Voigt [C++ MVP]

George said:
Hello everyone,


I am debugging and learning MSDN C# COM server sample.

http://msdn2.microsoft.com/en-us/library/aa645738(vs.71).aspx

I am using Regasm to generate Windows Registry scripts, here it is,

I can understand that for C# COM Server, since it is managed code, it will
use mscoree.dll as the entry point. But I can not see anything related to
the
real codebase dll (CSharpServer.dll), which contains the real
implementation
of coclass and interface definition.

I am wondering how mscoree.dll find and invoke real implementation in
CSharpServer.dll?

This line:
"Assembly"="CSharpServer, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null"

is the reference data used by mscoree to load managed assemblies.
Code:
REGEDIT4

[HKEY_CLASSES_ROOT\CSharpServer.InterfaceImplementation]
@="CSharpServer.InterfaceImplementation"

[HKEY_CLASSES_ROOT\CSharpServer.InterfaceImplementation\CLSID]
@="{C6659361-1625-4746-931C-36014B146679}"

[HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}]
@="CSharpServer.InterfaceImplementation"

[HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}\InprocServer32]
@="mscoree.dll"
"ThreadingModel"="Both"
"Class"="CSharpServer.InterfaceImplementation"
"Assembly"="CSharpServer, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null"
"RuntimeVersion"="v2.0.50727"

[HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}\InprocServer32\0.0.0.0]
"Class"="CSharpServer.InterfaceImplementation"
"Assembly"="CSharpServer, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null"
"RuntimeVersion"="v2.0.50727"

[HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}\ProgId]
@="CSharpServer.InterfaceImplementation"

[HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}\Implemented
Categories\{62C8FE65-4EBB-45E7-B440-6E39B2CDBF29}]


thanks in advance,
George
 
G

Guest

Hi Ben,


How do you think from the following line,
"Assembly"="CSharpServer, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null"

mscoree.dll will find the actual codebase -- CSharpServer.dll? Why it could
find this CSharpServer.dll, other than some other dll?

(I have this question since from the registry line you quoted, there is no
information about CSharpServer.dll).


regards,
George

Ben Voigt said:
George said:
Hello everyone,


I am debugging and learning MSDN C# COM server sample.

http://msdn2.microsoft.com/en-us/library/aa645738(vs.71).aspx

I am using Regasm to generate Windows Registry scripts, here it is,

I can understand that for C# COM Server, since it is managed code, it will
use mscoree.dll as the entry point. But I can not see anything related to
the
real codebase dll (CSharpServer.dll), which contains the real
implementation
of coclass and interface definition.

I am wondering how mscoree.dll find and invoke real implementation in
CSharpServer.dll?

This line:
"Assembly"="CSharpServer, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null"

is the reference data used by mscoree to load managed assemblies.
Code:
REGEDIT4

[HKEY_CLASSES_ROOT\CSharpServer.InterfaceImplementation]
@="CSharpServer.InterfaceImplementation"

[HKEY_CLASSES_ROOT\CSharpServer.InterfaceImplementation\CLSID]
@="{C6659361-1625-4746-931C-36014B146679}"

[HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}]
@="CSharpServer.InterfaceImplementation"

[HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}\InprocServer32]
@="mscoree.dll"
"ThreadingModel"="Both"
"Class"="CSharpServer.InterfaceImplementation"
"Assembly"="CSharpServer, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null"
"RuntimeVersion"="v2.0.50727"

[HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}\InprocServer32\0.0.0.0]
"Class"="CSharpServer.InterfaceImplementation"
"Assembly"="CSharpServer, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null"
"RuntimeVersion"="v2.0.50727"

[HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}\ProgId]
@="CSharpServer.InterfaceImplementation"

[HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}\Implemented
Categories\{62C8FE65-4EBB-45E7-B440-6E39B2CDBF29}]


thanks in advance,
George
 
G

Guest

Thanks Cezary!


I have tested that you are correct! We have to use /tlb option.

I am writing C# COM server (managed code). Since there is no QueryInterface,
DllGetClassObject like in C++ native code, I am wondering how to know which
coclass is initialized and which method is invoking by client?

I have such question is because I only develop COM server, and there are
some dll level error (dll no longer available, something like this), so I
think COM client may use some coclass/methods which my COM server does not
support. But I do not have COM client source codes, so I am wondering how to
get the information (which coclass/method client is using).


thanks in advance,
George

Cezary Nolewajka said:
Hi,

I was working lately on COM implementation in .Net and found out that
running regasm with tlb option registers as well the full path to tlb and
the directory where the dll (assembly). is placed.

When you look into registry, in the TypeLib subkey for registered classes
you have the Guid of the key that contains the information.
This is located in: \\HKCR\TypeLib\[YourGuid]

I don't know why the generated registry information does not contain this
bit.

Some good articles on .Net COM development can be found here:

http://www.codeproject.com/useritems/BuildCOMServersInDotNet.asp
http://www.codeproject.com/dotnet/nettocom.asp

Best regards,
Cezary Nolewajka

Consultant | Microsoft Services | Microsoft | Poland

George said:
Hello everyone,


I am debugging and learning MSDN C# COM server sample.

http://msdn2.microsoft.com/en-us/library/aa645738(vs.71).aspx

I am using Regasm to generate Windows Registry scripts, here it is,

I can understand that for C# COM Server, since it is managed code, it will
use mscoree.dll as the entry point. But I can not see anything related to
the
real codebase dll (CSharpServer.dll), which contains the real
implementation
of coclass and interface definition.

I am wondering how mscoree.dll find and invoke real implementation in
CSharpServer.dll?

Code:
REGEDIT4

[HKEY_CLASSES_ROOT\CSharpServer.InterfaceImplementation]
@="CSharpServer.InterfaceImplementation"

[HKEY_CLASSES_ROOT\CSharpServer.InterfaceImplementation\CLSID]
@="{C6659361-1625-4746-931C-36014B146679}"

[HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}]
@="CSharpServer.InterfaceImplementation"

[HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}\InprocServer32]
@="mscoree.dll"
"ThreadingModel"="Both"
"Class"="CSharpServer.InterfaceImplementation"
"Assembly"="CSharpServer, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null"
"RuntimeVersion"="v2.0.50727"

[HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}\InprocServer32\0.0.0.0]
"Class"="CSharpServer.InterfaceImplementation"
"Assembly"="CSharpServer, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null"
"RuntimeVersion"="v2.0.50727"

[HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}\ProgId]
@="CSharpServer.InterfaceImplementation"

[HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}\Implemented
Categories\{62C8FE65-4EBB-45E7-B440-6E39B2CDBF29}]


thanks in advance,
George
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top