|
I have been facing some issues lately with Pinvoke calls to native functions of advapi32.dll from managed code and i haven't found yet a way to make it work properly, facing multiple problems related to the classic "A call to ... has unbalanced the stack" and "attempt to read/write protected memory".
My question here is regarding on how to debug those situations properly, as i may not have experience debugging this i ran into the situation where i cannot get information enough to know where the error is.
Is there any way to debug/step into those calls from VS2010 that im not aware of, or maybe a way to read the memory that is being allocated and try to discover it by myself?
To give an example, i have a PTR to a memory address which is supposed to hold a structure, which is pretty big and consist of a lot of another sub-structures and i believe the problem is related to the definition of those as i might not be using the correct data types.
So, for instance, how i can read a specific memory block from a PTR and see which data is allocated there to see if it fits into the structure in the correct fields?
I'm sorry if this is a confusion question, but I'm more like looking for some guidelines and tips into this... hope to get some comments.
|
|
|
|
|
Don't report your question. You've already posted this in the QA forum. Posting it again doesn't get you anything.
Besides, you haven't listed what you're trying to P/Invoke and the code you're using to try to call this stuff.
Listing ALL the tips and what to look for and how to do things would take more than a couple of forum posts.
|
|
|
|
|
1. stack problems are caused by using the wrong calling convention. Fix that first.
2. the easiest way to debug code in general is by adding log statements, and NOT by relying on fancy tools (which require boring interaction) or lots of MessageBoxes. That way you get a chronological and structured result, and you can see up to what point things go well.
3. the one way to debug P/Invoke stuff I know of, is by writing the code one piece at a time, starting with simple stuff, then adding to it. Which also means I provide some simple and some more complex dummy native functions, and get them to work first.
4. when in charge of both sides, keep your API simple; have the managed world do all the memory allocation; and use logging, also let the managed world log native information using a callback. I've explained that and more here[^].
Luc Pattyn [My Articles] Nil Volentibus Arduum
Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.
|
|
|
|
|
Thank you very much for the reply, i had found P/Invoke Article really useful, I will have to play around with the code now...
|
|
|
|
|
You're welcome. And good luck with it.
Luc Pattyn [My Articles] Nil Volentibus Arduum
Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.
|
|
|
|
|
Dear All,
could anyone body assist about this error regarding to generate crystal report from the ASP.Net. the exception is this...
Invalid Argument provided. Failed to open a rowset. Error in File C:\WINDOWS\TEMP\
|
|
|
|
|
Don't crosspost, already you have posted the same question in Q/A section. Check my answer there.
Report Generated problem[^]
BTW always post the relevant code(where the error occurs) in your question.
|
|
|
|
|
I am using paypal sandbox to doing testing, however after click the continue button that i wish to complete the transaction, but the page is keep loading. So i click to go back on the browser, and then click to go forward again, then it will only display "You've already completed your purchase. Please click Close to continue to the merchant." My problem is i want it auto return me the success page, but not click the back and forward to view the return to merchant. thanks you
The page keep loading URL
https://www.sandbox.paypal.com/webapps/checkout/webflow/sparta/expresscheckoutvalidatedataflow?execution=e8s2[^]
|
|
|
|
|
This question would be better posted in the ASP.NET forum or referred back to paypal.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Hi,
Can anyone please let me know, how to kill the application session when the user clicks on the browser "X" button to close the browser.
I have googled and none of the examples seems to be working, appreciate a sample code.
Thanks,
Deb
|
|
|
|
|
If someone kills the browser, the server has no way of knowing. It just has to wait for the session to timeout.
|
|
|
|
|
You need one javascript function to capture browser unload event and one hidden server control button with click event. In that javascript function write code to click the hidden button. In the button click event you can do the actions you want like session clean up.
Ex:
//Javascript
javascript:window.onbeforeunload = function(){
if((window.event.clientX<0) ||
(window.event.clientY<0)){
if(document.getElementById("ctl00$testbutton")!=null)
document.getElementById("ctl00$testbutton").onclick();
}
}
//button event
protected void testbutton_ServerClick(object sender, EventArgs e)
{ Session["test"]=null;
Session.Abandon();
}
Hope it helps
|
|
|
|
|
The same thing could be accomplished with an AJAX call and avoiding another postback.
Also, using JQuery to find the DOM elements is more resilient than using getElementById, IMO.
No comment
|
|
|
|
|
Im trying to see if there is a better way of doing something that I have implemented. In our project we have a class that contains alot of generic list properties, for example
public class Portfolio
public property Client as list(of client)
end property
public property Covers as list(of covers)
end property
public property HomeQuotes as list(of HomeQuotes)
end property
end class
All the data is taken from the database using a LINQ to SQL. I have looked at using IoC container but am not sure that they are the best way to go as this container rarely changes in contents.
Any reference materials or that you could point me too or tips that you could give I would be grateful.
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication2._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<p style="text-align:right;">
<asp:Button ID="btnAdd" runat="Server" Text="Add New Record" OnClick="AddNewRecord" /></p>
<asp:GridView ID="GridView1" runat="Server" AutoGenerateColumns="False"BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px"CellPadding="4" ForeColor="Black" GridLines="Vertical" SkinID="RecordList" Width="100%"OnRowCommand="GridView1_OnRowCommand1" ShowFooter="False" AutoGenerateEditButton="true" OnRowEditing="EditRecord" OnRowCancelingEdit="CancelRecord"OnRowUpdating="UpdateRecords" DataKeyNames="AutoID" EnableViewState="True">
<Columns>
<asp:BoundField DataField="AutoID" HeaderText="AutoID" ReadOnly="True" />
<asp:TemplateField HeaderText="UserName">
<ItemTemplate><%# Eval("UserName") %></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtUserName" runat="Server" Text='<%# Eval("UserName") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate><asp:TextBox ID="txtNewUserName" runat="Server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Password">
<ItemTemplate><%# Eval("Password") %></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtPassword" runat="Server" Text='<%# Eval("Password") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate><asp:TextBox ID="txtNewPassword" runat="Server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="SuperPassword">
<ItemTemplate><%# Eval("SuperPassword") %></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtSuperPassword" runat="Server" Text='<%# Eval("SuperPassword") %>'></asp:TextBox></EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtNewSuperPassword" runat="Server"></asp:TextBox></FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="UserType">
<ItemTemplate><%# Eval("UserType") %></ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="dropType" runat="server" SelectedValue='<%# Eval("UserType").ToString() %>'>
<asp:ListItem Text="Admin" Value="Admin"></asp:ListItem><asp:ListItem Text="Maint" Value="Maint"></asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="NewdropType" runat="server">
<asp:ListItem Text="Admin" Value="Admin">
</asp:ListItem><asp:ListItem Text="Maint" Value="Maint">
</asp:ListItem></asp:DropDownList>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="AdminDesc">
<ItemTemplate><%# Eval("AdminDesc") %></ItemTemplate>
<EditItemTemplate><asp:TextBox ID="txtAdminDesc" Columns="30" runat="Server" Text='<%# Eval("AdminDesc") %>'>
</asp:TextBox></EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtNewAdminDesc" runat="Server" Text='<%# Eval("AdminDesc") %>'></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Active">
<ItemTemplate><%# Eval("Active") %></ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="dropActive" runat="server" SelectedValue='<%# Eval("Active").ToString().ToLower().Equals("true") ? "True" : "False" %>'><asp:ListItem Text="Yes" Value="True"></asp:ListItem><asp:ListItem Text="No" Value="False"></asp:ListItem></asp:DropDownList></EditItemTemplate>
<FooterTemplate><asp:DropDownList ID="dropNewActive" runat="server"><asp:ListItem Text="Yes" Value="True"></asp:ListItem><asp:ListItem Text="No" Value="False"></asp:ListItem></asp:DropDownList> <br />
<asp:Button ID="butIns" runat="Server" Text="Insert" CommandName="Insert" UseSubmitBehavior="False" /></FooterTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#CCCC99" /><RowStyle BackColor="#F7F7DE" />
<SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" /><HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
<EmptyDataTemplate>UserName
<asp:TextBox ID="txtUserName2" runat="Server"></asp:TextBox> Password
<asp:TextBox ID="txtPassword2" runat="Server"></asp:TextBox> SuperPassword
<asp:TextBox ID="txtSuperPassword2" runat="Server"></asp:TextBox> User Type
<asp:DropDownList ID="dropType2" runat="server">
<asp:ListItem Text="Admin2" Value="Admin"></asp:ListItem>
<asp:ListItem Text="Maint" Value="Maint"></asp:ListItem></asp:DropDownList> Admin Desc
<asp:TextBox ID="txtAdminDesc3" runat="Server" /> Active
<asp:DropDownList ID="dropActive3" runat="server">
<asp:ListItem Text="Yes" Value="True"></asp:ListItem>
<asp:ListItem Text="No" Value="False"></asp:ListItem></asp:DropDownList>
<asp:Button ID="btnInsert" runat="Server" Text="Insert" CommandName="EmptyInsert" UseSubmitBehavior="False" />
</EmptyDataTemplate>
</asp:GridView>
</div>
</form>
</body>
</html>
|
|
|
|
|
This really belongs into the ASP.NET forum and it should also contain code-formatting tags (see the link code above the editing textbox).
Regards,
Manfred
"With sufficient thrust, pigs fly just fine."
Ross Callon, The Twelve Networking Truths, RFC1925
|
|
|
|
|
I am not .Net developer. I am just curious.
First of all, as far I understand .Net is suppose to be platform independent. That is why it compile targeting (I think I read somewhere) a Virtual processor.
Now if a developer use WIN32 API in there .Net Application will it be plat form independent at all? I believe no it wont be. Then what is the real purpose of developing a .Net application that would take too much memory, and make my old machine tired?
I know I am coward since the day I know that fortune favors the brave
|
|
|
|
|
.NET is NOT platform independent. .NET is Microsofts implementation of the Common Language Infrastructure (CLI - which Microsoft wrote BTW) for Windows. Mono is another open source implementation of the CLI for Linux. General code that doesn't use any implementation specific libraries should work on any implementation.
When you start getting into the implementation specific stuff, like WPF in Windows, of course that's not going to work on Mono because Linux doesn't have WPF.
Any code you write that P/Invokes Win32 functions, obviously, will not work on anything other than a version of Windows that implements those functions.
|
|
|
|
|
Then why so called new technology, that will make my computer slow and after sometime it will tell me i am backdated upgrade yoursef?
I know I am coward since the day I know that fortune favors the brave
|
|
|
|
|
johny10151981 wrote: that will make my computer slow
Uhhh, no it won't. Where are you getting THAT from??
johny10151981 wrote: and after sometime it will tell me i am backdated upgrade yoursef?
No, it won't. Again, you seem to have some misconceptions on what .NET is and how it works.
|
|
|
|
|
johny10151981 wrote:
First of all, as far I understand .Net is suppose to be platform independen
No. .Net is not platform independent.
johny10151981 wrote: Now if a developer use WIN32 API in there .Net Application will it be plat form independent at all?
It won't be platform independent.
Simply put, Win32 API code never run on a MAC.
|
|
|
|
|
Hi,I am working on a project to manage information of our faculty from ASP.net in C#.
There are profiles for lecturer,student and department head.When Admin set privileges to do tasks Eg:edit student details, this should be appear only in the lecturer profile as a links to edit those data.
So, I want to create the admin page with ability to do those tasks and I have no idea to do that .Can you please give ideas,links or tutorials.
Thanks.
|
|
|
|
|
You may get a faster response if you move this question to the correct forum[^].
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Thanks
|
|
|
|
|
pimzy wrote: Can you please give ideas,links or tutorials.
There's always MSDN[^].
Bastard Programmer from Hell
|
|
|
|