none
Registration Free COM - Can't get Proxy/Stub to work

    Question

  • I'm trying to figure out how to effectively enable proxy/stub implementation for a COM component when using manifests (see http://msdn.microsoft.com/en-us/library/ms973913.aspx#rfacomwalk_topic8).

    So I built a little sample app, but am getting an error when the proxy/stub is being invoked.  My test scenario is:

    A simple COM component built using ATL/C++ that exposes a single interface/coclass with a single method.  This is also a dual interface and derives from IDispatch.

    [
    	object,
    	uuid(C5B80F04-D93B-4D48-9D78-44899B35109E),
    	dual,
    	nonextensible,
     oleautomation,
    	helpstring("ITestSimple Interface"),
    	pointer_default(unique)
    ]
    interface ITestSimple : IDispatch{
     [id(1), helpstring("method ReturnLineNumber")] HRESULT ReturnLineNumber([in] LONG entryID, [out,retval] LONG* lineNumber);
    };
    [
    	uuid(C62EE9A8-2A4D-4C43-9F70-36ABCCB955D0),
    	version(1.0),
    	helpstring("COMAut3 1.0 Type Library")
    ]
    library COMAut3Lib
    {
    	importlib("stdole2.tlb");
    	[
    		uuid(CD0375FD-AC13-4AB3-BE5F-E8443FAAA687),
    		helpstring("TestSimple Class")
    	]
    	coclass TestSimple
    	{
    		[default] interface ITestSimple;
    	};

    I have specified this to use Isolated COM and embedded the manifest into the dll.  The manifest looks like this:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
     <dependency>
      <dependentAssembly>
       <assemblyIdentity type="win32" name="Microsoft.VC90.DebugCRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
      </dependentAssembly>
     </dependency>
     <dependency>
      <dependentAssembly>
       <assemblyIdentity type="win32" name="Microsoft.VC90.DebugMFC" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
      </dependentAssembly>
     </dependency>
     <file name="COMAut3" hashalg="SHA1">
      <comClass clsid="{CD0375FD-AC13-4AB3-BE5F-E8443FAAA687}" tlbid="{C62EE9A8-2A4D-4C43-9F70-36ABCCB955D0}" description="TestSimple Class"></comClass>
      <typelib tlbid="{C62EE9A8-2A4D-4C43-9F70-36ABCCB955D0}" version="1.0" helpdir="" flags="HASDISKIMAGE"></typelib>
     </file>
     <comInterfaceExternalProxyStub 
      name="ITestSimple" 
      iid="{C5B80F04-D93B-4D48-9D78-44899B35109E}" 
      tlbid="{C62EE9A8-2A4D-4C43-9F70-36ABCCB955D0}" 
      baseInterface="{00000000-0000-0000-C000-000000000046}" 
      proxyStubClsid32="{00020424-0000-0000-C000-000000000046}"></comInterfaceExternalProxyStub>
    </assembly>
    

    The client application is a simple .Net Winforms app written in C#.  It creates an instance of the COM component on the main thread and then calls it twice.  Once on the main thread, and then passed to another thread to test this cross-apartment marshaling.

      public partial class Form1 : Form
      {
        private COMAut3Lib.TestSimpleClass _comInstance;
    
        public Form1()
        {
          InitializeComponent();
          _comInstance = new TestSimpleClass();
        }
    
        private void buttonRun_Click(object sender, EventArgs e)
        {
          int retVal = _comInstance.ReturnLineNumber(50);
    
          Worker workerObject = new Worker(_comInstance);
          Thread workerThread = new Thread(workerObject.DoWork);
          workerThread.Start();
        }
      }
    
      public class Worker
      {
        private COMAut3Lib.TestSimpleClass _passedCOM;
    
        public Worker(TestSimpleClass comObject)
        {
          _passedCOM = comObject;
        }
    
        public void DoWork()
        {
          int retVal = _passedCOM.ReturnLineNumber(50);
        }
    
    

    The application manifest file looks like:

    <?xml version="1.0" encoding="utf-8"?>
    <asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
     <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
      <security>
       <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
        <requestedExecutionLevel level="asInvoker" uiAccess="false" />
       </requestedPrivileges>
      </security>
     </trustInfo>
     <dependency>
      <dependentAssembly>
       <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" publicKeyToken="6595b64144ccf1df"
       language="*" processorArchitecture="x86" />
      </dependentAssembly>
     </dependency>
     <dependency>
      <dependentAssembly>
       <assemblyIdentity name="COMAut3" version="1.0.0.0" type="win32" processorArchitecture="x86"/>
      </dependentAssembly>
     </dependency>
    
    </asmv1:assembly>
    
    

    However, when I run this and it needs to invoke the proxy/stub, I get an InvalidCastException error (TYPE_E_CANTLOADLIBRARY).  In this particular case, the proxy/stub should be handled by ole32.dll and I don't need to add anything additional to the COM dll itself.  It seems like I'm missing something easy, but I can't figure out why this is not working.

    NOTE: taking the manifest file out of the picture and just registering the COM component works just fine.

    Tuesday, March 01, 2011 1:05 AM

All replies

  •  

    Would you please use sxstrace tool to get more detail information of this failure?


    Eric Yang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, March 02, 2011 8:40 AM
  • The development machine is Windows XP.  I'll try testing on a Windows 7 machine and track down some additional details.
    Wednesday, March 02, 2011 7:27 PM
  • I ran the sxstrace tool on a Windows 7 machine.  I don't fully understand how this tool works, it appears to be capturing info for other applications we have that use manifests but weren't running at the time I started the trace.  It also appears to capture info multiple times for my test app.  In any event, copied most of it here (posting the entire thing failed a couple of times, maybe because my post was too long).

    I can't really see any failures related to my issue.  Just to clarify:

    1.  The test app does not produce an error when it initially loads up, so it appears that it loads the COM DLL via the manifest correctly.

    2.  However, when I go to make a call on the COM component from another thread, it crashes with the following exception:

    An unhandled exception of type 'System.InvalidCastException' occurred in NetClient.exe

    Additional information: Unable to cast COM object of type 'COMAut3Lib.TestSimpleClass' to interface type 'COMAut3Lib.ITestSimple'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{C5B80F04-D93B-4D48-9D78-44899B35109E}' failed due to the following error: Error loading type library/DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)).

    I think this is because at that point, it looks at the comInterfaceExternalProxyStub info in the COM DLL's embedded manifest but somehow has a problem resolving the type library for ole32.dll.  Don't really understand why or how to remedy this though.

    =================

    Begin Activation Context Generation.
    Input Parameter:
        Flags = 0
        ProcessorArchitecture = AMD64
        CultureFallBacks = en-US;en
        ManifestPath = \\dcvsf\HOME02\JFendors\regfree\Debug\NetClient.exe.Manifest
        AssemblyDirectory = \\dcvsf\HOME02\JFendors\regfree\Debug\
        Application Config File =
    -----------------
    INFO: Parsing Manifest File \\dcvsf\HOME02\JFendors\regfree\Debug\NetClient.exe.Manifest.
        INFO: Manifest Definition Identity is MyApplication.app,version="1.0.0.0".
        INFO: Reference: Microsoft.Windows.Common-Controls,language="&#x2a;",processorArchitecture="x86",publicKeyToken="6595b64144ccf1df",type="win32",version="6.0.0.0"
        INFO: Reference: COMAut,processorArchitecture="x86",type="win32",version="1.0.0.0"
    INFO: Resolving reference Microsoft.Windows.Common-Controls,language="&#x2a;",processorArchitecture="x86",publicKeyToken="6595b64144ccf1df",type="win32",version="6.0.0.0".
        INFO: Resolving reference for ProcessorArchitecture x86.
            INFO: Resolving reference for culture en-US.
                INFO: Applying Binding Policy.
                    INFO: No publisher policy found.
                    INFO: No binding policy redirect found.
                INFO: Begin assembly probing.
                    INFO: Did not find the assembly in WinSxS.
                    INFO: Attempt to probe manifest at C:\Windows\assembly\GAC_32\Microsoft.Windows.Common-Controls\6.0.0.0_en-US_6595b64144ccf1df\Microsoft.Windows.Common-Controls.DLL.
                    INFO: Did not find manifest for culture en-US.
                INFO: End assembly probing.
            INFO: Resolving reference for culture en.
                INFO: Applying Binding Policy.
                    INFO: No publisher policy found.
                    INFO: No binding policy redirect found.
                INFO: Begin assembly probing.
                    INFO: Did not find the assembly in WinSxS.
                    INFO: Attempt to probe manifest at C:\Windows\assembly\GAC_32\Microsoft.Windows.Common-Controls\6.0.0.0_en_6595b64144ccf1df\Microsoft.Windows.Common-Controls.DLL.
                    INFO: Did not find manifest for culture en.
                INFO: End assembly probing.
            INFO: Resolving reference for culture Neutral.
                INFO: Applying Binding Policy.
                    INFO: Auto Servicing Policy redirected assembly version.
                    INFO: Post policy assembly identity is Microsoft.Windows.Common-Controls,processorArchitecture="x86",publicKeyToken="6595b64144ccf1df",type="win32",version="6.0.7600.16661".
                INFO: Begin assembly probing.
                    INFO: Attempt to probe manifest at C:\Windows\WinSxS\manifests\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7600.16661_none_420fe3fa2b8113bd.manifest.
                    INFO: Manifest found at C:\Windows\WinSxS\manifests\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7600.16661_none_420fe3fa2b8113bd.manifest.
                INFO: End assembly probing.
    INFO: Resolving reference Microsoft.Windows.Common-Controls.mui,language="&#x2a;",processorArchitecture="x86",publicKeyToken="6595b64144ccf1df",type="win32",version="6.0.7600.16661".
        INFO: Resolving reference for ProcessorArchitecture x86.
            INFO: Resolving reference for culture en-US.
                INFO: Applying Binding Policy.
                    INFO: No publisher policy found.
                    INFO: No binding policy redirect found.
                INFO: Begin assembly probing.
                    INFO: Did not find the assembly in WinSxS.
                    INFO: Attempt to probe manifest at C:\Windows\assembly\GAC_32\Microsoft.Windows.Common-Controls.mui\6.0.7600.16661_en-US_6595b64144ccf1df\Microsoft.Windows.Common-Controls.mui.DLL.
                    INFO: Did not find manifest for culture en-US.
                INFO: End assembly probing.
            INFO: Resolving reference for culture en.
                INFO: Applying Binding Policy.
                    INFO: No publisher policy found.
                    INFO: No binding policy redirect found.
                INFO: Begin assembly probing.
                    INFO: Did not find the assembly in WinSxS.
                    INFO: Attempt to probe manifest at C:\Windows\assembly\GAC_32\Microsoft.Windows.Common-Controls.mui\6.0.7600.16661_en_6595b64144ccf1df\Microsoft.Windows.Common-Controls.mui.DLL.
                    INFO: Did not find manifest for culture en.
                INFO: End assembly probing.
    INFO: Resolving reference COMAut,processorArchitecture="x86",type="win32",version="1.0.0.0".
        INFO: Resolving reference for ProcessorArchitecture x86.
            INFO: Resolving reference for culture Neutral.
                INFO: Applying Binding Policy.
                    INFO: No binding policy redirect found.
                INFO: Begin assembly probing.
                    INFO: Did not find the assembly in WinSxS.
                    INFO: Attempt to probe manifest at \\dcvsf\HOME02\JFendors\regfree\Debug\COMAut.DLL.
                    INFO: Manifest found at \\dcvsf\HOME02\JFendors\regfree\Debug\COMAut.DLL.
                INFO: End assembly probing.
    INFO: Resolving reference COMAut.mui,language="&#x2a;",processorArchitecture="x86",type="win32",version="1.0.0.0".
        INFO: Resolving reference for ProcessorArchitecture x86.
            INFO: Resolving reference for culture en-US.
                INFO: Applying Binding Policy.
                    INFO: No binding policy redirect found.
                INFO: Begin assembly probing.
                    INFO: Did not find the assembly in WinSxS.
                    INFO: Did not find manifest for culture en-US.
                INFO: End assembly probing.
            INFO: Resolving reference for culture en.
                INFO: Applying Binding Policy.
                    INFO: No binding policy redirect found.
                INFO: Begin assembly probing.
                    INFO: Did not find the assembly in WinSxS.
                    INFO: Did not find manifest for culture en.
                INFO: End assembly probing.
    INFO: Parsing Manifest File C:\Windows\WinSxS\manifests\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7600.16661_none_420fe3fa2b8113bd.manifest.
        INFO: Manifest Definition Identity is Microsoft.Windows.Common-Controls,processorArchitecture="x86",publicKeyToken="6595b64144ccf1df",type="win32",version="6.0.7600.16661".
        INFO: Reference: Microsoft.Windows.Common-Controls.Resources,language="&#x2a;",processorArchitecture="x86",publicKeyToken="6595b64144ccf1df",type="win32",version="6.0.0.0"
    INFO: Resolving reference Microsoft.Windows.Common-Controls.Resources,language="&#x2a;",processorArchitecture="x86",publicKeyToken="6595b64144ccf1df",type="win32",version="6.0.0.0".
        INFO: Resolving reference for ProcessorArchitecture x86.
            INFO: Resolving reference for culture en-US.
                INFO: Applying Binding Policy.
                    INFO: Auto Servicing Policy redirected assembly version.
                    INFO: Post policy assembly identity is Microsoft.Windows.Common-Controls.Resources,language="en-US",processorArchitecture="x86",publicKeyToken="6595b64144ccf1df",type="win32",version="6.0.7600.16385".
                INFO: Begin assembly probing.
                    INFO: Attempt to probe manifest at C:\Windows\WinSxS\manifests\x86_microsoft.windows.c..-controls.resources_6595b64144ccf1df_6.0.7600.16385_en-us_581cd2bf5825dde9.manifest.
                    INFO: Manifest found at C:\Windows\WinSxS\manifests\x86_microsoft.windows.c..-controls.resources_6595b64144ccf1df_6.0.7600.16385_en-us_581cd2bf5825dde9.manifest.
                INFO: End assembly probing.
    INFO: Parsing Manifest File \\dcvsf\HOME02\JFendors\regfree\Debug\COMAut.DLL.
        INFO: Manifest Definition Identity is (null).
        INFO: Reference: Microsoft.VC90.DebugCRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8"
        INFO: Reference: Microsoft.VC90.DebugMFC,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8"
    INFO: Resolving reference Microsoft.VC90.DebugCRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8".
        INFO: Resolving reference for ProcessorArchitecture x86.
            INFO: Resolving reference for culture Neutral.
                INFO: Applying Binding Policy.
                    INFO: Find publisher policy at C:\Windows\WinSxS\manifests\x86_policy.9.0.microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.21022.8_none_3c8576a8f974f0b8.manifest
                    INFO: Publisher Policy redirected assembly version.
                    INFO: Post policy assembly identity is Microsoft.VC90.DebugCRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8".
                INFO: Begin assembly probing.
                    INFO: Attempt to probe manifest at C:\Windows\WinSxS\manifests\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.21022.8_none_96748342450f6aa2.manifest.
                    INFO: Manifest found at C:\Windows\WinSxS\manifests\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.21022.8_none_96748342450f6aa2.manifest.
                INFO: End assembly probing.
    INFO: Resolving reference Microsoft.VC90.DebugCRT.mui,language="&#x2a;",processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8".
        INFO: Resolving reference for ProcessorArchitecture x86.
            INFO: Resolving reference for culture en-US.
                INFO: Applying Binding Policy.
                    INFO: No publisher policy found.
                    INFO: No binding policy redirect found.
                INFO: Begin assembly probing.
                    INFO: Did not find the assembly in WinSxS.
                    INFO: Attempt to probe manifest at C:\Windows\assembly\GAC_32\Microsoft.VC90.DebugCRT.mui\9.0.21022.8_en-US_1fc8b3b9a1e18e3b\Microsoft.VC90.DebugCRT.mui.DLL.
                    INFO: Did not find manifest for culture en-US.
                INFO: End assembly probing.
            INFO: Resolving reference for culture en.
                INFO: Applying Binding Policy.
                    INFO: No publisher policy found.
                    INFO: No binding policy redirect found.
                INFO: Begin assembly probing.
                    INFO: Did not find the assembly in WinSxS.
                    INFO: Attempt to probe manifest at C:\Windows\assembly\GAC_32\Microsoft.VC90.DebugCRT.mui\9.0.21022.8_en_1fc8b3b9a1e18e3b\Microsoft.VC90.DebugCRT.mui.DLL.
                    INFO: Did not find manifest for culture en.
                INFO: End assembly probing.
    INFO: Resolving reference Microsoft.VC90.DebugMFC,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8".
        INFO: Resolving reference for ProcessorArchitecture x86.
            INFO: Resolving reference for culture Neutral.
                INFO: Applying Binding Policy.
                    INFO: Find publisher policy at C:\Windows\WinSxS\manifests\x86_policy.9.0.microsoft.vc90.debugmfc_1fc8b3b9a1e18e3b_9.0.21022.8_none_37ea0b5cfc57dfad.manifest
                    INFO: Publisher Policy redirected assembly version.
                    INFO: Post policy assembly identity is Microsoft.VC90.DebugMFC,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8".
                INFO: Begin assembly probing.
                    INFO: Attempt to probe manifest at C:\Windows\WinSxS\manifests\x86_microsoft.vc90.debugmfc_1fc8b3b9a1e18e3b_9.0.21022.8_none_9b54853441e399d5.manifest.
                    INFO: Manifest found at C:\Windows\WinSxS\manifests\x86_microsoft.vc90.debugmfc_1fc8b3b9a1e18e3b_9.0.21022.8_none_9b54853441e399d5.manifest.
                INFO: End assembly probing.
    INFO: Resolving reference Microsoft.VC90.DebugMFC.mui,language="&#x2a;",processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8".
        INFO: Resolving reference for ProcessorArchitecture x86.
            INFO: Resolving reference for culture en-US.
                INFO: Applying Binding Policy.
                    INFO: No publisher policy found.
                    INFO: No binding policy redirect found.
                INFO: Begin assembly probing.
                    INFO: Did not find the assembly in WinSxS.
                    INFO: Attempt to probe manifest at C:\Windows\assembly\GAC_32\Microsoft.VC90.DebugMFC.mui\9.0.21022.8_en-US_1fc8b3b9a1e18e3b\Microsoft.VC90.DebugMFC.mui.DLL.
                    INFO: Did not find manifest for culture en-US.
                INFO: End assembly probing.
            INFO: Resolving reference for culture en.
                INFO: Applying Binding Policy.
                    INFO: No publisher policy found.
                    INFO: No binding policy redirect found.
                INFO: Begin assembly probing.
                    INFO: Did not find the assembly in WinSxS.
                    INFO: Attempt to probe manifest at C:\Windows\assembly\GAC_32\Microsoft.VC90.DebugMFC.mui\9.0.21022.8_en_1fc8b3b9a1e18e3b\Microsoft.VC90.DebugMFC.mui.DLL.
                    INFO: Did not find manifest for culture en.
                INFO: End assembly probing.
    INFO: Parsing Manifest File C:\Windows\WinSxS\manifests\x86_microsoft.windows.c..-controls.resources_6595b64144ccf1df_6.0.7600.16385_en-us_581cd2bf5825dde9.manifest.
        INFO: Manifest Definition Identity is Microsoft.Windows.Common-Controls.Resources,language="en-us",processorArchitecture="x86",publicKeyToken="6595b64144ccf1df",type="win32",version="6.0.7600.16385".
    INFO: Parsing Manifest File C:\Windows\WinSxS\manifests\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.21022.8_none_96748342450f6aa2.manifest.
        INFO: Manifest Definition Identity is Microsoft.VC90.DebugCRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8".
    INFO: Parsing Manifest File C:\Windows\WinSxS\manifests\x86_microsoft.vc90.debugmfc_1fc8b3b9a1e18e3b_9.0.21022.8_none_9b54853441e399d5.manifest.
        INFO: Manifest Definition Identity is Microsoft.VC90.DebugMFC,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8".
    INFO: Activation Context generation succeeded.
    End Activation Context Generation.

    Thursday, March 03, 2011 7:20 PM
  • Hi,

    Your question falls into the paid support category which requires a more in-depth level of support.  Please visit the below link to see the various paid support options that are available to better meet your needs.

    http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone

    Thanks!


    bill boyce
    Monday, March 07, 2011 7:35 PM
    Moderator
  • I've the same problem. Did you found a solution?
    Wednesday, July 13, 2011 8:12 AM
  • Hi,

    I am facing exactly the same problem. Please let me know if you have any solution to the above said problem


    Sumeet Bhatia --- [India]
    Friday, December 09, 2011 10:56 AM
  • This is a joke. I am having the same issue and this is a general question that would benefit developers.
    Tuesday, May 15, 2012 11:38 AM