0

I have the following condition:

  • I have an ASP.NET application with .NET framework 4.5 running at Windows 8 64 bit environment
  • I have an external DLL library which I will need to use and that it will connect my system to another application locally.

I have tried the following:

  • down porting my application to .NET 3.5 and 4.0
  • call DLL library from a Singleton class, as well as static class
  • compile and debug my application using x86
  • testing to call the DLL from a Desktop, Web Service, or WCF applications

The problem is, the only successful way to call this DLL is by calling them either from Desktop, Webservices, or WCF applications. I can never call this DLL from my ASP.NET app no matter what condition I tried.

I always run into System.BadImageFormatException, saying that "Additional information: An attempt was made to load a program with an incorrect format . (Exception from HRESULT: 0x8007000B )"

Unfortunately I cannot put any further detail about this DLL. And having my ASP.NET application connected to WCF application runs into performance issues.

Any ideas?

P.S.: terribly sorry for my bad English. Any help would be appreciated.

EDIT:

I have seen the reference that has been given. Although, oddly enough, this reference didn't give any solution to my problem.

As I have mentioned before, I have tried to develop various test applications using x86 and x64 platforms, .NET framework 3.5, 4.0, and 4.5, and any other project type (Desktop app, WCF, except ASP.NET) can execute the DLL call.

Apparently, after a discussion with the author of the DLL, we conclude that only Desktop-like or Service-like applications can make calls to this type of DLL. My understanding was: "ASP.NET applications run within HTTP Context, which executes when user requests a resource" (I am sorry for my shallow understanding, but please correct me if I'm wrong..)

One questions remaining tho:

Is it considerably possible to generate a System.BadImageFormatException from this kind of case?

1 Answers1

0

Change in Visual Studio IDE, the Platform target from “X86 ” to “Any CPU”.

Refer to here Troubleshooting BadImageFormatException

Community
  • 1
  • 1
HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
  • Hello, thank you for your response. I already set it back to Any CPU but still no chance.. – Galih Dono Prabowo Mar 09 '15 at 14:23
  • @Galih Dono Prabowo:- external DLL support 64 bit env? – HaveNoDisplayName Mar 09 '15 at 14:25
  • Yes, I have tested it by calling it from both 32 and 64 bit app, either desktop, web services, or WCF application. But with ASP.NET is no luck. Is there any way to create a class in ASP.NET that resembles a desktop app class? such as a WIndow class? Or is this a bad practice? – Galih Dono Prabowo Mar 09 '15 at 14:34