在64位环境中使用32位汇编 [英] Use a 32-bit assembly in 64-bit environment

查看:432
本文介绍了在64位环境中使用32位汇编的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图整合DevIL.NET到3ds Max来自动转换我的图片到一个单一的格式。要做到这一点,我创建了一个类库在C#中,它接受一个字符串,返回新的文件路径

 公共静态类FileConverter
{
    公共静态字符串ConvertFile(字符串_sOriginal)
    {
        //加载该文件,保存文件,返回新的文件路径
    }
}
 

该项目引用到DevIL.NET,这是一个32位版本。我的应用程序是一个64位版本,并给出了 BadImageFormatException 。他说,它是不是有效的Win32应用程序。

我已经尝试通过增加一个额外的行中的 .csproj的文件,以使我的应用程序32位:< PlatformTarget> 86< / PlatformTarget> 。这样一来,我的测试项目做的工作,但我的类库不会,因为3ds Max的是一个64位应用程序。

这怎么可能行这些32-64问题了,让我的插件将工作?由于是3ds Max的将是64位和DevIL.NET将是32位。我似乎无法在64建DevIL.NET从源代码在VC ++中前preSS 2008位自己。

解决方案

您不能加载一个位数一个DLL插入运行的另一个位数的过程。你所能做的要解决的问题是对齐平台或在它自己的进程中运行的其他位数的DLL。

我不得不为接受插件的64位应用程序做一次。我创建了进入应用程序,并通过IPC跟一个32位进程64位垫片的DLL。这32位进程被要求由于第三方DLL还为32位。

这是在背面正确的痛苦,但不幸的是需要痛为其他厂商没有64位支持在那个时候。

您可以从64位垫片使用进程相关类在.NET控制这种其他32位进程 - 这其实是我落得这样做<。 / P>

I am trying to integrate DevIL.NET into 3ds Max to automatically convert my images to a single format. To do so, I created a class library in C# that accepts a string and returns the new file path

public static class FileConverter
{
    public static string ConvertFile(string _sOriginal)
    {
        // Load the file, save the file, return the new filepath
    }
}

The project is referencing to DevIL.NET, which is a 32-bit build. My application is a 64-bit build and gives a BadImageFormatException. Saying that "it" is not a valid Win32 application.

I have already tried to make my application 32-bit by adding an extra line in the .csproj file: <PlatformTarget>x86</PlatformTarget>. In this way, my test project does work, but my class library doesn't, because 3ds Max is a 64-bit application.

How is it possible to line these 32-64 problems up, so that my plugin will work? Given is that 3ds Max will be 64-bit and DevIL.NET will be 32-bit. I can't seem to build DevIL.NET in 64 bit myself from source in VC++ Express 2008.

解决方案

You cannot load a DLL of one "bitness" into a process running as another "bitness". All you can do to solve the problem is align the platforms or run the other "bitness" DLL in it's own process.

I had to do this once for a 64-bit application that accepted plug-ins. I created a 64-bit shim DLL that went into the application and talked to a 32-bit process via IPC. This 32-bit process was required due to a third-party DLL also being 32-bit.

It was a proper pain in the backside, but unfortunately a required pain as the other vendor didn't have 64-bit support at that time.

You can control this other 32-bit process from your 64-bit shim using the Process related classes in .NET - this is actually what I ended up doing.

这篇关于在64位环境中使用32位汇编的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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