Make generated COM Interop assembly "Internal/Friend" to another assembly RRS feed

  • Question

  • Hi,

    I have a COM Interop Assembly generated by TLBIMP tool, and I'd like to make this COM Interop Assembly "internal/friend" to another public Assembly ONLY.

    Anyone knows if there's any way to do this (that does not use script to hack into disam file)?

    The TLBIMP tool does not seem to support this.

    Thanks for help!


    Tuesday, June 5, 2012 11:16 PM

All replies

  • I don't have an answer, only a question:  Since the assembly can be reproduced by running the tool again against the COM type library, what would be the point of the exercise?  Anybody really wanting to use the COM object can simply run the tool and voilá!

    Jose R. MCP

    Wednesday, June 6, 2012 3:14 AM
  • Good question. This is intended to *NOT* expose the COM objects in the Interop Assembly to Managed applications consuming the public Assembly (since public Assembly is referencing the Interop DLL); otherwise, one can just look them up from Ildsm or some Reflector tool.

    The normally [assembly:InternalVisibleTo("")] asstribute works for this exact purpose for managed codes compilation. But, for interop codes generated by TLBIMP tool, I'm still looking for an effective way to achieve same.

    Wednesday, June 6, 2012 12:49 PM
  • I can only think about creating the interop DLL by hand.  It could be an option if the TLB is rather small.  But granted, I have never created an interop DLL by hand.  I am guessing it is possible, but I cannot be 100% sure at the moment.

    Jose R. MCP

    Wednesday, June 6, 2012 12:58 PM
  • It's not too difficult to create an interop assembly by hand, especially if you have NET Reflector to help. There's rarely any actual code, just declarations of interfaces/methods/classes etc.

    Phil Wilson

    Wednesday, June 6, 2012 7:10 PM
  • Hi Phil,

    Would you like to share a specific way?

    You have said it is possible by reflector.

    But as far as I know, the tool reflector can only just show you the assembly code, you cannot edit it in this tool.

    Am I wrong?

    Have a nice day.

    Call me ghost for short, Thanks
    To get the better answer, it should be a better question.

    Thursday, June 7, 2012 8:09 AM
  • In the context of generating the interop assembly by hand, just copy it all out of reflector into a C# project.

    Phil Wilson

    • Proposed as answer by CrazyGhost_Von Wednesday, June 13, 2012 5:47 AM
    Friday, June 8, 2012 7:12 PM