473,387 Members | 1,745 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,387 software developers and data experts.

Error, probably something wrong with dllimport & call signature

Can anybody help me by checking if I have correct call signatures?
In my C# Windows Form project (VS2008) I am using dll which has been
written for Visual C++ 6.0:

This function code is used to start receive active message of ioLogik
2000 Ethernet Module:

C/C++
int Message2K_Start(  int iProtocol, WORD wPort, pfnCALLBACK&
iProcAddress);
Callback Function
void FunctionName( BYTE bytData[], WORD wSize );
Arguments:

iProtocol : Transmission protocol. 1: TCP 2: UDP
wPort :TCP or UDP port number.
iProcAddress : Callback function, which is called after receive an
active message form ioLogik 2000 Ethernet module.
bytData : An array that stores the message.
wSize : Array size.
Normally in VS C++ I would do like this:

void CALLBACK getUdpMessage( BYTE data[], WORD wSize ); //UDP call
back function
//****************************
// start TCP active message
//****************************
Message2K_Start( PROTOCOL_TCP, 9000, getTcpMessage ); //where: tcp,
port, call back function
Using C#
I have converted this to:

private static extern int Message2K_Start( int iProtocol, int wPort,
CallbackDelegate iProcAddress);
//The signature for the callback method
public delegate void CallbackDelegate(byte [] data, int size);
CallbackDelegate delLine = new CallbackDelegate(getTcpMessage);
//defined call back function:
public static void getTcpMessage( byte [] data, int wSize)
{
wasIcalled = true;
}
and in the code I call:
Message2K_Start(1, 9000, getTcpMessage);

but it return error: "The error occured when the Windows system
couldn't initialized Socket"
Did I make a correct call signatures in C#?
Sep 10 '08 #1
0 1136

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

Similar topics

1
by: Wayno | last post by:
My php logs are coming up empty. I have done all I can think of, and all that made sense to me. Can someone take a look at my php.ini please and tell me what you think may be the problem. I...
67
by: Steven T. Hatton | last post by:
Some people have suggested the desire for code completion and refined edit-time error detection are an indication of incompetence on the part of the programmer who wants such features. ...
8
by: Hasani | last post by:
OK, I'm trying to programmatically create an Access database/mdb file but CreateDb(string) always returns false. I don't know what I'm doing wrong, is it my extern signature? Thx in advance ...
2
by: Kurt Ng | last post by:
Hi, y'all. Can anyone help me on this problem? I'm working with a third-party C dll, and I'm having trouble importing into C# the dll's methods that return one of the dll's defined types,...
9
by: Tyler | last post by:
I am attempting to extend a legacy VB6 application by making it use a .NET component written in C# exposed through COM interop. Everything appeared to be going well (VB application creates the...
3
by: B Vidyadhar Joshi | last post by:
I was writing an Bluetooth Application which makes calls to Windows APIs. I feel I'm doing something wrong with the structure. Could somebody help me? The code that I'm using is pasted below: ...
6
by: Ken | last post by:
When running a program in the debugger, what would cause it to crash without any error messages? I get "The program has exited with code 0 (0x0)". The program is a MDI app with threading for...
2
by: DazedAndConfused | last post by:
I converted a C# example of using dll crypt32 to VB .NET. The converted example fails when Encypting/Decypting. I found that if instead of defining a variable as and setting the values for...
4
by: Steve Richter | last post by:
I have a C++ forms project that I am adding some unmanaged code to. I have a member function of the Form1 class that returns a String^ holding the text of the last win32 error. The code is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.