473,396 Members | 2,147 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,396 software developers and data experts.

Importing non-COM dll

First attempt at importing a DLL

Here is my class
<code>
public class TIGangProg
{
public TIGangProg(){}

[DllImport("GANG430.dll")]
public static extern int InitCom(string lpszComPort, int IBaudRate);
}
</code>

When I attempt to make a call to InitCom I get a DLLNotFound exception. I
tried added a reference to it, but VS complained it wasn't a valid dll
I tried copying it to the folder where my application is because I thought
it would search there after the DAC, but I still get the same error.

This is a DLL from Texas Instruments and with it comes a sample VB.Net
application using it. So I know it's possible, I just can't read VB code
without becoming suicidal ;)
Actually, I have looked at the VB code and don't see any clues...

Anyone have an idea?
Nov 17 '05 #1
4 2839
Steve,

The GANG430.dll is loaded with LoadLibrary, and it will follow the rules
for locating dlls according to that function.

The easiest way to make sure this works is to make sure that the dll is
in the same location as your .NET assembly.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Steve" <ss*@sss.com> wrote in message
news:Ou**************@TK2MSFTNGP14.phx.gbl...
First attempt at importing a DLL

Here is my class
<code>
public class TIGangProg
{
public TIGangProg(){}

[DllImport("GANG430.dll")]
public static extern int InitCom(string lpszComPort, int IBaudRate);
}
</code>

When I attempt to make a call to InitCom I get a DLLNotFound exception. I
tried added a reference to it, but VS complained it wasn't a valid dll
I tried copying it to the folder where my application is because I thought
it would search there after the DAC, but I still get the same error.

This is a DLL from Texas Instruments and with it comes a sample VB.Net
application using it. So I know it's possible, I just can't read VB code
without becoming suicidal ;)
Actually, I have looked at the VB code and don't see any clues...

Anyone have an idea?

Nov 17 '05 #2
"Steve" <ss*@sss.com> wrote in message
news:Ou**************@TK2MSFTNGP14.phx.gbl...
When I attempt to make a call to InitCom I get a DLLNotFound exception. I
tried added a reference to it, but VS complained it wasn't a valid dll
I tried copying it to the folder where my application is because I thought
it would search there after the DAC, but I still get the same error.


A couple of things to eliminate:

1) Move the DLL into the root of your C: drive and refer to it there
explicitly, e.g.
[DllImport("c:\\GANG430.dll")]

If that works, then that's all it was - remember that your app will look for
files in different folders depending on whether it's running in Debug mode,
Release mode, or as a fully-compiled executable.

2) If you still get the error, maybe you're missing some support files which
the DLL needs...
Was it written in VB6? If so, do you have the VB6 runtime files installed?
Nov 17 '05 #3

"Mark Rae" <ma**@mark-N-O-S-P-A-M-rae.co.uk> wrote in message
news:OW*************@TK2MSFTNGP12.phx.gbl...
"Steve" <ss*@sss.com> wrote in message
news:Ou**************@TK2MSFTNGP14.phx.gbl...
When I attempt to make a call to InitCom I get a DLLNotFound exception. I tried added a reference to it, but VS complained it wasn't a valid dll
I tried copying it to the folder where my application is because I thought it would search there after the DAC, but I still get the same error.
A couple of things to eliminate:

1) Move the DLL into the root of your C: drive and refer to it there
explicitly, e.g.
[DllImport("c:\\GANG430.dll")]

If that works, then that's all it was - remember that your app will look

for files in different folders depending on whether it's running in Debug mode, Release mode, or as a fully-compiled executable.

2) If you still get the error, maybe you're missing some support files which the DLL needs...
Was it written in VB6? If so, do you have the VB6 runtime files installed?


Hi Mark,

That worked, putting it in C:\. I will investigate further, thank you for
your response!

-Steve
Nov 17 '05 #4
<snip>
If that works, then that's all it was - remember that your app will look for files in different folders depending on whether it's running in Debug mode, Release mode, or as a fully-compiled executable.

<snip>

This makes sense and is what I tried the first time. For example, I copied
the DLL into obj\Debug thinking that my application would also check in it's
own folder for the DLL, but this fails.
If I tell it to look in c:\ it works.

I feel like I'm missing something... shouldn't it be looking in the folder
where the consuming application is running from?
Nov 17 '05 #5

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

Similar topics

4
by: Oleg | last post by:
Hi, Not really a PHP specific question, but I am using PHP on Linux box so it's kinda relevant. I'm developing a site which will periodically update inventory via a large batch file. I'm...
12
by: qwweeeit | last post by:
The pythonic way of programming requires, as far as I know, to spread a big application in plenty of more manageable scripts, using import or from ... import to connect the various modules. In...
4
by: jean-marc | last post by:
As an application programmer, I'm not well versed in the material aspects of computing (memory, cpu, bus and all). My understanding of imports in Python is such: the __main__ program is the center...
6
by: Sam Lazarus | last post by:
I need to import data from a website, but the text is arranged badly: Name:John Doe Title:Grunt ID:314159 Name:Jane Doe Title:Queen-Bee ID:271828 etc...
0
by: Mike Collins | last post by:
I am importing a XML file and have not been having the best of luck in doing this, but I do have the following solution below. I will not be importing more than 2000 records at a time, but will be...
2
by: Mike Collins | last post by:
I am importing a XML file and have not been having the best of luck in doing this, but I do have the following solution below. I will not be importing more than 2000 records at a time, but will be...
3
by: mukeshsrivastav | last post by:
dear sir i want to move form excel to access. i have 5 excel file having same formats and fields.now i want to import all data in one access table. importing one file is easy .but importing and...
7
by: hg | last post by:
Hi, I have the following problem. I find in a directory hierarchy some files following a certain sets of rules: ..../.../../plugin/name1/name1.py ..... ..../.../../plugin/namen/namen.py
7
by: Hussein B | last post by:
Hey, Suppose I have a Python application consists of many modules (lets say it is a Django application). If all the modules files are importing sys module, how many times the sys module will be...
3
by: rs387 | last post by:
Hi, I've found the following behaviour on importing a variable from a module somewhat odd. The behaviour is identical in Python 2.5 and 3.0b2. In summary, here's what happens. I have a...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.