Solved

BadImageFormatException

Posted on 2009-07-14
2
543 Views
Last Modified: 2013-12-17
I am creating a c# program using a dll called GlobalVariable.dll in windows\system32.
I gave me an exception when I using a function within a dll. Can anyone tell me if there is more I need to setup the environment or tips how to resolve this problem. The code is the wrapper code the dll. The attachment is the snapshot during debugging.
using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Runtime.InteropServices;
 

namespace TSGlobalVariables

{

    public class TS

    {

        [DllImport("GlobalVariable.dll", EntryPoint = "GV_SetInteger")]

        public static extern int GV_SetInteger(int iLocation, int iVal);

        [DllImport("GlobalVariable.dll", EntryPoint = "GV_GetInteger")]

        public static extern int GV_GetInteger(int iLocation);

        [DllImport("GlobalVariable.dll", EntryPoint = "GV_SetDouble")]

        public static extern int GV_SetDouble(int iLocation, double dVal);

        [DllImport("GlobalVariable.dll", EntryPoint = "GV_GetDouble")]

        public static extern double GV_GetDouble(int iLocation);

    }

}

Open in new window

BadImageFormatException.jpg
0
Comment
Question by:xewoox
2 Comments
 
LVL 33

Accepted Solution

by:
Todd Gerbert earned 500 total points
ID: 24849317
The error message would seem to suggest your DLL is not really a DLL (or is a 64-bit DLL on a 32-bit system, or vice versa).

I Googled "BadImageFormatException" and first on the results list:

http://msdn.microsoft.com/en-us/library/system.badimageformatexception.aspx
This exception is thrown when the file format of a dynamic link library (.dll file) or an executable (.exe file) does not conform to the format that is expected by the common language runtime.
0
 

Author Closing Comment

by:xewoox
ID: 31603239
Good answer, right to the point.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now