473,387 Members | 1,541 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

C# COM entry point function

Hello everyone,
I am a developer from C++ COM to C# COM. I feel confused about the entry
point function for a C# COM object.

In C++, we always initialize object through GetClassObject or
DLLGetClassObject, but it seems C# does not need these functions?

Here is a sample from MSDN.

http://msdn2.microsoft.com/en-us/lib...38(VS.71).aspx

So, in C# do we need to implement the required functions like
GetClassObject? If no need, which function is the entry point for C# COM
object -- I want to find the entry point function so that I can verify that
my C# COM object can begin to talk with other COM clients.
thanks in advance,
George
Jul 14 '07 #1
3 5632
"George" <Ge****@discussions.microsoft.comwrote in message
news:03**********************************@microsof t.com...
Hello everyone,
I am a developer from C++ COM to C# COM. I feel confused about the entry
point function for a C# COM object.

In C++, we always initialize object through GetClassObject or
DLLGetClassObject, but it seems C# does not need these functions?

Here is a sample from MSDN.

http://msdn2.microsoft.com/en-us/lib...38(VS.71).aspx

So, in C# do we need to implement the required functions like
GetClassObject? If no need, which function is the entry point for C# COM
object -- I want to find the entry point function so that I can verify
that
my C# COM object can begin to talk with other COM clients.
thanks in advance,
George

You don't (can't) have to expose the COM activation/deactivation entry
points, this is taken care of by mscoree.dll, who is registered as the
"real" COM server when you register a .NET assembly as COM server (using
regasm.exe for instance). mscoree.dll takes care of loading the CLR whenever
you create an instance of a .NET class from a native COM client, the CLR
takes care of loading the .NET assembly and exposing the core COM interfaces
(IUnknow) and the interfaces you declared in your code.

Willy.
Jul 14 '07 #2
Thanks Willy,
I have made some practices using regasm and following your comments. C# COM
development is really defferent from C++ development from entry point.

I am using MSDN sample COM server,

http://msdn2.microsoft.com/en-us/lib...71(VS.80).aspx

Then regasm will generate the following statements,

Expand|Select|Wrap|Line Numbers
  1.  
  2. REGEDIT4
  3.  
  4. [HKEY_CLASSES_ROOT\CSharpServer.InterfaceImplementation]
  5. @="CSharpServer.InterfaceImplementation"
  6.  
  7. [HKEY_CLASSES_ROOT\CSharpServer.InterfaceImplementation\CLSID]
  8. @="{C6659361-1625-4746-931C-36014B146679}"
  9.  
  10. [HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}]
  11. @="CSharpServer.InterfaceImplementation"
  12.  
  13. [HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}\InprocServer32]
  14. @="mscoree.dll"
  15. "ThreadingModel"="Both"
  16. "Class"="CSharpServer.InterfaceImplementation"
  17. "Assembly"="CSharpServer, Version=0.0.0.0, Culture=neutral,
  18. PublicKeyToken=null"
  19. "RuntimeVersion"="v2.0.50727"
  20.  
  21. [HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}\InprocServer32\0.0.0.0]
  22. "Class"="CSharpServer.InterfaceImplementation"
  23. "Assembly"="CSharpServer, Version=0.0.0.0, Culture=neutral,
  24. PublicKeyToken=null"
  25. "RuntimeVersion"="v2.0.50727"
  26.  
  27. [HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}\ProgId]
  28. @="CSharpServer.InterfaceImplementation"
  29.  
  30. [HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}\Implemented
  31. Categories\{62C8FE65-4EBB-45E7-B440-6E39B2CDBF29}]
  32.  
  33.  
I find only public class InterfaceImplementation is in the reg file, but
public interface IManagedInterface is not in reg file. I do not know why
regasm only cares about public classes -- why interface is not in reg file?

(I think for client, the interface may also be used in application?)
regards,
George

"Willy Denoyette [MVP]" wrote:
"George" <Ge****@discussions.microsoft.comwrote in message
news:03**********************************@microsof t.com...
Hello everyone,
I am a developer from C++ COM to C# COM. I feel confused about the entry
point function for a C# COM object.

In C++, we always initialize object through GetClassObject or
DLLGetClassObject, but it seems C# does not need these functions?

Here is a sample from MSDN.

http://msdn2.microsoft.com/en-us/lib...38(VS.71).aspx

So, in C# do we need to implement the required functions like
GetClassObject? If no need, which function is the entry point for C# COM
object -- I want to find the entry point function so that I can verify
that
my C# COM object can begin to talk with other COM clients.
thanks in advance,
George


