.net.net-4.0ms-officeadd-inshim

Is there a .NET 4 compatible version of the Office Add-in Shim?


When creating a .NET-based Office add-in without VSTO, it's necessary (or at least desirable) to use a "COM shim" that loads the add-in, to provide process isolation so that the effect of any crash is limited to that add-in.

Microsoft (I think) provided the C++ shim project that I've been using, but now I'm belatedly upgrading my project from .NET 1.1 (yes, really) to .NET 4.

I'm getting a compiler warning from the shim project:

warning C4996: 'CorBindToRuntimeEx': This API has been deprecated. Refer to http://go.microsoft.com/fwlink/?LinkId=143720 for more details.

Unfortunately, this link doesn't actualy tell me how to fix it, and since I don't understand the original, I'm not in a position to do this.

FYI, the offending code looks like this:

// Load runtime into the process ...
hr = CorBindToRuntimeEx(
     // version, use default
    0,
     // flavor, use default
    0,
     // domain-neutral"ness" and gc settings
    STARTUP_LOADER_OPTIMIZATION_MULTI_DOMAIN |  STARTUP_CONCURRENT_GC,
    CLSID_CorRuntimeHost, 
    IID_ICorRuntimeHost, 
    (PVOID*) &m_pHost);

Is there a new version of the shim project available? I've been unable to find one...


Solution

  • I found this, which is a solution for VS2010. It also covers how to set breakpoints in your add-in when using a shim, which is something I'd always found problematic.

    I was able to convert this to a VS2012 project, too.