473,500 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MarshalDirectiveException - Method's type signature is not PInvoke compatible

1 New Member
Hello,
I'm trying to retrieve a structure in C# from a C dll. Really to say I'm not an expert programmer on both C/C#, and will appreciate any comments and suggestions.
Here's a C dll coded structure, to be retrieved..
--
Expand|Select|Wrap|Line Numbers
  1. struct MESSAGEE 
  2. {
  3.       int               MsgNo;          
  4.       int               MsgType;       
  5.       char        MsgTypeText[64];
  6.       char        MsgNoText[64];  
  7.       char        MsgText[256];    
  8. };
--
the function to be connected to (C coded)
--
Expand|Select|Wrap|Line Numbers
  1. MESSAGEE*  Msg_Listing(
  2.             int         &nMsg,    
  3.             int         Type        
  4. )
--
My code in C# for the structure:
--
Expand|Select|Wrap|Line Numbers
  1.  [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
  2.         public struct MESSAGEE 
  3.         {
  4.             Int32 MsgNo;
  5.             Int32 MsgType;
  6.             [MarshalAs(UnmanagedType.LPStr, SizeConst = 64)]
  7.             string MsgTypeText;
  8.             [MarshalAs(UnmanagedType.LPStr, SizeConst = 64)]
  9.             string MsgNoText;
  10.             [MarshalAs(UnmanagedType.LPStr, SizeConst = 256)]
  11.             string MsgText;
  12.         }
--
And a DLL function calling :
--
Expand|Select|Wrap|Line Numbers
  1.         [DllImport("messagees.dll")] // Connection string
  2.         [return: MarshalAs(UnmanagedType.LPStruct)]
  3.         public static unsafe extern MESSAGEE Msg_Listing([Out]
  4.             Int32 nRules,    // # of defined rules
  5.             Int32 Type    // type of rule checking
  6.             );
--

Thanks a lot in advance!!
Jul 2 '09 #1
1 5713
KYAW KYAW OO
30 New Member
Hi,

I am also started facing this issue and please advise me if you manage to settle it.

I am looking forward to hearing from you soon.


Thanks in advance
Mar 19 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

31
2880
by: Chris S. | last post by:
Is there a purpose for using trailing and leading double underscores for built-in method names? My impression was that underscores are supposed to imply some sort of pseudo-privatization, but would...
19
1912
by: Dave Raskin | last post by:
public class Base { } public class Derived : Base { } public class Service {
5
2440
by: Simon Harris | last post by:
Hi All, I am trying to call a method in a web form, from an event fired in a user control. My user control displays a map, which has a link button to enlarge/shrink the map. When the user...
3
4087
by: Steve | last post by:
I'm trying to call some unmanaged methods from a DLL. I did this awhile ago, a couple years ago... I'm a little rusty. I will show you what I'm dealing with: <unmanaged function signature>...
4
5934
by: Zytan | last post by:
I have VB code that shows how to import a DLL function. I compiled it. I used .NET Reflector to see the C# code, and it shows this: private static extern bool MethodName( ref string...
9
5829
by: Steve Richter | last post by:
in a generic class, can I code the class so that I can call a static method of the generic class T? In the ConvertFrom method of the generic TypeConvert class I want to write, I have a call to...
0
1528
by: yadolov | last post by:
Hi! I have IDL-file: const byte DataStrLen = 255; #pragma pack(1) typedef struct { wchar_t fDataStr;
0
1298
by: emitojleyes | last post by:
Hi everyone! i'm new at this forum as well as programming in .net I have to develop a module that can use and configure a fingerprint detector; its documentation is written in C, as you will see...
2
2129
by: Tim Sprout | last post by:
The P/Invoke Interop Assistant (http://www.codeplex.com/clrinterop) generates a signature for GetDefaultPrinter using an uint type for pcchBuffer: public static extern bool GetDefaultPrinter( ...
0
7136
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
7018
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
7182
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
7397
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
5490
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,...
0
4611
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1430
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
672
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
316
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.