PC Review


Reply
Thread Tools Rate Thread

C libraries in C#

 
 
=?Utf-8?B?TmF2ZWVuIE11a2tlbGxp?=
Guest
Posts: n/a
 
      18th Aug 2004
Hi,
I am a student and new to .NET Compact Framework,Visual Studio.NET.
I am using .NET Compact Framework and Visual C#.NET for my project.
I have to use some C runtime DLLs in my project, but I have no idea
how this can be done. I mean, using C SDK and C runtime DLLs in
C# smart device applications template.
Can any one let me know wheather it( using C SDK and C runtime DLLs in C#
smart device application ) is possible or not.

If we can do this kindly let me know the procedure.

Thank you,

Naveen.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?YXduaQ==?=
Guest
Posts: n/a
 
      18th Aug 2004
check MSDN for
System.Runtime.InteropServices

awni

"Naveen Mukkelli" wrote:

> Hi,
> I am a student and new to .NET Compact Framework,Visual Studio.NET.
> I am using .NET Compact Framework and Visual C#.NET for my project.
> I have to use some C runtime DLLs in my project, but I have no idea
> how this can be done. I mean, using C SDK and C runtime DLLs in
> C# smart device applications template.
> Can any one let me know wheather it( using C SDK and C runtime DLLs in C#
> smart device application ) is possible or not.
>
> If we can do this kindly let me know the procedure.
>
> Thank you,
>
> Naveen.

 
Reply With Quote
 
Steve Maillet \(eMVP\)
Guest
Posts: n/a
 
      18th Aug 2004
In particular search for "dll import" or "PInvoke"

--
Steve Maillet
EmbeddedFusion
www.EmbeddedFusion.com

Do have an opinion on the effectiveness of Microsoft Windows Mobile and
Embedded newsgroups? Let us know!
https://www.windowsembeddedeval.com/...ity/newsgroups


 
Reply With Quote
 
=?Utf-8?B?TmF2ZWVuIE11a2tlbGxp?=
Guest
Posts: n/a
 
      24th Aug 2004
Hi Steve,

Thank you for your response.
I when I tried a samle program, I got "Missing method exception" in my
PDA.

I am wondering are we supposed to install and register the "DLL" in PDA.

Kindly let me know.

Cheers,

Naveen

"Steve Maillet (eMVP)" wrote:

> In particular search for "dll import" or "PInvoke"
>
> --
> Steve Maillet
> EmbeddedFusion
> www.EmbeddedFusion.com
>
> Do have an opinion on the effectiveness of Microsoft Windows Mobile and
> Embedded newsgroups? Let us know!
> https://www.windowsembeddedeval.com/...ity/newsgroups
>
>
>

 
Reply With Quote
 
=?Utf-8?B?TmF2ZWVuIE11a2tlbGxp?=
Guest
Posts: n/a
 
      24th Aug 2004
Hi Awni,

Thank you for your response.
I when I tried a samle program, I got "Missing method exception" in my
PDA.

I am wondering are we supposed to install and register the "DLL" in PDA.

Kindly let me know.

Cheers,

Naveen


"awni" wrote:

> check MSDN for
> System.Runtime.InteropServices
>
> awni
>
> "Naveen Mukkelli" wrote:
>
> > Hi,
> > I am a student and new to .NET Compact Framework,Visual Studio.NET.
> > I am using .NET Compact Framework and Visual C#.NET for my project.
> > I have to use some C runtime DLLs in my project, but I have no idea
> > how this can be done. I mean, using C SDK and C runtime DLLs in
> > C# smart device applications template.
> > Can any one let me know wheather it( using C SDK and C runtime DLLs in C#
> > smart device application ) is possible or not.
> >
> > If we can do this kindly let me know the procedure.
> >
> > Thank you,
> >
> > Naveen.

 
Reply With Quote
 
Paul G. Tobey [eMVP]
Guest
Posts: n/a
 
      24th Aug 2004
You don't have to register anything, but you should make sure that you are
compiling the exported functions in the DLL as C functions, not C++. C++,
as you certainly must know, changes the exported names of functions so that
their parameter and return types are part of their name. This allows
overloading of functions, since you can distinguish between int A( float b )
and int A( long b ) by the mangled function name, but it also makes it
harder to call from systems where you have to know the actual exported name.
The depends.exe tool will show you the actual exported names from a DLL and
you should be able to use this tool to see if what you are telling your C#
code to call is actually what the DLL is exporting...

Paul T.

"Naveen Mukkelli" <(E-Mail Removed)> wrote in
message news:33E6561E-25BB-4AD6-94F1-(E-Mail Removed)...
> Hi Steve,
>
> Thank you for your response.
> I when I tried a samle program, I got "Missing method exception" in my
> PDA.
>
> I am wondering are we supposed to install and register the "DLL" in PDA.
>
> Kindly let me know.
>
> Cheers,
>
> Naveen
>
> "Steve Maillet (eMVP)" wrote:
>
>> In particular search for "dll import" or "PInvoke"
>>
>> --
>> Steve Maillet
>> EmbeddedFusion
>> www.EmbeddedFusion.com
>>
>> Do have an opinion on the effectiveness of Microsoft Windows Mobile and
>> Embedded newsgroups? Let us know!
>> https://www.windowsembeddedeval.com/...ity/newsgroups
>>
>>
>>



 
Reply With Quote
 
=?Utf-8?B?TmF2ZWVuIE11a2tlbGxp?=
Guest
Posts: n/a
 
      25th Aug 2004
Hi Paul,

Thank you very much for your reply.
As I am a starter, I couldn't understand

> " but you should make sure that you are
> compiling the exported functions in the DLL as C functions, not C++. "


I have a C run time DLL( third party), I need to access the C methods in
this DLL. What I have done is
I have written a sample code which access a method called Connect in the dll.

[ DllImport (" blah.dll")]
private static extern void Connect ();

Then I compiled the code using "Build"
but when I deployed it on my PDA, it is giving "MissingMethod" exception.

Am I doing right thing?. if not, kindly let me know what I need to change.
do I need to change any settings in Visual Studio.NET 2003.

I got the same problem when I tried the following sample code from the
internet

using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;

public class Win32
{
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int MessageBox(int hWnd, string text,
string caption, uint type);
}

public class HelloWorld
{
public static void Main()
{
Win32.MessageBox(0, "Hello World", "Platform InvokeSample", 0);
}
}


Thank you,

Naveen.

"Paul G. Tobey [eMVP]" wrote:

> You don't have to register anything, but you should make sure that you are
> compiling the exported functions in the DLL as C functions, not C++. C++,
> as you certainly must know, changes the exported names of functions so that
> their parameter and return types are part of their name. This allows
> overloading of functions, since you can distinguish between int A( float b )
> and int A( long b ) by the mangled function name, but it also makes it
> harder to call from systems where you have to know the actual exported name.
> The depends.exe tool will show you the actual exported names from a DLL and
> you should be able to use this tool to see if what you are telling your C#
> code to call is actually what the DLL is exporting...
>
> Paul T.
>
> "Naveen Mukkelli" <(E-Mail Removed)> wrote in
> message news:33E6561E-25BB-4AD6-94F1-(E-Mail Removed)...
> > Hi Steve,
> >
> > Thank you for your response.
> > I when I tried a samle program, I got "Missing method exception" in my
> > PDA.
> >
> > I am wondering are we supposed to install and register the "DLL" in PDA.
> >
> > Kindly let me know.
> >
> > Cheers,
> >
> > Naveen
> >
> > "Steve Maillet (eMVP)" wrote:
> >
> >> In particular search for "dll import" or "PInvoke"
> >>
> >> --
> >> Steve Maillet
> >> EmbeddedFusion
> >> www.EmbeddedFusion.com
> >>
> >> Do have an opinion on the effectiveness of Microsoft Windows Mobile and
> >> Embedded newsgroups? Let us know!
> >> https://www.windowsembeddedeval.com/...ity/newsgroups
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
Paul G. Tobey [eMVP]
Guest
Posts: n/a
 
      25th Aug 2004
You need to learn the items that I mentioned in order to solve your problem.
You are sure that this third party compiled the DLL with C and not C++? I
didn't think so. If it *was* compiled with C++, there is no exported
function called Connect, so your code can't find it. You need to verify
that it is exporting the method with exactly that name. The depends.exe
tool, as I mentioned, will show you the exports.

Paul T.

"Naveen Mukkelli" <(E-Mail Removed)> wrote in
message news:C2B730F5-2518-4174-94C7-(E-Mail Removed)...
> Hi Paul,
>
> Thank you very much for your reply.
> As I am a starter, I couldn't understand
>
>> " but you should make sure that you are
>> compiling the exported functions in the DLL as C functions, not C++. "

>
> I have a C run time DLL( third party), I need to access the C methods in
> this DLL. What I have done is
> I have written a sample code which access a method called Connect in the
> dll.
>
> [ DllImport (" blah.dll")]
> private static extern void Connect ();
>
> Then I compiled the code using "Build"
> but when I deployed it on my PDA, it is giving "MissingMethod" exception.
>
> Am I doing right thing?. if not, kindly let me know what I need to change.
> do I need to change any settings in Visual Studio.NET 2003.
>
> I got the same problem when I tried the following sample code from the
> internet
>
> using System.Windows.Forms;
> using System.Data;
> using System.Runtime.InteropServices;
>
> public class Win32
> {
> [DllImport("user32.dll", CharSet=CharSet.Auto)]
> public static extern int MessageBox(int hWnd, string text,
> string caption, uint type);
> }
>
> public class HelloWorld
> {
> public static void Main()
> {
> Win32.MessageBox(0, "Hello World", "Platform InvokeSample", 0);
> }
> }
>
>
> Thank you,
>
> Naveen.
>
> "Paul G. Tobey [eMVP]" wrote:
>
>> You don't have to register anything, but you should make sure that you
>> are
>> compiling the exported functions in the DLL as C functions, not C++.
>> C++,
>> as you certainly must know, changes the exported names of functions so
>> that
>> their parameter and return types are part of their name. This allows
>> overloading of functions, since you can distinguish between int A( float
>> b )
>> and int A( long b ) by the mangled function name, but it also makes it
>> harder to call from systems where you have to know the actual exported
>> name.
>> The depends.exe tool will show you the actual exported names from a DLL
>> and
>> you should be able to use this tool to see if what you are telling your
>> C#
>> code to call is actually what the DLL is exporting...
>>
>> Paul T.
>>
>> "Naveen Mukkelli" <(E-Mail Removed)> wrote in
>> message news:33E6561E-25BB-4AD6-94F1-(E-Mail Removed)...
>> > Hi Steve,
>> >
>> > Thank you for your response.
>> > I when I tried a samle program, I got "Missing method exception" in my
>> > PDA.
>> >
>> > I am wondering are we supposed to install and register the "DLL" in
>> > PDA.
>> >
>> > Kindly let me know.
>> >
>> > Cheers,
>> >
>> > Naveen
>> >
>> > "Steve Maillet (eMVP)" wrote:
>> >
>> >> In particular search for "dll import" or "PInvoke"
>> >>
>> >> --
>> >> Steve Maillet
>> >> EmbeddedFusion
>> >> www.EmbeddedFusion.com
>> >>
>> >> Do have an opinion on the effectiveness of Microsoft Windows Mobile
>> >> and
>> >> Embedded newsgroups? Let us know!
>> >> https://www.windowsembeddedeval.com/...ity/newsgroups
>> >>
>> >>
>> >>

>>
>>
>>



 
Reply With Quote
 
=?Utf-8?B?TmF2ZWVuIE11a2tlbGxp?=
Guest
Posts: n/a
 
      23rd Sep 2004
Hi Steve,

How can we send string to the unmanaged C method( in dll) which requires
char *.

for example C method in dll

char *someMethod( char *name ); this method
takes a "char" pointer and returns a "char *"

When I tryied in following way, it is not working..

// decleration
[DllImport("somedll.dll")]
public static extern string someMethod( string name );

// method invocation
string str = someMethod("message");
MessageBox.Show(str);

am I missing any thing? is there any way we can send string to the
unmanaged methods and handle char * from unmanaged code using C#?

kindly let me know.

Cheers,

Naveen.

"Steve Maillet (eMVP)" wrote:

> In particular search for "dll import" or "PInvoke"
>
> --
> Steve Maillet
> EmbeddedFusion
> www.EmbeddedFusion.com
>
> Do have an opinion on the effectiveness of Microsoft Windows Mobile and
> Embedded newsgroups? Let us know!
> https://www.windowsembeddedeval.com/...ity/newsgroups
>
>
>

 
Reply With Quote
 
Chris Tacke, eMVP
Guest
Posts: n/a
 
      23rd Sep 2004
In CE strings are Unicode, so they're not chars, but rather wchar_t. Either
you must change the unmanaged function to use Unicode strings, or you must
convert the strings to ANSI before passing them over.

-Chris


"Naveen Mukkelli" <(E-Mail Removed)> wrote in
message news:AD4E0C0B-A8BC-4042-8542-(E-Mail Removed)...
> Hi Steve,
>
> How can we send string to the unmanaged C method( in dll) which requires
> char *.
>
> for example C method in dll
>
> char *someMethod( char *name ); this method
> takes a "char" pointer and returns a "char *"
>
> When I tryied in following way, it is not working..
>
> // decleration
> [DllImport("somedll.dll")]
> public static extern string someMethod( string name );
>
> // method invocation
> string str = someMethod("message");
> MessageBox.Show(str);
>
> am I missing any thing? is there any way we can send string to the
> unmanaged methods and handle char * from unmanaged code using C#?
>
> kindly let me know.
>
> Cheers,
>
> Naveen.
>
> "Steve Maillet (eMVP)" wrote:
>
> > In particular search for "dll import" or "PInvoke"
> >
> > --
> > Steve Maillet
> > EmbeddedFusion
> > www.EmbeddedFusion.com
> >
> > Do have an opinion on the effectiveness of Microsoft Windows Mobile and
> > Embedded newsgroups? Let us know!
> > https://www.windowsembeddedeval.com/...ity/newsgroups
> >
> >
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows Mobile 2003 class libraries versus Windows Mobile 5 class libraries Thore Berntsen Microsoft Dot NET Compact Framework 1 26th Jun 2006 05:03 PM
PDF Libraries Ray Booysen Microsoft ASP .NET 5 24th Jun 2006 02:10 PM
OCR libraries leibnizster Microsoft Dot NET Compact Framework 0 26th May 2006 10:52 PM
Libraries in the GAC Boris Condarco Microsoft Dot NET Framework 2 19th Feb 2004 08:05 PM
Using VC++ 6.0 libraries Anthony Gallagher Microsoft VC .NET 4 16th Jul 2003 11:54 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:40 AM.