473,385 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Imprting DLLs into C# program

I am attempting to import a DLL function from a COBOL program using the
DLLImport function but I always get an error that says the Specified module
(dtonsub.dll) cannot be found. I used the link program to determine if
there is a function by the name I am using. I have tried this with both
REALIA and Microfocus COBOL programs and get the same error. Can anyone
enlightened me on what the problem is? Below is my code.
Dave

[DllImport("dtronsub.DLL", EntryPoint = "DTRON1", SetLastError = false,
CharSet = CharSet.Unicode, ExactSpelling = false,
CallingConvention = CallingConvention.StdCall)]
public static extern void DTRON1(callparm1 c1, callparm2 c2, int x);

public Form1()
{
InitializeComponent();

callparm1 c1 = new callparm1();
c1.filedata = "12345";
callparm2 c2 = new callparm2();
c2.calldata = "abcd";
DTRON1(c1, c2, 0);

}
Jan 15 '08 #1
4 1287
Hi,
You have to know if the dll is a win32 dll (in which case you use P/invoke
as in your code) or maybe it's a COM dll in which case you need to create a
RCW and import it as any other assembly in .NET

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
"Parrot" <Pa****@discussions.microsoft.comwrote in message
news:EC**********************************@microsof t.com...
>I am attempting to import a DLL function from a COBOL program using the
DLLImport function but I always get an error that says the Specified
module
(dtonsub.dll) cannot be found. I used the link program to determine if
there is a function by the name I am using. I have tried this with both
REALIA and Microfocus COBOL programs and get the same error. Can anyone
enlightened me on what the problem is? Below is my code.
Dave

[DllImport("dtronsub.DLL", EntryPoint = "DTRON1", SetLastError = false,
CharSet = CharSet.Unicode, ExactSpelling = false,
CallingConvention = CallingConvention.StdCall)]
public static extern void DTRON1(callparm1 c1, callparm2 c2, int
x);

public Form1()
{
InitializeComponent();

callparm1 c1 = new callparm1();
c1.filedata = "12345";
callparm2 c2 = new callparm2();
c2.calldata = "abcd";
DTRON1(c1, c2, 0);

}

Jan 15 '08 #2
Thanks for your reply. Since the COBOL compilers I am using are over 10
years old I will assume they are not win32. How does one create an RCW and
import it into an assembly?
Dave

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,
You have to know if the dll is a win32 dll (in which case you use P/invoke
as in your code) or maybe it's a COM dll in which case you need to create a
RCW and import it as any other assembly in .NET

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
"Parrot" <Pa****@discussions.microsoft.comwrote in message
news:EC**********************************@microsof t.com...
I am attempting to import a DLL function from a COBOL program using the
DLLImport function but I always get an error that says the Specified
module
(dtonsub.dll) cannot be found. I used the link program to determine if
there is a function by the name I am using. I have tried this with both
REALIA and Microfocus COBOL programs and get the same error. Can anyone
enlightened me on what the problem is? Below is my code.
Dave

[DllImport("dtronsub.DLL", EntryPoint = "DTRON1", SetLastError = false,
CharSet = CharSet.Unicode, ExactSpelling = false,
CallingConvention = CallingConvention.StdCall)]
public static extern void DTRON1(callparm1 c1, callparm2 c2, int
x);

public Form1()
{
InitializeComponent();

callparm1 c1 = new callparm1();
c1.filedata = "12345";
callparm2 c2 = new callparm2();
c2.calldata = "abcd";
DTRON1(c1, c2, 0);

}


Jan 15 '08 #3
There are Win32 dlls older than 10 years. I notice that your exception
says that dtonsub.dll cannot be found (while you are calling dtronsub.DLL).
Are you sure that the DLL is installed on the machine correctly, with all
supporting files? If not, then you have to make sure that it is installed
correctly, and that a call to LoadLibrary passing that dll name will succeed
(as this is what the CLR uses to locate the DLL and make the call).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Parrot" <Pa****@discussions.microsoft.comwrote in message
news:98**********************************@microsof t.com...
Thanks for your reply. Since the COBOL compilers I am using are over 10
years old I will assume they are not win32. How does one create an RCW
and
import it into an assembly?
Dave

