Reply

alice johnson replied to sambath kumar at 03-Jul-08 01:32

Here's an example of a properly defined native Dll method written in 'C':

 

extern "C"

{

//Note: must use __declspec(dllexport) to make (export) methods as 'public'

      __declspec(dllexport) void DoSomethingInC(unsigned short int ExampleParam, unsigned char AnotherExampleParam)

      {

            printf("You called method DoSomethingInC(), You passed in %d and %c\n\r", ExampleParam, AnotherExampleParam);

      }

}//End 'extern "C"' to prevent name mangling

 

 Here's what the import declaration in C# looks like:

[DllImport("C_DLL_with_Csharp.dll", EntryPoint="DoSomethingInC")]

public static extern void DoSomethingInC(ushort ExampleParam, char AnotherExampleParam);

Here's what the Dll dump looks like:

File Type: DLL

Section contains the following exports for C_DLL_with_Csharp.dll

00000000 characteristics

409557E6 time date stamp Sun May 02 13:19:50 2004

Hi please got hrough the below link: Hope they help you:

http://www.codeproject.com/KB/cs/C_DLL_with_Csharp.aspx



Click here to sign in and reply. You could earn money via our $500 contest just for being helpful.
  Using C DLL with C# - sambath kumar  03-Jul-08 03:14 3:14:29 AM
      Check with these links - This will fix your issue - santhosh kumar  03-Jul-08 03:39 3:39:42 AM
      refer this link : - Deepak Ghule  03-Jul-08 03:52 3:52:59 AM
      See this - Sujit Patil  03-Jul-08 04:30 4:30:45 AM
      Solution to c dll - Umapathy Kaliaperumal  03-Jul-08 04:32 4:32:05 AM
      Reply - alice johnson  03-Jul-08 01:32 1:32:51 PM
View Posts

promotion
Silverlight    WPF    WCF    WWF    LINQ   
JavaScript    AJAX    ASP.NET    XAML   
C#    VB.NET    VB 6.0    GDI+    IIS    XML   
.NET Generics    Anonymous Methods    Delegate   
Visual Studio .NET    Expression Blend    Virus   
Windows Vista    Windows XP    Windows Update   
Windows 2003 Server    Windows 2008 Server   
SQL Server    Microsoft Excel    Microsoft Word   
SharePoint    BizTalk    Virtual Earth   
.NET Compact Framework    Web Service   


"Everything" RSS / ATOM Feed Parser
How to send and receive messages through message queuing in .Net
How to Read text file as database
SQL Server 2005 Paging Performance Tip
Display code of web page.
Fully Scalable Excel File Importer class for .net using Microsoft Jet driver
Generic Chart Color Manager class that can be used for any charts
Helper class to style the infragistics wingrid
Using Reflection to detemine as Assembly Info in and out.
Helper class to play with Window (Owners and position)
Resolving displayname from the culture using the XmlLanguage and LanguageSpecificStringDictionary class