方法可以从64位exe文件访问32位的DLL [英] Ways to access a 32bit DLL from a 64bit exe

查看:228
本文介绍了方法可以从64位exe文件访问32位的DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在64位模式下,必须编制了项目并运行。不幸的是,我需要在一个DLL,它仅在32位模式下可调用,所以没有办法,我可以容纳一切都在1 Visual Studio项目。我正在找换行32位的DLL在其自己的exe /服务,并发出远程(尽管在同一台机器上)调用该EXE /服务从我的64位应用程序的最佳途径。我的操作系统是Win7的专业版64位。

I have a project that must be compiled and run in 64 bit mode. Unfortunately, I am required to call upon a DLL that is only available in 32 bit mode, so there's no way I can house everything in a 1 Visual Studio project. I am working to find the best way to wrap the 32 bit DLL in its own exe/service and issue remote (although on the same machine) calls to that exe/service from my 64 bit app. My OS is Win7 Pro 64 bit.

所需调用该32位进程有几十每秒,但低数据量。这是一个实时的图像分析应用程序,以便响应时间,尽管低量的关键。大量发送/接收单语的。

The required calls to this 32 bit process are several dozen per second, but low data volume. This is a realtime image analysis application so response time is critical despite low volume. Lots of sending/receiving single primitives.

在理想情况下,我会举办一个WCF服务来容纳这个DLL,但在64位操作系统一个人不能强制服务为x86的运行! <一href="https://connect.microsoft.com/VisualStudio/feedback/details/349510/vs2008-incorrectly-launches-x64-version-of-wcfsvchost-for-x86-debugging#tabs">Source.这实在是不幸的,因为我计时功能调用WCF服务,只有4ms的我的机器上。

Ideally, I would host a WCF service to house this DLL, but in a 64 bit OS one cannot force the service to run as x86! Source. That is really unfortunate since I timed function calls to the WCF service to be only 4ms on my machine.

我已经尝试使用命名管道是.NET。我发现他们比WCF(不可用对我来说)。

I have experimented with named pipes is .net. I found them to be 40-50 times slower than WCF (unusable for me).

任何其它选项或建议最好的方式接近我的拼图?

Any other options or suggestions for the best way to approach my puzzle?

推荐答案

当你注意到,就没有办法混位数在同一过程中。你需要一个单独的进程为32位的部分。

As you correctly note, there is no way to mix bitness in the same process. You need a separate process for your 32-bit part.

我想举办一个WCF服务是正确的道路要走。您的链接只有wcfsvchost会谈。我是pretty的肯定,你可以创建自己的Windows服务,并主办了WCF服务的32位。

I think hosting a WCF Service is the right way to go. Your link only talks about wcfsvchost. I am pretty sure you can create your own Windows Service, and host the WCF service in that on 32 bit.

请参阅此链接:如何在托管应用程序承载WCF服务。您可以在任何托管应用托管服务,其中包括Windows服务,以及你喜欢的位数下运行它。

See this link: How to host a WCF service in a managed application. You can host your service in any managed application, including a Windows Service, and run it under the bitness you like.

这是code。在您的应用程序需要自托管的WCF服务的数量,假设你刚刚创建还增加了新的服务,称为为MyService,,并且适当配置的app.config:

This is the amount of code required to self-host a WCF service in your application, assuming you have just created a new service called MyService, and the appropiate configuration has been added to app.config:

class Program
{
    static void Main(string[] args)
    {
        using(ServiceHost host = new ServiceHost(typeof(MyService), new Uri[0]))
        {
            host.Open();
            Console.ReadKey();    
        }
    }
}

以上程序将运行一样好,如果你还明确其编译为32位或64位。

The above program will run just as well, also if you compile it explicitly as 32 or 64 bit.

这篇关于方法可以从64位exe文件访问32位的DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