COM Shims

I am new to creating COM Shims. I want to know for which all asseblies other then Office Extensions that we can create COM Shims.

How is it implemented in Application Packaging and how can we find out which assembly requires COM Shim to be created.


Answer this question

COM Shims

  • R.A

    Yes It is the same COM Shims that Microsoft advices for Office Addins.

    But what I want to Know as a Application Packager that

    If  I get a application with office addins we can apply COM Shim to the addin DLL. But what to do if the DLL is not a strong DLL. How can we convert the DLL to strong DLL without the source code.

    Can this COM Shim technology be used for some other application DLLs. If yes How and If not Why.

    In any case way can't we use in terms of conflict resolution technique.

  • Highrad

    I am not aware of a simple way to strong name an assembly that has not been previously delay signed. Keep in mind all assemblies referenced by strong named assemblies must be strong named as well. If there are no other unsigned assemblies referenced then you can first run ildasm tool to retrieve the MSIL code and then compile it back into an assembly using ilasm this time by specifying a key pair.

    However you might choose not to do this. It still not the end of the world and I would still recommend using the COM shim - just without the strong name. This will at least place your assembly into a separate AppDomain and give you types isolation. There are some remote security risks associated with using unsigned assemblies and you need to assess the risks before going down this road.

    To achieve loading unsigned assemblies you need to make minor modification to the code of the COM shim. In the below snippet from http://msdn.microsoft.com/library/default.asp url=/library/en-us/dnoxpta/html/odc_shim.asp you will just need to remove the specification of the PublicKeyToken.

    static LPCWSTR szAddInAssemblyName = L"ManagedAddIn, PublicKeyToken=6c96c7507b8e2be8"; 
    static LPCWSTR szAddInAssemblyName = L"ManagedAddIn";
    static LPCWSTR szConnectClassName = L"ManagedAddIn.Connect";
    LPCWSTR ShimConfig::AssemblyName()
    {
    return szAddInAssemblyName;
    }
    LPCWSTR ShimConfig::ConnectClassName()
    {
    return szConnectClassName;
    }


  • Victoria W

    Thankyou Misha

    It was really helpful to me.
    Hope u will guide me in the same way in furture too.

    regards
    Sudhir kaushik

  • netterdotter

    Sudhir,

    I am a little bit lost. I assume you are talking about the technique outlined here http://msdn.microsoft.com/library/default.asp url=/library/en-us/dno2k3ta/html/ODC_Office_COM_Shim_Wizards.asp

    I am not clear what your question is though Do you understand why shims are needed

  • COM Shims