adamsmithhrs
Programmer
Hello,
wondering if somone could clear something up for me as i have been reading around this subject for a while and am still confused.
I have a DLL from a hardware vendor but i dont know what language the DLL is written in.
I would like to use this DLL from managed code (c#). From what i have read i need this to be a COM object, but i dont really understand how you differentiate between a dll written in C++ which is a COM object and on that isnt.
Each time i try to add the dll as a reference (VS 2003 .Net 2.0) i get the following message:
A reference to MYDLL.dll could not be added. This is not a valid assembly or COM component.
I have tried using PINVOKE see code below and managed to call a method from the DLL using my c# application but i dont really want to write a method for each method the DLL supports, mainly becuase i am worried about casting data types etc
[DllImport("MyDLL.dll", SetLastError = true, CharSet = CharSet.Auto)]
static extern bool AlarmLogSize(int lpDirectoryName,
out uint lpFreeBytesAvailable);
Form1.AlarmLogSize(0, out freeBytesAvail);
MessageBox.Show(freeBytesAvail.ToString());
Can anyone tell me how best i can use this DLL and what my options are.
Also i have an example application written in VB6 which come with the DLL and that has a Module which seems looks like this:
Public Declare Function AlarmLogSize Lib "VertX.dll" (ByVal mode As Long, _
logSize As Long) As Long
I have no idea when it comes to VB but i presume this is the equivilent of what am doing with my PINVOKE applicaiton.
Any help really appreicated!
Thanks
Adam
wondering if somone could clear something up for me as i have been reading around this subject for a while and am still confused.
I have a DLL from a hardware vendor but i dont know what language the DLL is written in.
I would like to use this DLL from managed code (c#). From what i have read i need this to be a COM object, but i dont really understand how you differentiate between a dll written in C++ which is a COM object and on that isnt.
Each time i try to add the dll as a reference (VS 2003 .Net 2.0) i get the following message:
A reference to MYDLL.dll could not be added. This is not a valid assembly or COM component.
I have tried using PINVOKE see code below and managed to call a method from the DLL using my c# application but i dont really want to write a method for each method the DLL supports, mainly becuase i am worried about casting data types etc
[DllImport("MyDLL.dll", SetLastError = true, CharSet = CharSet.Auto)]
static extern bool AlarmLogSize(int lpDirectoryName,
out uint lpFreeBytesAvailable);
Form1.AlarmLogSize(0, out freeBytesAvail);
MessageBox.Show(freeBytesAvail.ToString());
Can anyone tell me how best i can use this DLL and what my options are.
Also i have an example application written in VB6 which come with the DLL and that has a Module which seems looks like this:
Public Declare Function AlarmLogSize Lib "VertX.dll" (ByVal mode As Long, _
logSize As Long) As Long
I have no idea when it comes to VB but i presume this is the equivilent of what am doing with my PINVOKE applicaiton.
Any help really appreicated!
Thanks
Adam