无法调用从ASP.NET的DLL [英] Unable to call the DLL from ASP.NET

查看:119
本文介绍了无法调用从ASP.NET的DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我有一个C DLL将与一个COBOL应用程序进行交互。我们想通过互联网发送数据到COBOL。



所以我创建了一个C#DLL将调用C DLL。其工作正常,当我做了consoleapp,但是当我试图调用从ASP.NET同一个DLL它给人的错误信息



我不明白,误差



 试图加载程序格式不正确。 (从HRESULT异常:0x8007000B)

有关于这一点,但那些其他一些职位不匹配我的上下文
I觉得我漏了权限的asp.net



这是调用我的C#DLL声明C DLL

 函数[DllImport(@C:\CCExpert\haz450cp.dll,入口点=方法名,CallingConvention = CallingConvention.Cdecl)] 
不安全的公共静态外部无效METHODNAME(参照p1,参照p2);



修改



您好我改变了根据您的建议,但我现在得到一个新的错误



设置

 微软的Visual Studio C运行时库已检测到W3WP一个致命的错误。 exe文件


解决方案

如果你有一个C .dll文件,它的马上就32位或64位。你必须确保你的网站是在正确的平台上运行(也就是你的网站正在作为一个匹配的六十四分之三十二位的网站。)



在IIS 7中,可以通过右键单击应用程序池,然后选择高级设置配置应用程序池的位数。有一个名为设置启用32位应用程序,您需要在设置为 32位的网站和< 。code>假 64位的网站



您可以使用的的Dependency Walker 来看看如果DLL是32位或64位:使用查看完整的路径(看起来像 C:\ 工具栏上的),如果您的.dll和依赖:




  • 如果您有一个32位操作系统,您的.dll可能是64位。您将无法加载它

  • 如果你有一个64位操作系统:

    • 如果依赖是System32下下,这是一个64位的.dll

    • 如果依赖是Syswow64资料下,这是一个32位的.dll




这将告诉您如何设置应用程序池。要设置应用程序池,您可以检查的此链接



请确保您使用高级设置当你打开应用程序池属性,没有基本设置。此外,当您打开属性为您的网站,这些设置不可用 - 他们仅可用于应用程序池


Hi I have a C Dll which will interact with a cobol application. we want to send the data to the cobol through internet.

so i created an C# DLL which will call the C DLL. its working fine when i do a consoleapp, but when i try to call the same DLL from ASP.NET its giving error message

i dont understand that error

An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

There are some other posts regarding this but those were not matching my context i think im missing permissions for asp.net

this is the declaration in my c# dll for calling c dll

[DllImport(@"C:\CCExpert\haz450cp.dll", EntryPoint = "Methodname", CallingConvention = CallingConvention.Cdecl)]
    unsafe public static extern void Methodname(ref p1, ref p2);

Edit:

Hi i changed the settings according to your suggestions but now im getting a new error

Microsoft Visual Studio C Runtime Library has detected a fatal error in w3wp.exe

解决方案

If you have a C .dll, it'll be either 32-bit or 64-bit. You must make sure that your site is running in the correct platform for that (that is, your site is running as a matching 32/64-bit site.)

In IIS 7, you can configure the bitness of the application pool by right-clicking the app pool and selecting Advanced Settings. There's a setting called Enable 32-bit applications, you need to set that to True for 32-bit sites and False for 64-bit sites.

You can use Dependency Walker to see if the DLL is 32-bit or 64-bit: use View full paths (looks like C:\ on the toolbar) and if the dependencies of your .dll and:

  • If you have a 32-bit OS, your .dll may be 64-bit. You won't be able to load it.
  • If you have a 64-bit OS:
    • If the dependencies are under System32, it's a 64-bit .dll
    • If the dependencies are under SysWOW64, it's a 32-bit .dll

That tells you how to set the application pool. To set the app pool you can check this link.

Make sure you use Advanced Settings when you open the app pool properties, not basic settings. Also, these settings are not available when you bring up properties for your site - they are only available for the app pool.

这篇关于无法调用从ASP.NET的DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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