在VB6清单中包含.NET程序集?

6
我正在处理一个VB6项目,并想创建一个清单文件,以便无需注册。我使用MMM(Make My Manifest)工具扫描VB6项目的dll依赖项并生成清单。然而,MMM不包括tlb文件,而我有一个Client.dll和Client.tlb文件,它们是用.NET编写的,并已公开到COM中,在我的VB6程序中使用。我不想使用Regasm,因为不需要向注册表注册。我尝试通过命令行中的mt工具为其生成单独的清单,'mt.exe -tlb:Client.tlb -dll:Client.dll -out:Client.manifest'。然后我想可以通过'mt.exe -manifest program.exe.manifest client.manifest -out:program.exe.manifest'合并两个清单。但是,当我运行程序时,我得到一个消息框,显示“Run-time error -2147220999(800401f9):Automation error,Error in the Dll”。我做的事情正确吗?是否有类似的经历?任何帮助都将不胜感激。

一个 [ComVisible] 的 .NET 程序集在清单中需要 <clrClass> 元素。VB6 工具不知道如何做到这一点。合并清单的最佳方法是使用文本编辑器。并且编写一个:http://msdn.microsoft.com/en-us/library/eew13bza%28v=VS.80%29.aspx - Hans Passant
1个回答

4
以下是关于如何使用UMMM的简短介绍:
  1. First, for the .Net dll it generates a manifest to a temp file with this

    mt.exe -nologo -managedassemblyname:"{dotnet_dll}" -nodependency -out:"{dotnet_dll}.manifest"
    
  2. Then embeds this manifest into .Net dll as RT_MANIFEST resource 2 with this

    mt.exe -nologo -manifest "{dotnet_dll}.manifest" -outputresource:"{dotnet_dll}";2
    
  3. Finally references the .Net dll from the VB6 executable by extracting assemblyIdentity tag from .Net dll manifest and adding it to the reg-free manifest inside dependency\dependentAssembly tag like this

    <dependency>
        <dependentAssembly>
            <assemblyIdentity name="PdfSigner" version="1.0.0.0" processorArchitecture="msil" />
        </dependentAssembly>
    </dependency>
    

这样,Hans提到的clrClass标签会出现在.Net dll嵌入的清单中而不是VB6可执行文件的清单中。


嗨wqw,现在program.exe清单似乎可以捕获Client.dll嵌入式清单。但是现在我会收到一个错误消息框,上面显示:运行时错误'-2146234341'(8013101b)自动化错误。所以我认为可能是client.dll代码相关的问题,但是当我对Client.dll进行regasm时,program.exe可以工作。com Client.dll使用和引用另外两个.net dlls,.A.dll和B.dll,它们也位于与program.exe相同的目录中。有什么想法吗? - ray_code
你是否将Client.dll所依赖的Net dll放在与VB6可执行文件相同的文件夹中?你遇到的错误几乎肯定是一个简单的路径查找错误。使用来自Windows7.1 SDK的fuslogvw.exe和sxstrace.exe进行故障排除。 - Dabblernl

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接