简体   繁体   English

64位平台上的COM

[英]COM on 64 Bit Platform

I'm using a 3rd party COM Library with C#, all works fine on 32 bit XP. 我正在使用带有C#的第三方COM库,所有在32位XP上都能正常工作。 I use tlbimp to create the wrapper, add a reference all works. 我用tlbimp来创建包装器,添加一个引用所有的工作。 However, when porting to our Server environment which is 64 bit Windows Server 2008, I've run into a road block. 但是,当移植到64位Windows Server 2008的服务器环境时,我遇到了障碍。

The code below only runs properly when I right click and test it, ie run within the VS environment. 当我右键单击并测试它时,下面的代码只能正常运行,即在VS环境中运行。 The code does not work when compiled to a Console App, nor does the code work in an Assembly whether in test or called from a console App. 编译到控制台应用程序时代码不起作用,无论是在测试中还是从控制台应用程序调用,代码也无法在程序集中工作。 In an attempt to get it working I'm running as Administrator and in a 32bit command window - still nothing grouper is always null, and no exception is thrown, indicating that GrpSvr.GrpCall is a valid Com Library name. 为了让它正常工作,我在管理员和32位命令窗口中运行 - 仍然没有任何分组器总是为空,并且没有抛出异常,表明GrpSvr.GrpCall是一个有效的Com库名称。

    string sMessage = "no grouper";
    GrpSvr.GrpCall grouper = Activator.CreateInstance(
        Type.GetTypeFromProgID("GrpSvr.GrpCall")) as GrpSvr.GrpCall;
    if (grouper != null)
        sMessage = grouper.GroupInit(@"C:\CmdGrp.txt", true, true);

    Console.WriteLine(sMessage);

Try using COM+ as host, and keep your application compiled for 64 bits. 尝试使用COM +作为主机,并将您的应用程序编译为64位。 For more info see this link 有关详细信息,请参阅此链接

It sounds like the 3rd party COM DLL is 32 bits only. 听起来第三方COM DLL只是32位。 You have to configure your app to run as 32 bits only, instead of any cpu. 您必须将应用程序配置为仅运行32位,而不是任何CPU。

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

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