473,545 Members | 2,627 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DllImport -> Object Reference not set to an instance an object

Hi,

I've got a problem with calling a unmanged function :

function call in the .H file :
DWORD _stdcall DoCmdRequest(lo ng lMode, long * plTagType);

my definition in C#

[DllImport("3964 Lib")]
internal static extern int DoCmdRequest(lo ng mode, ref long cardType);
When i try to excute the function, the error ' Object Reference not set
to an instance an object' is triggerd.

Can someone help me out here ?

Nov 17 '05 #1
2 2013
This error can occur if an access violation happens in the native function .
<Fr***@etc.be > schrieb im Newsbeitrag
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
Hi,

I've got a problem with calling a unmanged function :

function call in the .H file :
DWORD _stdcall DoCmdRequest(lo ng lMode, long * plTagType);

my definition in C#

[DllImport("3964 Lib")]
internal static extern int DoCmdRequest(lo ng mode, ref long cardType);
When i try to excute the function, the error ' Object Reference not set
to an instance an object' is triggerd.

Can someone help me out here ?

Nov 17 '05 #2
>function call in the .H file :
DWORD _stdcall DoCmdRequest(lo ng lMode, long * plTagType);

my definition in C#

[DllImport("3964 Lib")]
internal static extern int DoCmdRequest(lo ng mode, ref long cardType);

^^^^ ^^^^

long in C++ translates to int in C#.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 17 '05 #3

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

Similar topics

15
4441
by: Jim | last post by:
I am extremely frustrated. I am building c# application for a call center and am using a third party API to access some hardware. When develop and test my class using the windows console the application runs flawlessly, but once I call the class from inside a c# windows application the program freezes, crashes etc... there must be a way...
6
5905
by: Tim Mulholland | last post by:
Whats the correct C# datatype (or marshalling function or something) to use when you're importing a function that has a signature similar to char* FuncA(char c) ? Assuming you know that both the parameter for the function and the return value are c-style strings?
9
4950
by: Ole Christensen | last post by:
I'm trying to make a sort of conditional compilation in my C# code because my app is intended to run on both a Pocket PC and on a normal desktop PC. My code uses a call to an API function that on the PPC is located in coredll.dll and on the desktop in kernel32.dll. I could make two versions of the DllImported funktions but then I would have to...
3
3450
by: Mark Jerde | last post by:
I'm sill learning VS .NET 2003, not an expert yet. I'm calling an unmanaged C++ DLL from C# using . When the whole project is done I will be calling a total of 5 C++ DLLs from C#. All the DLLs have the same signature, and I never have to call more than one DLL in the same program. (The DLLs parse and validate 5 different binary formats.)...
1
1710
by: Brian Anderson | last post by:
Hello, I have a native, C++ console app that uses ~26MB of RAM when it runs. It uses quite a lot of RAM to make some math but will never xceed 26MB. Now I've made a dll out of this code and use it with DllImport in a C# console application. Basically I just access main() and pass my parameters. w00t! RAM used by the C# app is now 228...
5
2039
by: Felix I. Wyss | last post by:
Good Afternoon, I recently noticed that some very simple methods of a template declared and used in a DLL library get inlined when used by the DLL itself, but not by other DLLs and EXEs. After some investigating, I narrowed this down to a very odd behavior (bug?) of the VC++.NET 2003 compiler: If a class that is declared as...
6
19901
by: Steve | last post by:
I'm sure I'm missing something basic. I have an class library that uses an unmanaged dll. Let's say the class library is called "CL1.dll" and is located at: and the unmanaged dll is called "UM.dll" and is located at For my DllImport attribute I was using and this worked.
2
3656
by: Ed | last post by:
Hello, dear all, I often see these two import usage in the code. Both are the interface to use the Dll library. I think they are the same. Normally P/Invoke means using the to import the dll. But I have some confusion about them. 1. Is the "_declspec(dllimport)" also one of the forms of P/Invoke? 2. From performance aspect, which way...
1
4255
by: kardon33 | last post by:
Let me explain my problem, Im currently trying to use a Perl module that was built for a Windows OS that uses a .dll and .lib file. I have obtained the c header files that the modules were built with. I am trying to use SWIG to write my Perl mod with those files but I getting a bunch of errors with the "extern "C" __declspec(dllimport)"...
1
5785
by: elke | last post by:
Hi, I want to use an unmanaged dll in C# .net and I'm having some troubles witch a function that should return an array. I'm new at this, so I don't know what I'm doing wrong. Here is some code: #define USERINT_FUNC __cdecl #ifdef __cplusplus extern "C" { #endif
0
7496
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7428
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7941
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7784
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6014
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5354
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3485
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1916
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1039
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.