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

C# dll import function returning -1

Hi there,
In C# I'm using a DLL import attribute to call a function from this
DLL. This function was written in an older version of Vb and I know the

name of this function and it should return an integer.
public class Class1
{
[DllImport("DllDemo")]
public static extern int Initiliase(string Path);

}
// in Main Form
pathos = "initialisepath"
retval = Class1.Initialise(pathos);
Console.WriteLine(retval);

The DLL is found ... however this integer function I'm using, I'm
passing to it a string value which is this a case is a path to an INI
file. But its returning to me a -1 integer value and making Beep sound.

I'm passing a correct path. I tried to pass a garbaged string like
"dsfs3rt" to see if the problem was coming from the path but its
returning to me the same -1 integer value and making a beep sound.
I cannot see what this -1 means. Maybe I'm missing something. Maybe its

an error that doesn't stop the program.
Any help appreciated :)
Thanks

Dec 9 '05 #1
4 4199
>This function was written in an older version of Vb
DllImportAttribute is used to call traditional windows DLL. I am not
aware that vb can produce such DLL, it can only produce COM (ActiveX)
DLL.

Dec 9 '05 #2
Thanks for the reply :)

I'm writing the application in C#.NET not in Vb. The Dllimportattribute
is used in the C# Win32

Dec 9 '05 #3
What version of vb was it made in? VB could only make activex dlls. .Net
provides support for using com components. You dont have to do anything
special for this dll function. Just add a reference to it and create a new
object and call the method. It should work.

Ab.
http://joehacker.blogspot.com

<of****@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Hi there,
In C# I'm using a DLL import attribute to call a function from this
DLL. This function was written in an older version of Vb and I know the

name of this function and it should return an integer.
public class Class1
{
[DllImport("DllDemo")]
public static extern int Initiliase(string Path);

}
// in Main Form
pathos = "initialisepath"
retval = Class1.Initialise(pathos);
Console.WriteLine(retval);

The DLL is found ... however this integer function I'm using, I'm
passing to it a string value which is this a case is a path to an INI
file. But its returning to me a -1 integer value and making Beep sound.

I'm passing a correct path. I tried to pass a garbaged string like
"dsfs3rt" to see if the problem was coming from the path but its
returning to me the same -1 integer value and making a beep sound.
I cannot see what this -1 means. Maybe I'm missing something. Maybe its

an error that doesn't stop the program.
Any help appreciated :)
Thanks

Dec 9 '05 #4
Hi,
"Varangian" <of****@gmail.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
Thanks for the reply :)

I'm writing the application in C#.NET not in Vb. The Dllimportattribute
is used in the C# Win32


He means that VB could not create a native win32 dll, you could only create
COM dlls, therefore you cannot use dllimport. All you have to do is include
a reference to the dll using "Add Reference" and the IDE will create a
wrapper for you.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Dec 9 '05 #5

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

Similar topics

3
by: Dennis Chang | last post by:
Hi all, I was reading about function pointers and came across something which intrigued me. K&R2 calls qsort (pg.119) within main as so: qsort( (void **) lineptr, 0, nlines-1, (int (*) (void...
26
by: Adam Warner | last post by:
Hello all, I'm very new to C but I have a number of years of Common Lisp programming experience. I'm trying to figure out ways of translating higher order concepts such as closures into C. The...
2
by: None | last post by:
Hello, 1. The prototype of function signal in signal.h: void (*signal(int sig, void (*func)(int)))(int); is some complex to me. Would you please explain it to me in detail with the C...
17
by: I.M. !Knuth | last post by:
Hi. I'm more-or-less a C newbie. I thought I had pointers under control until I started goofing around with this: ...
2
by: pendell | last post by:
I am working with a client running 2003 Access. Some time ago I built them an import spec for use with the Import Wizard. Several months later, I have been called back and asked to solve a...
2
by: rfdes | last post by:
Hi- I could use some help resolving a problem. This explanation will be lengthy as I am trying to describe my problem without posting real code. I currently have a Win32 console application & a...
26
by: aruna.mysore | last post by:
Hi all, I have a specific problem passing a function pointer array as a parameter to a function. I am trying to use a function which takes a function pointer array as an argument. I am too sure...
13
by: Sri Harsha Dandibhotla | last post by:
Hello all. I recently came across a function declaration as : char(*(*x()))(); This was not in some code but it was in a C questions thread on some group. I tried to decipher what it returns but...
13
by: Rafe | last post by:
Hi, I am in a situation where I feel I am being forced to abandon a clean module structure in favor of a large single module. If anyone can save my sanity here I would be forever grateful. My...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.