REGDB_E_CLASSNOTREG in COM Tutorial (Pluralsight)
<p>I'm trying to teach myself the fundamentals of COM, and to that end I'm following along with Kenny Kerr's "The Essentials of COM" course on Pluralsight. I'm currently stuck in the "Remoting" section of part 2, specifically the video titled "Demo: Defining Remotable Interfaces". My current full solution is listed here: <a href="https://github.com/jakotheshadows/COMClient" rel="nofollow noreferrer">https://github.com/jakotheshadows/COMClient</a></p>

<p>I get as far as running </p>

<pre><code>midl hen.idl
</code></pre>

<p>and then compiling the output from that with</p>

<pre><code>cl /W4 /DWIN32 /DREGISTER_PROXY_DLL *.c /link /DLL rpcrt4.lib /OUT:Proxy.dll /DEF:Exports.def
</code></pre>

<p>then I do </p>

<pre><code>regsvr32 Proxy.dll
</code></pre>

<p>and it says it successfully registered.</p>

<p>However when I get to the CoGetClassObject call while running the client:</p>

<pre><code>#include "Precompiled.h"
#include "..\COMServer\Server.h"
#include "..\Proxy\Hen.h"

using namespace Microsoft::WRL;

int main()
{
    ComRuntime runtime(Apartment::SingleThreaded);

    ComPtr&lt;IPSFactoryBuffer&gt; proxyFactory;

    HR(CoGetClassObject(__uuidof(IAsyncHenEventHandler), 
                    CLSCTX_INPROC_SERVER,
                    nullptr,
                    __uuidof(proxyFactory), 
                    reinterpret_cast&lt;void**&gt;(proxyFactory.GetAddressOf())));

    ComPtr&lt;IHen&gt; hen;

    HR(CoCreateInstance(__uuidof(Hen), nullptr, CLSCTX_INPROC_SERVER, __uuidof(hen), reinterpret_cast&lt;void**&gt;(hen.GetAddressOf())));

    hen-&gt;Cluck();
}
</code></pre>

<p>I get an error and I can see that CoGetClassObject returns HRESULT REGDB_E_CLASSNOTREG, and Kenny Kerr's example seems to "just work".</p>

<p><strong>Update</strong>: It has been suggested that the <code>rclsid</code> and the <code>riid</code> arguments are backwards in the call shown above. I have tried: </p>

<pre><code>HR(CoGetClassObject(_uuidof(proxyFactory),
                    CLSCTX_INPROC_SERVER,
                    nullptr,
                    __uuidof(IAsyncHenEventHandler),
                    reinterpret_cast&lt;void**&gt;(proxyFactory.GetAddressOf())));
</code></pre>

<p>And I still run into the same HRESULT from CoGetClassObject.</p>

<p>I'm not sure where I've gone wrong here. I am noticing that I see something different when I check Proxy.dll with the dependency walker than Mr. Kerr gets when he does it:</p>

<p><a href="https://i.stack.imgur.com/XVEmb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XVEmb.png" alt="enter image description here"></a></p>

<p>Most notably, in my Proxy.dll there is this "ADVAPI32.DLL" that is not present when Kenny Kerr inspects Proxy.dll with depends.exe. Also, I see a few errors that he doesn't seem to get:</p>

<blockquote>
  <ol>
  <li>Warning: At least one delay-load dependency module was not found.</li>
  <li>Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.</li>
  </ol>
</blockquote>

<p>Another difference between my environment and Kenny Kerr's is that I'm using Visual Studio 2015, where he is using Visual Studio 2012. I'm running in Windows 7 Professional x64.</p>