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

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,COleDateTime m_dtFuelEffFrom,CString gSimID,char *itemp);

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

[DllImport ("VMMYDLL.dll")]
public static extern void FuelEfficiency(DateTime m_dtFuelEffTo,DateTime
m_dtFuelEffFrom,string gSimID,[In,Out] char[] sb );
//calling function on a click event
private void StatSubmit_ServerClick(object sender, System.EventArgs e)
{
DateTime temp = Convert.ToDateTime(TxtFuelToDate.Value);
DateTime temp1 = Convert.ToDateTime(TxtFuelFromDate.Value);
string st = null;
FuelEfficiency(temp,temp1,"919444305923",st);//fn called
Response.Write(st);
}
I get an error :System.Runtime.InteropServices.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 1484
You might want to look into Marshaling..
"Priya" <Pr***@discussions.microsoft.com> wrote in message
news:F3**********************************@microsof t.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,COleDateTime m_dtFuelEffFrom,CString gSimID,char *itemp);

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

[DllImport ("VMMYDLL.dll")]
public static extern void FuelEfficiency(DateTime m_dtFuelEffTo,DateTime
m_dtFuelEffFrom,string gSimID,[In,Out] char[] sb );
//calling function on a click event
private void StatSubmit_ServerClick(object sender, System.EventArgs e)
{
DateTime temp = Convert.ToDateTime(TxtFuelToDate.Value);
DateTime temp1 = Convert.ToDateTime(TxtFuelFromDate.Value);
string st = null;
FuelEfficiency(temp,temp1,"919444305923",st);//fn called
Response.Write(st);
}
I get an error :System.Runtime.InteropServices.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
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...
3
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...
24
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...
2
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...
4
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
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...
13
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...
0
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
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...
1
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)...
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
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
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
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.