473,386 Members | 1,798 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,386 software developers and data experts.

Calling unmanaged dll from VB.NET

Folks,
I'm trying to call an unmanaged function from VB.NET and
keep getting "Object reference not set to an instance of
an object" error.

The code that i wrote can be found at:
http://www.nomorepasting.com/paste.php?pasteID=5973

The dll (if some kind soul has the time to compile and run
the code) can be found at:
ftp://ftp.astro.com/pub/swisseph/sweph.zip
The original function definition in the dll is:
char *FAR PASCAL swe_get_planet_name(int ipl, char
*spname);
Any help is greatly appreciated.
Thanks,
Leftie
Nov 20 '05 #1
1 3025
Two problems:

First, you need to initialize the stringbuilder with enough buffer space for
the string the unmanaged function intends to fill.
Secondly, your function uses the PASCAL calling convention. This calling
convention is not directly supported by the framework. The calling
convention specifies two primary things - the order of the parameters on the
stack, and who cleans the stack frame (the caller, or the callee). I can't
recall the exact rules of the PASCAL calling convention off the top of my
head, but in *theory* you can experiment and you might still be able to get
it to work, especially since you only have two 32-bit parameters on the
stack in this case.

-Rob Teixeira [MVP]

"Leftie" <an*******@discussions.microsoft.com> wrote in message
news:13*****************************@phx.gbl...
Folks,
I'm trying to call an unmanaged function from VB.NET and
keep getting "Object reference not set to an instance of
an object" error.

The code that i wrote can be found at:
http://www.nomorepasting.com/paste.php?pasteID=5973

The dll (if some kind soul has the time to compile and run
the code) can be found at:
ftp://ftp.astro.com/pub/swisseph/sweph.zip
The original function definition in the dll is:
char *FAR PASCAL swe_get_planet_name(int ipl, char
*spname);
Any help is greatly appreciated.
Thanks,
Leftie

Nov 20 '05 #2

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

Similar topics

4
by: jarmopy | last post by:
Hi, I have made a service with C# and calling that service class from another C# program with remoting. (Referendes from the calling program) That service class is configured so that garpage...
15
by: Bryan | last post by:
I have a multi-threaded C# console application that uses WMI (System.Management namespace) to make RPC calls to several servers (600+ ) and returns ScheduledJobs. The section of my code that...
1
by: Jesse McGrew | last post by:
Hi all, I'm trying to make a plugin DLL for a third-party application, using VC++ .NET 2003. This DLL acts as a bridge between the C++ plugin API of the application, and my actual plugin code...
1
by: H.B. | last post by:
Hi, I need to make a function that can display data on my Managed C++ app and be called by an unmanaged C++ DLL. Something like : void Form1::Form1_Load(System::Object * sender,...
0
by: monika.saxena | last post by:
Hi all, In one of my projects which is a web based application in asp.net, a third party tool - "Frontline Solver DLL" (It is an unmanaged DLL and ..NET is calling it using the PInvoke) is used....
1
by: MC-Advantica | last post by:
Does anyone have a simple "Hello World" like application that demonstrates unmanaged C++ calling managed C++ developed in VS2005? I'm confused by many posts as they discuss managed extensions from...
9
by: Amit Dedhia | last post by:
Hi All I have a VC++ 2005 MFC application with all classes defined as unmanaged classes. I want to write my application data in xml format. Since ADO.NET has buit in functions available for...
3
by: Klaus | last post by:
Hi, I have an existing VC 6 MFC application which communicates asynchronly with a VC 2005 managed code dll. I use an unmanaged base class with virtual functions to access methods in the MFC...
7
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
I have a C# logging assembly with a static constructor and methods that is called from another C# Assembly that is used as a COM interface for a VB6 Application. Ideally I need to build a file...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.