473,396 Members | 1,683 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

PInvoke: super stuck on this one :0(

Just when I thought working with this unmanaged DLL could get any more
difficult.... I have to deal with this:
<exception>
{"An attempt was made to load a program with an incorrect format. (Exception
from HRESULT: 0x8007000B)"}
<exception>

Here is the sig. of the unmanaged DLL I'm trying to call:
<unmanaged code>
int MSP430_FET_FwUpdate(LPTSTR lpszFileName, MSP430_FET_NOTIFY_FUNC
callback, LONG clientHandle);
</unmanaged code>

The signature of the callback:
<callback>
typedef void (* MSP430_FET_NOTIFY_FUNC) (UINT MsgId, WPARAM wParam,
LPARAM lParam, LONG clientHandle);
</callback>
I researched how to deal with a callback using delegates and I think I have
that part correct ( I will post in a little later) Here is the signature
for my managed function:
<code>
public delegate void TIFETUpdateCallback(uint MsgId, uint wParam, int
lParam, int clientHandle);

[DllImport(@"C:\adt430\MSP430_DLL\Inc\MSP430_FET.h" )]
public static extern string MSP430_FET_FwUpdate( string lpszFileName,
TIFETUpdateCallback callback, int clientHandle);
</code>

I'm not sure what to pass to the last parameter. The comments in the
unmanaged h file say to pass a handle to the calling application, but I'm
calling this is a class library and am not sure what to pass to it.

And here is the code where I call the above function:
<code>
TIMSP430Driver.MSP430_FET_FwUpdate(string.Empty, new
TIFETUpdateCallback(UpdateCallback), 1);

public static void UpdateCallback(uint MsgId, uint wParam, int lParam,
int clientHandle)
{
// do something
int y = 4;
}
</code>

I'm in waaaaay over my head. Google isn't turning up anything for this
exception.

Does anyone see the problem here? Your help will be very much appreciated!

Thanks for reading,
Steve
Feb 28 '06 #1
3 2781
><exception>
{"An attempt was made to load a program with an incorrect format. (Exception
from HRESULT: 0x8007000B)"}
<exception> .... [DllImport(@"C:\adt430\MSP430_DLL\Inc\MSP430_FET.h" )]


The DllImport attribute should point to the executable DLL file
exporting the function, not the C++ header file where they are
declared.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Feb 28 '06 #2
Helpful little wiki http://pinvoke.net/

Feb 28 '06 #3
I'm sorry, that was a typo. It is indeed set to the dll filename.
"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:uP**************@TK2MSFTNGP10.phx.gbl...
<exception>
{"An attempt was made to load a program with an incorrect format.
(Exception
from HRESULT: 0x8007000B)"}
<exception>

...
[DllImport(@"C:\adt430\MSP430_DLL\Inc\MSP430_FET.h" )]


The DllImport attribute should point to the executable DLL file
exporting the function, not the C++ header file where they are
declared.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Feb 28 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Kerim Borchaev | last post by:
Hello! Always when I use "super" I create a code duplication because class used as first arg to "super" is always the class where the method containing "super" was defined in: ''' class C:...
2
by: Clarence Gardner | last post by:
The super object is considered a solution to the "diamond problem". However, it generally requires that the ultimate base class know that it is last in the method resolution order, and hence it...
11
by: Nicolas Lehuen | last post by:
Hi, I hope this is not a FAQ, but I have trouble understanding the behaviour of the super() built-in function. I've read the excellent book 'Python in a Nutshell' which explains this built-in...
0
by: Delaney, Timothy C (Timothy) | last post by:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/286195 This is a new version of super that automatically determines which method needs to be called based on the existing stack frames....
10
by: Chris Green | last post by:
Good day, I've done a bit of searching in the language reference and a couple pages referring the behavior of super() but I can't find any discussion of why super needs the name of the class as...
3
by: Brett Robichaud | last post by:
I have created a simple background thread to make one pinvoke call into a DLL I've created. My Winforms app spawns the thread in the form load event then go about it's business. The problem is...
5
by: vertigo | last post by:
Hello I use some win 32 API function for example: HANDLE CreateFile( LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD...
2
by: Chris Mellon | last post by:
I see super documented, and in use, as below (from the Python documentation) class C(B): def meth(self, arg): super(C, self).meth(arg) I'd like to not write C all the time, so is there any...
10
by: Martin Manns | last post by:
Hi, I have a class structure as follows and I would like to invoke the method A.m() from D.m class A(object): def m(self): class B(A): def m(self): class C(A):
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.