如何根据平台加载DLL [英] How according to platform load the Dll

查看:86
本文介绍了如何根据平台加载DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个32bit和64bit的dll,现在我希望我的exe根据解决方案平台从dll调用,这意味着在设置x64时将调用64bit的dll.为此,我声明一个函数Ge​​tPlatform().

I have a dll for 32bit and 64bit and now I want that my exe call the dll from according to solution platform,means when x64 is set then the dll of 64bit will call.For this I declare a function GetPlatform().

Public Function GetPlateform() As String

        Dim var1 As String
        If (IntPtr.Size = "8") Then
            var1 = "hellox64"
        Else
            var1 = "hello"
        End If
        Return var1
    End Function



并且当表单加载时
此var1分配给var.




and when the form load
this var1 is assign to var.


Public Declare Function function1 Lib "var" (ByVal Id As Integer) As Integer




但是,当我调试代码时,会出现"DllNotFoundException"代码.
注意:该dll位于vc ++中.




But When I debug the code "DllNotFoundException" is ocuured.
NOTE:The dll is in vc++.

推荐答案

为什么要执行此操作,因为它不起作用. dll将在其主机的相同上下文中运行.这意味着,如果您的应用程序的32位版本在64位计算机上运行,​​则将需要32位dll,因为该进程以32位运行.您不能只是将不同的32位和64位程序集混合在一起.无需自己弄清楚这一点,否则只会使事情变得更难.

祝你好运!
Why would you want to do this because it won''t work. The dll will run in the same context of its host. This means that if the 32bit version of your application is running on a 64bit machine, it would need th 32bit dll because the process is running in 32bit. You can''t just mix different 32 and 64bit assemblies together. There is no need to figure this out yourself and would only make things harder otherwise.

Good luck!


这篇关于如何根据平台加载DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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