简体   繁体   English

如何处理与 VB6 ActiveX dll 的对话,该 ActiveX dll 具有来自 .NET Z3055DD731D7924089A62F3 的 OCX 依赖项

[英]How to handle talking to VB6 ActiveX dll that has OCX dependencies from a .NET WPF application

I have a VB6 ActiveX dll that has a dependency on ComDlg32.ocx.我有一个依赖于 ComDlg32.ocx 的 VB6 ActiveX dll。 This ActiveX dll is called from a .NET application.此 ActiveX dll 是从 .NET 应用程序调用的。 The ActiveX dll has a public interface that has 1 method, which opens a form, which opens an Open File dialog (from ComDlg32.ocx). ActiveX dll 有一个公共接口,该接口有一个方法,它打开一个表单,打开一个打开文件对话框(来自 ComDlg32.ocx)。 The .NET application has a button which will call this ActiveX dll method. .NET 应用程序有一个按钮,它将调用此 ActiveX dll 方法。

This all works when the ComDlg32.ocx and the ActiveX dll are both registered (via regsvr32), but I need to get this to work using RegFree COM, at least for the dependencies of the ActiveX dll.当 ComDlg32.ocx 和 ActiveX dll 都注册(通过 regsvr32)时,这一切都有效,但我需要使用 RegFree COM 让它工作,至少对于 ActiveX Z0641ZAF16233FEEC48CZ 的依赖项I have made a manifest file for this ActiveX dll but it doesn't seem to be getting read.我已经为这个 ActiveX dll 制作了一个清单文件,但它似乎没有被读取。 ProcMon had no reference to the manifest file and sxstrace gave me no info (literally a blank text file when I parsed the etl file). ProcMon 没有参考清单文件,并且 sxstrace 没有给我任何信息(当我解析 etl 文件时,实际上是一个空白文本文件)。

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
    <assemblyIdentity name="DeployArchitectureTest" version="1.0.0.0" type="win32" processorArchitecture="x86"/>
    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
        <security>
            <requestedPrivileges>
                <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
            </requestedPrivileges>
        </security>
    </trustInfo>
    <file name="COMDLG32.OCX">
        <typelib tlbid="{F9043C88-F6F2-101A-A3C9-08002B2F49FB}" version="1.2" flags="control,hasdiskimage" helpdir="" />
        <comClass clsid="{F9043C85-F6F2-101A-A3C9-08002B2F49FB}" tlbid="{F9043C88-F6F2-101A-A3C9-08002B2F49FB}" progid="MSComDlg.CommonDialog.1" threadingModel="Apartment" miscStatus="" miscStatusContent="recomposeonresize,onlyiconic,cantlinkinside,insideout,activatewhenvisible,invisibleatruntime,setclientsitefirst">
            <progid>MSComDlg.CommonDialog</progid>
        </comClass>
    </file>
</assembly>

I have tried an external manifest for the dll as well as embedding the manifest but still no luck.我已经尝试了 dll 的外部清单以及嵌入清单,但仍然没有运气。 I must be missing something but all the information I can find talks about how to create a manifest file for an exe but no info about how to handle an ActiveX dll that has its own dependencies.我一定遗漏了一些东西,但我能找到的所有信息都是关于如何为 exe 创建清单文件,但没有关于如何处理具有自己依赖关系的 ActiveX dll 的信息。

If anyone has any information then I would really appreciate it.如果有人有任何信息,那么我将不胜感激。

After some more research and being pointed in the right direction by @SimonMourier and @HansPassant, I managed to get this working.经过更多的研究并被@SimonMourier 和@HansPassant 指出了正确的方向,我设法让这个工作正常进行。

I thought that a dll manifest would have been possible if I was using the resource ID #2 as @HansPassant mentioned, but I wasn't able to get it to work that way.我认为如果我使用@HansPassant 提到的资源 ID #2,则可以使用 dll 清单,但我无法让它以这种方式工作。 No matter what I did, the dll manifest never seemed to be read.无论我做什么,dll 清单似乎从未被阅读过。

I did however find that including all of the manifest data from what was the dll manifest into the exe manifest and making sure the exe had no embedded manifest allowed RegFree COM to work as expected.但是,我确实发现将 dll 清单中的所有清单数据包含到 exe 清单中,并确保 exe 没有嵌入式清单允许 RegFree COM 按预期工作。 I was finding that Visual Studio was building my .NET exe with an embedded manifest, even though there was an app.manifest file as part of the project.我发现 Visual Studio 正在使用嵌入式清单构建我的 .NET exe,即使项目中有一个 app.manifest 文件。 I had to set the COM dll as 'isolated=true' in order for the manifest to be built as external.我必须将 COM dll 设置为“isolated=true”,以便将清单构建为外部。

So thank you both @SimonMourier and @HansPassant, both of your comments led me down the right path to figure it out.因此,感谢@SimonMourier 和@HansPassant,您的两条评论都让我找到了正确的解决方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM