Re: delegate problem
From: Shakir Hussain (shak_at_fakedomain.com)
Date: 06/29/04
- Next message: Michael A. Covington: "Re: turbo c application (dos) -> .NET"
- Previous message: Mark Broadbent: "Re: Referencing assemblies and .config files."
- In reply to: [Yosi]: "delegate problem"
- Next in thread: [Yosi]: "Re: delegate problem"
- Reply: [Yosi]: "Re: delegate problem"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 29 Jun 2004 09:52:11 -0500
Try
[MarshalAs(UnmanagedType.ByValArray)]
in the char [] argument.
--
Shak
(Houston)
"[Yosi]" <Yosi@discussions.microsoft.com> wrote in message
news:1F85E2BD-6025-4B16-BEB2-3DE9683503ED@microsoft.com...
> Hi,
> I have a DLL file which include loop back function, this function get as
parameter a reference to my error function to be called when an error will
occur.
> But I got an exception during my calling to 'SetCallbackDll' function :
> "Can not marshal parameter #1: Ansi char arrays can not be marshaled as
byref or as an unmanaged-to-managed parameter."
>
> What's wrong / how to do that correctly???
>
>
> Loop back function prototype as following:
>
> void SetCallbackDll (PointerToFunction _referMethod) ;
>
> I create a delegate as following :
> public delegate void PointerToFunction(char [] ErrorString, int ErrorNum);
>
> then call the loopback function :
> [DllImport("RW_DLL.dll")]
> extern static void SetCallbackDll (PointerToFunction _referMethod) ;
>
> public void myErrorHandler(char [] ErrorString, int ErrorNum)
> {
> MessageBox.Show("Error",
"Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
> }
> private void setHandler()
> {
> try
> {
> SetCallbackDll(new PointerToFunction(this.errorH));
> }
> catch()...
>
>
> Regards,
> Yosef
>
>
- Next message: Michael A. Covington: "Re: turbo c application (dos) -> .NET"
- Previous message: Mark Broadbent: "Re: Referencing assemblies and .config files."
- In reply to: [Yosi]: "delegate problem"
- Next in thread: [Yosi]: "Re: delegate problem"
- Reply: [Yosi]: "Re: delegate problem"
- Messages sorted by: [ date ] [ thread ]