0

My global objective is to create a COM-based application, where client part is C++ code and server part - C#. It looks simple.

I try to use the sample from MSDN: http://msdn.microsoft.com/en-us/library/aa645738(v=vs.71).aspx

I make a solution with two projects (using VisualStudio2008) and compile. well.

I register component manually. (ref1)

But when I run a client application, CoCreateInstance returns HRESULT "Class not registred".

on the step (ref1) I try to use:

1) regasm server.dll /tlb:server.tlb (file names in cpp source now are compatible, of cause)(from MSDN)

2) regasm server.dll /tlb:server.tlb gacutil /i server.dll

3) regasm /codebase /tlb server.dll

In the registry a see my class, but "default value" of InprocServer is mscore.dll. Comparing with another registry notes, it looks like mistake. I tryed to edit this value manually - no result.

But I'm shure, this sample works! once I've done many many different actions without change GUIDs and... It WORKS! But I Change GUID's, try to register - no result. And i can't repeat this situation. Magic...

Help me, please! I need an exact alhoritm without change source (optionnal) and without manual work in the registry (totally impossible in my case).

//sorry, mb my english isn't perfect.

1
  • The InprocServer value of mscore.dll is correct. Commented Jul 18, 2011 at 14:55

2 Answers 2

4

In the registry a see my class, but "default value" of InprocServer is mscore.dll

No, that's not a mistake. Mscoree.dll is the bootstrapper for the CLR, it ensures the CLR is properly loaded and initialized to allow managed code to run in a native application without CLR support. And it provides the DllGetClassObject entrypoint that a COM server must supply. There is no general way for a managed assembly to have native exports like DllGetClassObject.

You ought to run regasm.exe with the /codebase option on your dev machine so you don't have to register the assembly in the GAC with gacutil.exe. Which you already tried. You are now down to registry issues, the native program cannot find the registry entries that you found back with Regedit.exe. A very common cause for that is running on a 64-bit operating system. You should use the 32-bit version of Regasm.exe (from Framework, not Framework64) if the COM client is a 32-bit program. So that the registration info goes into HKLM\Software\Wow6432Node\Classes\CLSID instead of HKLM\Software\Classes\CLSID. The Wow6432Node is the difference, that's the home for 32-bit registration.

When all else fails, use SysInternals' ProcMon utility. It lets you see where the native program is searching in the registry for the registration keys.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, Hans, It's working. The problem was my command line use by the command "regasm" a 64 version.
0

I think you should try the line: regasm /codebase server.dll /tlb server.tlb

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.