473,788 Members | 3,078 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

call a unmanaged dll in ASP.NET app

Hi,
I'm developing an ASP.NET app. In codebehind .cs file i need call an
unmanaged C++ dll.I copied the dll into the bin directory.
the header file of the dll contains the definition as

extern "C" __declspec (dllexport) void FuelEfficiency( COleDateTime
m_dtFuelEffTo,C OleDateTime m_dtFuelEffFrom ,CString gSimID,char *itemp);

where itemp is out parameter
Declaration of function in C# is:

[DllImport ("VMMYDLL.dl l")]
public static extern void FuelEfficiency( DateTime m_dtFuelEffTo,D ateTime
m_dtFuelEffFrom ,string gSimID,[In,Out] char[] sb );
//calling function on a click event
private void StatSubmit_Serv erClick(object sender, System.EventArg s e)
{
DateTime temp = Convert.ToDateT ime(TxtFuelToDa te.Value);
DateTime temp1 = Convert.ToDateT ime(TxtFuelFrom Date.Value);
string st = null;
FuelEfficiency( temp,temp1,"919 444305923",st);//fn called
Response.Write( st);
}
I get an error :System.Runtime .InteropService s.SEHException: External
component has thrown an exception.
Is the above code correct?
Is there any way to debug unmanaged code in C#?

Thanks in advance
Priya
Nov 18 '05 #1
1 1495
You might want to look into Marshaling..
"Priya" <Pr***@discussi ons.microsoft.c om> wrote in message
news:F3******** *************** ***********@mic rosoft.com...
Hi,
I'm developing an ASP.NET app. In codebehind .cs file i need call an
unmanaged C++ dll.I copied the dll into the bin directory.
the header file of the dll contains the definition as

extern "C" __declspec (dllexport) void FuelEfficiency( COleDateTime
m_dtFuelEffTo,C OleDateTime m_dtFuelEffFrom ,CString gSimID,char *itemp);

where itemp is out parameter
Declaration of function in C# is:

[DllImport ("VMMYDLL.dl l")]
public static extern void FuelEfficiency( DateTime m_dtFuelEffTo,D ateTime
m_dtFuelEffFrom ,string gSimID,[In,Out] char[] sb );
//calling function on a click event
private void StatSubmit_Serv erClick(object sender, System.EventArg s e)
{
DateTime temp = Convert.ToDateT ime(TxtFuelToDa te.Value);
DateTime temp1 = Convert.ToDateT ime(TxtFuelFrom Date.Value);
string st = null;
FuelEfficiency( temp,temp1,"919 444305923",st);//fn called
Response.Write( st);
}
I get an error :System.Runtime .InteropService s.SEHException: External
component has thrown an exception.
Is the above code correct?
Is there any way to debug unmanaged code in C#?

Thanks in advance
Priya

Nov 18 '05 #2

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

Similar topics

4
2032
by: Gnanaprakash Rathinam | last post by:
Hi Expert, Is there a way to obtain assembly name in an unmanaged call? During Interop call between managed to unmanaged, I would like to know in unmanaged code about the caller of assembly file name? Thanks, GP.
3
1631
by: rasa | last post by:
I am able to instantiate and make calls to a com module that use only primitive data types, but I simply don't know what the c# equivalent is for a function expecting short*. Any help would be appreciated.
24
7696
by: Jazper | last post by:
hi i have this problem. i made a class deverted by CRootItem with implementation of IDisposable-Interface. i made a test-funktion to test my Dispose-Method.... but when set a breakpoint in my Dispose-Method and call the GC nothing happend!!! my Disposemethod has never been called!! so the GC dont call my Dispose-Method although I implemented IDisposable? what am i doing wrong?
2
1747
by: hykim | last post by:
I want to call a unmanaged dll's function returning some STRUCT's pointer. the next is definition of a STRUCT. ----------------------------------------------------------------------- typedef struct myStruct{ struct { UINT_PTR anything; UCHAR anything2; } myInnerStruct;
4
4876
by: Andreas Ntalakas | last post by:
hello is it possible to call functions implemented in a C# .dll from unmanaged C++ code Thank you
2
9506
by: joye | last post by:
Hello, My question is how to use C# to call the existing libraries containing unmanaged C++ classes directly, but not use C# or managed C++ wrappers unmanaged C++ classes? Does anyone know how to do that? Thanks. Tsung-Yu
13
4150
by: Bern McCarty | last post by:
I have run an experiment to try to learn some things about floating point performance in managed C++. I am using Visual Studio 2003. I was hoping to get a feel for whether or not it would make sense to punch out from managed code to native code (I was using IJW) in order to do some amount of floating point work and, if so, what that certain amount of floating point work was approximately. To attempt to do this I made a program that...
0
1461
by: Ken Durden | last post by:
A little more info. I have a unmanaged C++ DLL, compiled without /CLR. Inside a Managed C++ DLL, I have the following class: MarshalWrapper.h ---- #ifdef _MANAGED __nogc #endif
28
1953
by: Peter Olcott | last post by:
I want to double check my understanding about how the .NET framework works. From what I understand every call to the .NET framework is ultimately translated into one of more API calls, is this correct?
1
1296
by: lingchen_email | last post by:
Hi, Is there a way to call an API in unmanaged DLL from C# application in a way that the name of the API is generated programmatically? For example, I have API_AAA(p1,p2) & API_BBB(p1,p2,p3) defined in an unmanaged DLL already. I know that I can use DllImport and declare the APIs as "public static extern ......", and then call API_AAA() & API_BBB() directly from the C# code. But, what I really want is something similar to...
0
9655
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10363
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9964
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5535
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.