locked
COM Interop DLL Registration Issues and ComRegisterFunctionAttribute RRS feed

  • Question

  • I'm trying to create a shell extension handler.  I'm using a sample bit from here.

    In this sample, the author adorns a couple of methods with attributes that are supposed to expose those methods to be called when the DLL is registered.

    System.Runtime.InteropServices.ComRegisterFunctionAttribute()
    System.Runtime.InteropServices.ComUnregisterFunctionAttribute()

    (As well as adding a GUID and ComVisible(true) attribute to the class itself.)

    The author specifically states that these function will be called when the assembly is registered (or un-registered) with COM.  "If we were to register our assembly with regsvr32.exe or other standard registration system, they would call these methods when registering and un-registering."

    But if I try to register the DLL with RegSvr32, I get the error that the DLLRegisterServer entry point could not be found.  If I try to register with RegAsm, the functions noted above are never called.

    (I do have the "Register for COM interop" box checked in the build options of the project.)

    How do I get those methods to execute at registration?

    Thanks.

    J
    http://digitalcamel.blogspot.com - .Net, ILM, SQL and Anything Else That Falls Out Of My Brain
    Tuesday, March 17, 2009 2:46 PM

Answers

  • Regsvr32 doesn't work with .NET assemblies.  regasm will call your functions.  If it isn't then your functions or the type it is attached to isn't actually being registered.  You didn't mention anything about the COM interface(s) you are implementing on your type in question.  Can you show us the class declaration you are using along with the signature for the reg/unreg functions you're using?

    Michael Taylor - 3/17/09
    http://p3net.mvps.org
    • Marked as answer by Jerry Camel Tuesday, March 17, 2009 3:17 PM
    Tuesday, March 17, 2009 2:53 PM

All replies

  • Regsvr32 doesn't work with .NET assemblies.  regasm will call your functions.  If it isn't then your functions or the type it is attached to isn't actually being registered.  You didn't mention anything about the COM interface(s) you are implementing on your type in question.  Can you show us the class declaration you are using along with the signature for the reg/unreg functions you're using?

    Michael Taylor - 3/17/09
    http://p3net.mvps.org
    • Marked as answer by Jerry Camel Tuesday, March 17, 2009 3:17 PM
    Tuesday, March 17, 2009 2:53 PM
  • I have no idea what changed.  I didn't do anything other than restart VS and recompile, but the functions are now being called and my reg entries are being added.  Maybe I forgot to refresh the registry when I was checking earlier...  Not sure.  But it's going now.

    So the article has it wrong when the Author mentions RegSvr32 as a valid registration method...

    Thanks for the response.

    J
    http://digitalcamel.blogspot.com - .Net, ILM, SQL and Anything Else That Falls Out Of My Brain
    Tuesday, March 17, 2009 3:16 PM