Running ATL Components created in VS2008 as CLSCTX_LOCAL_SERVER

Yesterday Jasenko, one of the developers here, noticed that our newest components weren’t working in ‘Safe Mode’. Since Safe Mode simply runs the component in a separate process by specifying CLSCTX_LOCAL_SERVER instead of CLSCTX_INPROC_SERVER this had us all quite confused. This used to work seamlessly. On closer inspection it appears that the default settings generated by Visual Studio 2008 are to blame.

Two extra changes are now required for out of process activation to work:

1. The AppID settings for the library needs to specify the DllSurrogate (leave blank to use the default surrogate process dllhost.exe), e.g.

HKCR 
{ 
    NoRemove AppID 
    { 
        '%APPID%' = s 'MyLib' 
        { 
            val DllSurrogate = s '' 
        } 
  
        'MyLib.DLL' 
        { 
            val AppID = s '%APPID%' 
        } 
    } 
} 

2. The component needs to specify the AppID

HKCR 
{
     ... default component registration ...
     NoRemove CLSID
     {
         ForceRemove (clsid) = s 'MyObject Class'
         {
             val AppID = s '%APPID%'
             ... rest of class registration...
         }
     }
 } 

That’s it.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s