Search code examples
.netcominteroptlbimp

How to use tlbimp.exe's /keycontainer switch?


Anybody have an example of how to use tlbimp.exe's /keycontainer command line switch?

The googles...they don't help. It's always /publickey, or /keyfile. No example of using /keycontainer.


Solution

  • Well, to answer my own question for the sake of anyone else who may find themselves in this situation:

    First, you need to put your public/private key into a 'container'. sn.exe can do this for you:

    sn.exe -i MySpecial.pfx MagicContainerName
    

    Then you can use tlbimp.exe like so:

    tlbimp.exe MyActiveX.dll /out:MyActiveX.Interop.dll /keycontainer:MagicContainerName 
    

    Finally, cleanup the container you created:

    sn.exe -d MagicContainerName