Why not log a number of sets of values supplied to DLL by you ASP.NET.
Next write a C++ command line program to call the DLL, query for the required values so you enter them and debug from there.
Click "Mark as Answer" on the post that helped you.
This earns you a point and marks your thread as Resolved so we will all know you have been helped.
FAQ on the correct forum http://forums.asp.net/p/1337412/2699239.aspx#2699239
>I've tried the first method. It does not clear imply of what the data flow are and where they go. I really need to step into the code and trace.
>By the second method that you have mentioned, I am not very clear about how to do it, can it step into the code by doing this?
Instead of trying to debug from ASP.NET into the C++, approach the problem differently.
>Could you please specified it more clearly ? I am new to ASP.net, and I am a green hand coder.
You need to trap the values that are being passed to the DLL. You can do this in a number of ways:
By setting a breakpoint on the call line and get the value from the debug windows.
By writing the values to a label. - This is better as you are not interrupting the process flow.
By writing the values to a custom event log.- this has the advantage of allowing you to trap a large number values. Please see my posting on thread http://forums.asp.net/thread/1631102.aspx for some sample code on how to create a custom event log and a
library that facilitates writing to it.
By writing to trace - not such a good idea,
Of these ideas the one I prefer is to write to a custom event of as it is the least intrusive. I have ASP.NET errors that did not yield to conventional debugging by label or break point, yet were simple to solve using the custom event log technique.
Now once you got your test values, write a simple test harness in C++ to call your C++ DLL. Since you will now be calling from C++ to C++, debugging will be simple.
Click "Mark as Answer" on the post that helped you.
This earns you a point and marks your thread as Resolved so we will all know you have been helped.
FAQ on the correct forum http://forums.asp.net/p/1337412/2699239.aspx#2699239
Does the call from ASP.NET to C++ fail every time or only on some values?
Are you logging at the ASP.NET end? Are logging the exception and the data values that were were fed?
What data types are being passed?
Please post the lines of the call in ASP.NET, indcating the data types of all the variables. Also please post the C++ function header.
Click "Mark as Answer" on the post that helped you.
This earns you a point and marks your thread as Resolved so we will all know you have been helped.
FAQ on the correct forum http://forums.asp.net/p/1337412/2699239.aspx#2699239
Why not go back to the C++ code, copy the project and work with it as a Console (or whatever you want) application? It will be much easier to debug that way because otherwise you are just going to be doing guess and check with logged exceptions.
You can also post the failing C++ code and I or someone else can probably help.
The C++ DLL provides several methods, and the call failed at only one method:
In ASP.net:
public class SomeAlgorithmWrapper{
......
[DllImport("TemplateDLL.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode)]
public static extern Int32 GetTitle(String strPage, int iLenIn, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder sbResult, int iLenOut);
......
StringBuilder sbTitleResult = new StringBuilder(5000);
GetTitle(strParserResult, strParserResult.Length, sbTitleResult, 5000); // exceptions happen at this line, but I can not step into this function
// it works well in C++ project, using the same input in ASP.net
// The variable types work here. Because the log kept some correct results, but failed to log and stopped in the middle of where the exception lies.
// Also, in this function, I called a Part-Of-Speech tagging C++ DLL written by others, the exception may also caused by this DLL :(
......
}
Its C++ function header:
public static extern Int32 GetTitle(wchar_t *wszPage, int iLenIn, wchar_t *wszResult, int iLenOut);
Li_Zhang
Member
4 Points
10 Posts
Debugging C++ DLL in ASP.NET
Apr 25, 2007 07:50 AM|LINK
Dear all,
Hi, I am facing the problem of debugging or step into a C++ DLL source code in a ASP.NET solution.
I've already added the C++ DLL source code as a project in that ASP.net solution, but it can not be debugging or stepped into.
Also, I can only find a "ASP.NET" debugger option in Start Options of the .NET solution property pages, there is no choice as "Native Code".
I am working on this for several days and tried to seek help from different people. But without any results.
Can anyone please help me on this ?
Thanks Very Much!
Li Zhang
TATWORTH
All-Star
72415 Points
14017 Posts
MVP
Re: Debugging C++ DLL in ASP.NET
Apr 25, 2007 04:56 PM|LINK
Why not log a number of sets of values supplied to DLL by you ASP.NET.
Next write a C++ command line program to call the DLL, query for the required values so you enter them and debug from there.
This earns you a point and marks your thread as Resolved so we will all know you have been helped.
FAQ on the correct forum http://forums.asp.net/p/1337412/2699239.aspx#2699239
Li_Zhang
Member
4 Points
10 Posts
Re: Debugging C++ DLL in ASP.NET
Apr 25, 2007 05:08 PM|LINK
Thanks very much, TATWORTH,
I've tried the first method. It does not clear imply of what the data flow are and where they go. I really need to step into the code and trace.
By the second method that you have mentioned, I am not very clear about how to do it, can it step into the code by doiing this?
Could you please specified it more clearly ? I am new to ASP.net, and I am a green hand coder.
Thanks again !
I really wonder if there is a way that can make the debugger step into the DLL code, does anyone knows?
Li_Zhang
Member
4 Points
10 Posts
Re: Debugging C++ DLL in ASP.NET
Apr 25, 2007 05:23 PM|LINK
TATWORTH
All-Star
72415 Points
14017 Posts
MVP
Re: Debugging C++ DLL in ASP.NET
Apr 25, 2007 07:05 PM|LINK
>I've tried the first method. It does not clear imply of what the data flow are and where they go. I really need to step into the code and trace.
>By the second method that you have mentioned, I am not very clear about how to do it, can it step into the code by doing this?
Instead of trying to debug from ASP.NET into the C++, approach the problem differently.
>Could you please specified it more clearly ? I am new to ASP.net, and I am a green hand coder.
You need to trap the values that are being passed to the DLL. You can do this in a number of ways:
- By setting a breakpoint on the call line and get the value from the debug windows.
- By writing the values to a label. - This is better as you are not interrupting the process flow.
- By writing the values to a custom event log.- this has the advantage of allowing you to trap a large number values. Please see my posting on thread http://forums.asp.net/thread/1631102.aspx for some sample code on how to create a custom event log and a
library that facilitates writing to it.
- By writing to trace - not such a good idea,
Of these ideas the one I prefer is to write to a custom event of as it is the least intrusive. I have ASP.NET errors that did not yield to conventional debugging by label or break point, yet were simple to solve using the custom event log technique.Now once you got your test values, write a simple test harness in C++ to call your C++ DLL. Since you will now be calling from C++ to C++, debugging will be simple.
This earns you a point and marks your thread as Resolved so we will all know you have been helped.
FAQ on the correct forum http://forums.asp.net/p/1337412/2699239.aspx#2699239
Li_Zhang
Member
4 Points
10 Posts
Re: Debugging C++ DLL in ASP.NET
Apr 26, 2007 03:05 AM|LINK
Thanks very much, TATWORTH.
I will try to follow the instructions you have provide. :)
Li_Zhang
Member
4 Points
10 Posts
Re: Debugging C++ DLL in ASP.NET
Apr 26, 2007 09:18 AM|LINK
[:(] I tried to log and revise my C++ DLL.
Also, I tried to get the same input that the ASP.net will give to my C++ DLL; It works in a C++ project.
However, whenever I call my C++ DLL in ASP.net, it throw out an exception, I do not know where the exception lies.
Though this log method works, but it really needs a lot of effort as , because the C++ DLL is a big project.
So if only I can debug it and trace into it...
Headache. [+o(]
Why does it works well in C++, but throw exceptions in ASP.net, even using the same input ?
TATWORTH
All-Star
72415 Points
14017 Posts
MVP
Re: Debugging C++ DLL in ASP.NET
Apr 26, 2007 11:23 AM|LINK
Does the call from ASP.NET to C++ fail every time or only on some values?
Are you logging at the ASP.NET end? Are logging the exception and the data values that were were fed?
What data types are being passed?
Please post the lines of the call in ASP.NET, indcating the data types of all the variables. Also please post the C++ function header.
This earns you a point and marks your thread as Resolved so we will all know you have been helped.
FAQ on the correct forum http://forums.asp.net/p/1337412/2699239.aspx#2699239
pickyh3d
Star
9696 Points
1955 Posts
Re: Debugging C++ DLL in ASP.NET
Apr 27, 2007 03:17 AM|LINK
Why not go back to the C++ code, copy the project and work with it as a Console (or whatever you want) application? It will be much easier to debug that way because otherwise you are just going to be doing guess and check with logged exceptions.
You can also post the failing C++ code and I or someone else can probably help.
Li_Zhang
Member
4 Points
10 Posts
Re: Debugging C++ DLL in ASP.NET
Apr 27, 2007 07:08 AM|LINK
The C++ DLL provides several methods, and the call failed at only one method:
In ASP.net:
public class SomeAlgorithmWrapper{
......
[DllImport("TemplateDLL.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode)]
public static extern Int32 GetTitle(String strPage, int iLenIn, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder sbResult, int iLenOut);
......
StringBuilder sbTitleResult = new StringBuilder(5000);
GetTitle(strParserResult, strParserResult.Length, sbTitleResult, 5000); // exceptions happen at this line, but I can not step into this function
// it works well in C++ project, using the same input in ASP.net
// The variable types work here. Because the log kept some correct results, but failed to log and stopped in the middle of where the exception lies.
// Also, in this function, I called a Part-Of-Speech tagging C++ DLL written by others, the exception may also caused by this DLL :(
......
}
Its C++ function header:
public static extern Int32 GetTitle(wchar_t *wszPage, int iLenIn, wchar_t *wszResult, int iLenOut);
// Picky is right, I am doing guess and check :(