Re: DllImport into C#
From: Tim Mulholland (TimMulholland_at_nospamaddress.com)
Date: 02/12/04
- Next message: Mike G: "Re: Excel won't Close - Common issue with a twist"
- Previous message: Travis Butynski: "Re: Calling Still Image API in C#"
- In reply to: Tim Mulholland: "Re: DllImport into C#"
- Next in thread: Mattias Sjögren: "Re: DllImport into C#"
- Reply: Mattias Sjögren: "Re: DllImport into C#"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 12 Feb 2004 13:04:29 -0500
n/m, i found what the CallingConvention thing was. i declare mine with
__declspec(dllexport)
which one should i be using? They all seem to do the same thing (throw that
exception)
"Tim Mulholland" <TimMulholland@nospamaddress.com> wrote in message
news:%231tFQHZ8DHA.2472@TK2MSFTNGP10.phx.gbl...
> It was your post i was referring to, so thanks for responding.
> What do you mena you had to specify the calling convention in the
DllImport
> statement?
>
> I'm still very stumped about why i get an exception when i don't debug the
> unmanaged code, but no exception when i do...
>
> "Ted Sung" <teds@intex.com> wrote in message
> news:86dea8f5.0402120907.35005268@posting.google.com...
> > I was able to get something similar to work by using StringBuilder:
> >
> > .. FuncA( StringBuilder string ParamA ) ;
> >
> > It seems that the DllImport's default char set is ANSI so StringBuilder
> > marshals the parameter correctly. Also, my C function was declared
> > as CDECL and I had to specify the calling convention in the DllImport
> statement.
> >
> > Ted
> >
> >
> > "Tim Mulholland" <TimMulholland@nospamaddress.com> wrote in message
> news:<uBBLODM8DHA.3804@tk2msftngp13.phx.gbl>...
> > > just so you know, what i'm trying is
> > >
> > > [DllImport("MyDll.dll", EntryPoint="FuncA")]
> > > private static extern IntPtr FuncA([MarshalAs(UnmanagedType.LPStr)]
> string
> > > ParamA);
> > >
> > > as per something i saw a little bit below in the Interop NG.. but i'm
> > > getting a NullReferenceException when i make the calls to that
function
> and
> > > i'm wondering if its because of how i'm declaring it.
> > >
> > > "Tim Mulholland" <TimMulholland@nospamaddress.com> wrote in message
> > > news:%23K6vz5L8DHA.2540@TK2MSFTNGP11.phx.gbl...
> > > > Whats the correct C# datatype (or marshalling function or something)
> to
> > > use
> > > > when you're importing a function that has a signature similar to
> > > >
> > > > char* FuncA(char c[])
> > > >
> > > > ?
> > > >
> > > > Assuming you know that both the parameter for the function and the
> return
> > > > value are c-style strings?
> > > >
> > > > Thanks in advance!
> > > >
> > > > Tim
> > > >
> > > >
>
>
- Next message: Mike G: "Re: Excel won't Close - Common issue with a twist"
- Previous message: Travis Butynski: "Re: Calling Still Image API in C#"
- In reply to: Tim Mulholland: "Re: DllImport into C#"
- Next in thread: Mattias Sjögren: "Re: DllImport into C#"
- Reply: Mattias Sjögren: "Re: DllImport into C#"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|