none
Can I put reg-free COM config in an app-domain config? RRS feed

  • Question

  • Hi there

    Could anyone help with the following ref-free COM problem, please?

    I have an unmanaged module which points IAppDomainSetup->ConfigurationFile to a file with the following contents and then uses the IAppDomainSetup to create an app-domain.

    <?xml version ="1.0"?>
    <configuration>
        <runtime>
            <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
                <dependentAssembly>
                    <assemblyIdentity type="win32" name="managed-dependency " version="1.0.0.0" />
                </dependentAssembly>
            </assemblyBinding>
        </runtime>
    </configuration>

    A managed module in the app-domain then uses an interop to unmanaged coclass. The managed dependency has the following manifest

    <?xml version="1.0" encoding="utf-8"?>
    <assembly xsi:schemaLocation="urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd" manifestVersion="1.0" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:co.v1="urn:schemas-microsoft-com:clickonce.v1" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <assemblyIdentity name="managed-dependency " version="1.0.0.0" type="win32" />
      <dependency>
        <dependentAssembly asmv2:dependencyType="install" asmv2:codebase="reg-free-comserver.dll.manifest " asmv2:size="787">
          <assemblyIdentity name="reg-free-comserver.dll " version="1.0.0.0" type="win32" />
          <hash xmlns="urn:schemas-microsoft-com:asm.v2">
            <dsig:Transforms>
              <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
            </dsig:Transforms>
            <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
            <dsig:DigestValue>LpJMG4ZBo5H1NxbG3JPaTyjcpAI=</dsig:DigestValue>
          </hash>
        </dependentAssembly>
      </dependency>
    </assembly>

    The unmanaged reg-free-comserver.dll.manifest file contains the following. It's very simple: just one coclass with one IDispatch registered for standard TLB marshalling.

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">

        <assemblyIdentity type = "win32" name = "reg-free-comserver.dll " version = "1.0.0.0" />

        <file name = "reg-free-comserver.dll ">
            <comClass clsid="{05F5B69B-B4E7-4500-94E5-8AA1533B44D5}" threadingModel = "Apartment" />
            <typelib tlbid="{BAE209E9-D942-4397-8806-FA93B54C2486}" version="1.0" helpdir=""/>
        </file>

        <comInterfaceExternalProxyStub
            name="IMyUnManagedInterface"
            iid="{2BAAAC04-7035-40DA-852D-35066FDE47CF}"
            proxyStubClsid32="{00020424-0000-0000-C000-000000000046}"
            baseInterface="{00000000-0000-0000-C000-000000000046}"
            tlbid="{BAE209E9-D942-4397-8806-FA93B54C2486}" />

    </assembly>

    The trace output tells me that reg-free-comserver.dll is in fact never loaded.

    Any advice greatly appreciated.
    Monday, November 23, 2009 4:00 PM

Answers

  • Hello

    There are four tools that are very useful to trouble-shoot reg-free and dll loading problems:

    1. Windows Event Log
    As the article says in the Trouble-shooting section
    http://msdn.microsoft.com/en-us/library/ms973913.aspx
    When troubleshooting registration-free COM issues, the Event Viewer on Windows Server 2003 is your friend. When Windows XP or Windows Server 2003 detects a configuration error it will typically show an error message box titled for the application you have launched and containing the message "This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem." I advise that whenever you see this message you reproduce the problem on Windows Server 2003, consult the System Event Log and look for events from the SideBySide source. The reason I don't suggest that you look at the Windows XP Event Log in these cases is that it will invariably contain a message such as "Generate Activation Context failed for [path]\[application filename].Manifest. Reference error message: The operation completed successfully," which doesn't help identify the problem.

    2. sxstrace
    If you get any sxs errors, please enable sxstrace to trace the process, and analyze the log file:
     SxsTrace Trace -logfile:SxsTrace.etl
     SxsTrace Parse -logfile:SxsTrace.etl -outfile:SxsTrace.txt

    3. Process Monitor.
    http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx
    You can use this tool to see where your process is looking for the dll. Do you see any NAME NOT FOUND errors in the procmon log? The error means that the process is looking for a file in the specified location, but could not find it.

    4. .NET Fusion Log
    http://msdn.microsoft.com/en-us/library/e74a18c4(VS.71).aspx

    Could you please use these tools to isolate this problem?

    You may also consider sending a simple test project that can reproduce the symptom to my mailbox: jialge@microsoft.com. I will help you do the analysis.




    Regards,
    Jialiang Ge
    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact msdnmg@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Tuesday, November 24, 2009 10:47 AM
    Moderator

All replies

  • Hello

    There are four tools that are very useful to trouble-shoot reg-free and dll loading problems:

    1. Windows Event Log
    As the article says in the Trouble-shooting section
    http://msdn.microsoft.com/en-us/library/ms973913.aspx
    When troubleshooting registration-free COM issues, the Event Viewer on Windows Server 2003 is your friend. When Windows XP or Windows Server 2003 detects a configuration error it will typically show an error message box titled for the application you have launched and containing the message "This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem." I advise that whenever you see this message you reproduce the problem on Windows Server 2003, consult the System Event Log and look for events from the SideBySide source. The reason I don't suggest that you look at the Windows XP Event Log in these cases is that it will invariably contain a message such as "Generate Activation Context failed for [path]\[application filename].Manifest. Reference error message: The operation completed successfully," which doesn't help identify the problem.

    2. sxstrace
    If you get any sxs errors, please enable sxstrace to trace the process, and analyze the log file:
     SxsTrace Trace -logfile:SxsTrace.etl
     SxsTrace Parse -logfile:SxsTrace.etl -outfile:SxsTrace.txt

    3. Process Monitor.
    http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx
    You can use this tool to see where your process is looking for the dll. Do you see any NAME NOT FOUND errors in the procmon log? The error means that the process is looking for a file in the specified location, but could not find it.

    4. .NET Fusion Log
    http://msdn.microsoft.com/en-us/library/e74a18c4(VS.71).aspx

    Could you please use these tools to isolate this problem?

    You may also consider sending a simple test project that can reproduce the symptom to my mailbox: jialge@microsoft.com. I will help you do the analysis.




    Regards,
    Jialiang Ge
    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact msdnmg@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Tuesday, November 24, 2009 10:47 AM
    Moderator
  • How are you, Massacrino?

    Do you get any progress in this issue?
    Regards,
    Jialiang Ge
    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact msdnmg@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, November 30, 2009 4:06 AM
    Moderator
  • not really. I'm struggling to find time at the moment

    the scenario has a few ingredients
    • Excel.exe uses
    • ExcelDNA, which starts the app-domain and loads
    • my .Net assembly which uses
    • a COM coclass (trivial coclass with one IDispatch)
    so getting the test project "right" wilkl require some attention to details

    In the meantime, so you know of any web page that has info about configuring reg-free COM for a DLL assembly, please?
    All the material I found around the web only speaks about configuring reg-free COM for EXEcutables, which you do not always have control over

    Seriously, just a little more documentation would help big time on this!

    Thanks!
    Tuesday, December 1, 2009 4:39 PM