You don't (can't) have to expose the COM activation/deactivation entry
points, this is taken care of by mscoree.dll, who is registered as the
"real" COM server when you register a .NET assembly as COM server (using
regasm.exe for instance). mscoree.dll takes care of loading the CLR whenever
you create an instance of a .NET class from a native COM client, the CLR
takes care of loading the .NET assembly and exposing the core COM interfaces
(IUnknow) and the interfaces you declared in your code.

Willy.
Jul 16 '07 #3
"George" <Ge****@discussions.microsoft.comwrote in message
news:8B**********************************@microsof t.com...
Thanks Willy,
I have made some practices using regasm and following your comments. C#
COM
development is really defferent from C++ development from entry point.

I am using MSDN sample COM server,

http://msdn2.microsoft.com/en-us/lib...71(VS.80).aspx

Then regasm will generate the following statements,

Expand|Select|Wrap|Line Numbers
  1. REGEDIT4
  2. [HKEY_CLASSES_ROOT\CSharpServer.InterfaceImplementation]
  3. @="CSharpServer.InterfaceImplementation"
  4. [HKEY_CLASSES_ROOT\CSharpServer.InterfaceImplementation\CLSID]
  5. @="{C6659361-1625-4746-931C-36014B146679}"
  6. [HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}]
  7. @="CSharpServer.InterfaceImplementation"
  8. [HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}\InprocServer32]
  9. @="mscoree.dll"
  10. "ThreadingModel"="Both"
  11. "Class"="CSharpServer.InterfaceImplementation"
  12. "Assembly"="CSharpServer, Version=0.0.0.0, Culture=neutral,
  13. PublicKeyToken=null"
  14. "RuntimeVersion"="v2.0.50727"
  15. [HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}\InprocServer32\0.0.0.0]
  16. "Class"="CSharpServer.InterfaceImplementation"
  17. "Assembly"="CSharpServer, Version=0.0.0.0, Culture=neutral,
  18. PublicKeyToken=null"
  19. "RuntimeVersion"="v2.0.50727"
  20. [HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}\ProgId]
  21. @="CSharpServer.InterfaceImplementation"
  22. [HKEY_CLASSES_ROOT\CLSID\{C6659361-1625-4746-931C-36014B146679}\Implemented
  23. Categories\{62C8FE65-4EBB-45E7-B440-6E39B2CDBF29}]
  24.  

I find only public class InterfaceImplementation is in the reg file, but
public interface IManagedInterface is not in reg file. I do not know why
regasm only cares about public classes -- why interface is not in reg
file?

(I think for client, the interface may also be used in application?)
regards,
George
The /reg option is meant for informational purposes only, you should
register your classes with the /tlb option. Classes that are registered
using the reg file won't be able to be created using CoCreateInstance, nor
will it include the (optional) registration done by the custom registration
functions (see ComRegisterFunctionAttribute).

Willy.

Jul 16 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Laurent Schall | last post by:
I experience a problem where starting an application compiled with visual C++ 6 SP5 does not execute the function main(int argc, char **argv) and exit immediately with code 1 (0x1). Putting main...
6
by: aneesh | last post by:
Hi all, I would like to know whether we can specify another function instead of main as entry point. Thanks Aneesh
14
by: Vijay Kumar R Zanvar | last post by:
I have following questions: 1. Appendix C of K&R says: Trigraph sequences introduced by ?? allow representation of characters lacking in some character sets. ... Can somebody explain how...
1
by: TRI_CODER | last post by:
I am trying to solve the following exception. The exception occurs when my ASP.NET code behind code attemtps to access a remore site using SSL. Please note that all certificates are valid and the...
5
by: Mike in Santa Rosa | last post by:
I'm trying to get a simple c# app built that can launch/manipulate an excel workbook, sheet. I've chased down several examples and can't any of them to work. So I must be doing somethnig obviouslt...
8
by: Johnny | last post by:
Hi, Is there a way to detect the entry point of all the functions in a project? If so, can I make a function that will be called at the every entry point? Thanks for your consideration. ...
2
by: bboule | last post by:
Hi I have developped a dll that I want to use in another program ! here is my code : using System; using System.Collections.Generic; using System.Text; namespace NameSpace
10
by: Lung.S.wu | last post by:
Hi all, It is a history question. Recently, I read the book "C A reference manual, third edition". In this book, it list all C language keyword, and one is "entry". I know it is omitted from...
5
by: Premkumar | last post by:
a.cpp ---------------------------------- #include <iostream> using namespace std; void mymain() { cout<<"my-main"<<endl; } ----------------------------------
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.