Re: calling from c# into a dll
From: Al the programmer (Altheprogrammer_at_discussions.microsoft.com)
Date: 03/18/05
- Next message: BC: "Re: Display base64 image in web application"
- Previous message: jez123456: "Re: Adding to Array"
- In reply to: Willy Denoyette [MVP]: "Re: calling from c# into a dll"
- Next in thread: Willy Denoyette [MVP]: "Re: calling from c# into a dll"
- Reply: Willy Denoyette [MVP]: "Re: calling from c# into a dll"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 18 Mar 2005 06:19:11 -0800
Thanks for the info. I remember the mangling issue from when I had to call C
code from C++, but the C# docs are silent on the issue.
What do I do when I want to export a C++ class in a dll to a C# program?
Al
"Willy Denoyette [MVP]" wrote:
> Make sure the exported C function is not mangled (has C linkage), make also
> sure the calling convention is cdecl (CallingConvention.Cdecl)]).
>
> Willy.
>
> "Al the programmer" <Altheprogrammer@discussions.microsoft.com> wrote in
> message news:1466DA50-01F4-4B7A-9324-C81AD4A5417D@microsoft.com...
> >I have a dll that consists of unmanaged C++ routines. I can call a
> >function
> > in the dll from a C++ executable, but not from a C# executable. I am
> > calling
> > an independent function, not a class. C# gives me a runtime exception
> > saying
> > the entry point to the dll cannot be found.
> >
> > I declare the function in C# with the following lines:
> > [DllImport("simpleDLL.dll", CallingConvention=CallingConvention.Cdecl)]
> > public static extern int fnsimpleDLL(int i);
> >
> > I then call the function with the line:
> > fnsimpleDLL(1);
> >
> > Any ideas?
>
>
>
- Next message: BC: "Re: Display base64 image in web application"
- Previous message: jez123456: "Re: Adding to Array"
- In reply to: Willy Denoyette [MVP]: "Re: calling from c# into a dll"
- Next in thread: Willy Denoyette [MVP]: "Re: calling from c# into a dll"
- Reply: Willy Denoyette [MVP]: "Re: calling from c# into a dll"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|