"Ignacio Machin ( .NET/ C# MVP )" wrote:
>Hi,
You have to know if the dll is a win32 dll (in which case you use
P/invoke
as in your code) or maybe it's a COM dll in which case you need to create
a
RCW and import it as any other assembly in .NET

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
"Parrot" <Pa****@discussions.microsoft.comwrote in message
news:EC**********************************@microso ft.com...
>I am attempting to import a DLL function from a COBOL program using the
DLLImport function but I always get an error that says the Specified
module
(dtonsub.dll) cannot be found. I used the link program to determine
if
there is a function by the name I am using. I have tried this with
both
REALIA and Microfocus COBOL programs and get the same error. Can
anyone
enlightened me on what the problem is? Below is my code.
Dave

[DllImport("dtronsub.DLL", EntryPoint = "DTRON1", SetLastError = false,
CharSet = CharSet.Unicode, ExactSpelling = false,
CallingConvention = CallingConvention.StdCall)]
public static extern void DTRON1(callparm1 c1, callparm2 c2, int
x);

public Form1()
{
InitializeComponent();

callparm1 c1 = new callparm1();
c1.filedata = "12345";
callparm2 c2 = new callparm2();
c2.calldata = "abcd";
DTRON1(c1, c2, 0);

}



Jan 15 '08 #4
I am able to call this same dll in a program written in C++ which has an
export function. In C++ I have to specify the lib file for the dll in the
linker section of my C++ application. I don't see anywhere in a C#
application that calls for a similar interface. I know that the DLL is
installed and works correctly on the C++ system. I really need to know the
procedure for doing the same thing in C#.
Dave

"Nicholas Paldino [.NET/C# MVP]" wrote:
There are Win32 dlls older than 10 years. I notice that your exception
says that dtonsub.dll cannot be found (while you are calling dtronsub.DLL).
Are you sure that the DLL is installed on the machine correctly, with all
supporting files? If not, then you have to make sure that it is installed
correctly, and that a call to LoadLibrary passing that dll name will succeed
(as this is what the CLR uses to locate the DLL and make the call).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Parrot" <Pa****@discussions.microsoft.comwrote in message
news:98**********************************@microsof t.com...
Thanks for your reply. Since the COBOL compilers I am using are over 10
years old I will assume they are not win32. How does one create an RCW
and
import it into an assembly?
Dave

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,
You have to know if the dll is a win32 dll (in which case you use
P/invoke
as in your code) or maybe it's a COM dll in which case you need to create
a
RCW and import it as any other assembly in .NET

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
"Parrot" <Pa****@discussions.microsoft.comwrote in message
news:EC**********************************@microsof t.com...
I am attempting to import a DLL function from a COBOL program using the
DLLImport function but I always get an error that says the Specified
module
(dtonsub.dll) cannot be found. I used the link program to determine
if
there is a function by the name I am using. I have tried this with
both
REALIA and Microfocus COBOL programs and get the same error. Can
anyone
enlightened me on what the problem is? Below is my code.
Dave

[DllImport("dtronsub.DLL", EntryPoint = "DTRON1", SetLastError = false,
CharSet = CharSet.Unicode, ExactSpelling = false,
CallingConvention = CallingConvention.StdCall)]
public static extern void DTRON1(callparm1 c1, callparm2 c2, int
x);

public Form1()
{
InitializeComponent();

callparm1 c1 = new callparm1();
c1.filedata = "12345";
callparm2 c2 = new callparm2();
c2.calldata = "abcd";
DTRON1(c1, c2, 0);

}


Jan 15 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: kinghuangz | last post by:
Everyone: I want to use a DLL(FileName:PubFunction.Dll) built with VS.Net(C#) in a unmanaged Program .But there was a Dll just has the same filename,it was built with VC++(6.0).The unmanaged was...
1
by: Lucas Graf | last post by:
I am trying to get the deployment to do what I want, but I just can't. I want my folders to be setup like below.. Main Program Folder - Program EXE - Program PDB - AppStart EXE - AppStart...
0
by: ZMan | last post by:
Scenario: This is about debugging server side scripts that make calls to middle-tier business DLLs. The server side scripts are legacy ASP 3.0 pages, and the DLLs are managed DLLs...
0
amitpatel66
by: amitpatel66 | last post by:
There is always a requirement that in Oracle Applications, the Concurrent Program need to be execute programatically based on certain conditions/validations: Concurrent programs can be executed...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.