?
Solved

DLL that is NOT a .NET Assembly or COM component

Posted on 2005-03-25
10
Medium Priority
?
1,497 Views
Last Modified: 2012-08-13
In a C# Class Library, how do I hook into a DLL that is neither a .NET Assembly nor a COM component????

When I try and add a Reference to the DLL...it says I cannot do it because it is not a .NET Assembly nor is it a COM component.

Whaaaaa!!!  But I wanna use it!!!  Not fair!
0
Comment
Question by:Tom Knowlton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 1

Expert Comment

by:M1One
ID: 13634028
use DLLImport attribute. (Please look for more help on "DLLImport" in help).

That way you should be able to use dll functions in your c# code.


0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 13634038
I am using DLLImport as you said but I am getting the following error:


Expected class, delegate, enum, interface, or struct



Here is my code:


using System;
using System.Runtime.InteropServices;




namespace TAPIWrapper
{
      /// <summary>
      /// Summary description for Class1.
      /// </summary>
      ///

      [DllImport("C:\\Program Files\\Avaya\\IP Office\\DEV Link\\devlink.dll")]
      public static extern void DLOpen();

      public class Class1
      {
            public Class1()
            {
                  //
                  // TODO: Add constructor logic here
                  //
            }
      }
}
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 13634056
I am not sure if this line is correct:


public static extern void DLOpen();



Here is screenshot of a DLL "viewer" I am using.....does this help any?????

http://www.knowltonsoftware.com/junk/depwalker.gif
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 5

Author Comment

by:Tom Knowlton
ID: 13634099
I also ran DUMPBIN.exe  (that comes with Visual Studio)


Here was the output:




C:\PROGRA~1\AVAYA\IPOFFI~1\DEVLIN~1>dumpbin /exports devlink.dll
Microsoft (R) COFF/PE Dumper Version 7.00.9466
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file devlink.dll

File Type: DLL

  Section contains the following exports for DEVLINK.DLL

    00000000 characteristics
    3D57DDFF time date stamp Mon Aug 12 10:10:39 2002
        0.00 version
           1 ordinal base
           3 number of functions
           3 number of names

    ordinal hint RVA      name

          1    0 00001040 DLClose
          2    1 00001000 DLOpen
          3    2 00001050 DLRegisterType2CallDeltas

  Summary

        1000 .data
        1000 .rdata
        1000 .reloc
        1000 .rsrc
        4000 .text

C:\PROGRA~1\AVAYA\IPOFFI~1\DEVLIN~1>
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 13634133
Hummmmm.....


The devlink.dll   also has a devlink.h file:


/********************************************************************/
/*                                                                  */
/*       C/C++ Header File  (c) 2001 Avaya Global SME Solutions     */
/*                                                                  */
/*  Contents:-                                                      */
/*  IP400 Office Dev link DLL provides an interface for managing    */
/*  the IP400 Office product ranges from a Windows PC.              */
/********************************************************************/

#ifndef _DEVLINK_H_
#define _DEVLINK_H_

typedef char TEXT;

#define DEVLINK_SUCCESS                        0
#define DEVLINK_UNSPECIFIEDFAIL            1
#define DEVLINK_LICENCENOTFOUND            2

#define DEVLINK_COMMS_OPERATIONAL 0
#define DEVLINK_COMMS_NORESPONSE  1
#define DEVLINK_COMMS_REJECTED    2
#define DEVLINK_COMMS_MISSEDPACKETS 3

#ifdef __cplusplus
extern "C"
{
#endif

      typedef void (CALLBACK * DLCALLLOGEVENT)(
    DWORD   pbxh,
    TEXT   * info
    );

typedef void (CALLBACK * DLCOMMSEVENT)(
    DWORD   pbxh,
    DWORD    comms_state,
    DWORD    parm1
    );

LONG  PASCAL  DLOpen( DWORD pbxh
                       , TEXT * pbx_address
                       , TEXT * pbx_password
                       , TEXT * reserved1
                       , TEXT * reserved2
                       , DLCOMMSEVENT cb
                       );
LONG  PASCAL  DLClose( DWORD pbxh );

LONG  PASCAL  DLRegisterType2CallDeltas( DWORD  pbxh, DLCALLLOGEVENT cb );

#ifdef __cplusplus
};
#endif

#endif // _DEVLINK_H_
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 13634139
So I guess my question is how does this:

LONG  PASCAL  DLOpen( DWORD pbxh
                       , TEXT * pbx_address
                       , TEXT * pbx_password
                       , TEXT * reserved1
                       , TEXT * reserved2
                       , DLCOMMSEVENT cb
                       );


Get translated into a function declaration in C# as I am trying to do above?????
0
 
LVL 10

Accepted Solution

by:
eternal_21 earned 2000 total points
ID: 13634573
Hi knowlton,

  The error you are receiving from the compiler is because you are declaring a method outside of a class.  Try this:


  using System;
  using System.Runtime.InteropServices;

  namespace TAPIWrapper
  {
       public class Class1
       {
            [DllImport("C:\\Program Files\\Avaya\\IP Office\\DEV Link\\devlink.dll")]
            public static extern void DLOpen();

            public Class1()
            {
            }
       }
  }
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 13634577
Thanks.
0
 

Expert Comment

by:arody
ID: 14493893
Knowlton,

where you ever successful with using the devlink with c#?
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 14498238
arody:

I honestly don't remember and since that time I have left the company I was trying to do the work for.

Let me know if YOU get it working, though!!!  :)

Tom
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question