|
Alex Korchemniy wrote:
Stack is the memory location where local variables are stored
That's not exactly true. What stored on the execution stack are pointers to the variables, whether they be parameters, local variables or fields.
So, to answer the original question the local variable is at a certain address apart from the execution stack. When you use stloc.* it pops the variable referenced on the stack and assigns that reference to the applicable local variable.
The best way to learn about this stuff is to learn about computer architecture - specifically about memory addressing.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
> That's not exactly true.
Well its a simplistic answer.
|
|
|
|
|
I'll take a shot at this. To the best of my knowledge,
registers: small area of memory, located directly on the cpu, faster than conventional memory, used by the CPU for temporary storage, often used in calculations.
heap: the big pile of memory used (in .NET) for storing reference types. Everything on the heap, pinned references aside, is managed by the .NET garbage collector.
public class MyClass()
{
}
MyClass class = new MyClass();
The 'stored local variable': if it's stored locally in your function, it's on the stack until you pop it off the stack, in which case it'll be stored as a register variable. In your example, the 3rd line of IL will store the value on the top of the stack into a register variable I believe.
*waits for some expert to correct him*
Any remotely useful information on my blog will be removed immediately. There are 10 kinds of people in the world. Those who have heard of the ubiquitous, overused, worn-out-like-an-old-shoe binary "joke" and those who haven't.
Judah Himango
|
|
|
|
|
I'm sure this is easy but I can't seem to find the answer. I want to close a form and open another without using Form1.Hide() and Form2.Show(). I want the first form to totaly close and the next form to be opened not as a child. Thanks
|
|
|
|
|
You can't close the form that your app starts on. If you do, you're entire app will quit. What you do in your Form1 Load event is create a Form2, like a splash screen, show it, complete all your initialization, and at the end of the Form1 Load event, destroy Form2.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Yea, I ended up making them both separate threads and that worked
|
|
|
|
|
I am learning C# web development with Visual studio .NET and I cannot get past this error. Whilst working from a book i got the following error.
"A namespace does not directly contain members such as fields or methods."
I have included the code belowwhich was typed out of the book. It throws the error to line 75(near bottom). I have highlighted it. It is not happy with override protected void OnInit(EventArgs e. Namely override has red line in the API. I did not even type this part of the code in as it was webgenerated code. If anyone could point me in the direction I would be so Grateful as ths is for my Final year project at university.
Many thanks
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
//I removed using System.Drawing from here
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace FriendsReunion
{
public class _Default : System.Web.UI.Page
{
protected System.Web.UI.WebControls.PlaceHolder phNav;
protected FriendsReunion.SubHeader ccSubHeader;
private void Page_Load(object sender, System.EventArgs e)
{
Table tb = new Table();
TableRow row;
TableCell cell;
Image img;
Hyperlink lnk;
if (Context.User.Identity.IsAuthenticated)
{
//Create a new blank table row
row = new TableRow();
//Set up the News image
img = new Image();
img.ImageUrl = "Images/globe.gif";
img.ImageAlign = ImageAlign.Middle;
img.Width = new Unit(24, UnitType.Pixel);
img.Height = new Unit(24,UnitType.Pixel);
//Create a cell and add the image
cell = new TableCell();
cell.Controls.Add(img);
//Add the new cell to the row
row.Cells.Add(cell);
//Set up the News link
lnk = new HyperLink();
lnk.Text = "News";
lnk.NavigateUrl = "News.aspx";
//Create the cell and the add link
cell = new TableCell();
cell.Controls.Add(lnk);
//Add the new cell to the row
row.Cells.Add(cell);
//Add the row to the table
tb.Rows.Add(row);
}
else
{
//code for authenticated users here...
}
//Finally, add the table to the placeholder
phNav.Controls.Add(tb);
}
}
}
#region Web Form Designer generated code
LINE 75 >>> override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
|
|
|
|
|
copy everything between
#region Web Form Designer generated code
and
#endregion
and move it inside the } brace just above where #region currently is.
|
|
|
|
|
cmitty wrote:
#region Web Form Designer generated code
LINE 75 >>> override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
InitializeComponent();
base.OnInit(e);
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
This code block should be inside the class declaration. Move it a few lines up ( just before the last '}') and it'll work.
Yes, even I am blogging now!
|
|
|
|
|
Hi,
thank you for you quick response. I do not fully understand what you mean. I have tried moving it afew lines up but no joy. ths code is automaticlly generated. I have included all my code below. You may be able to see where I am going wrong. its bugging me now huh. Thanks for your help.
Chris
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
//I removed using System.Drawing from here
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace FriendsReunion
{
public class _Default : System.Web.UI.Page
{
protected FriendsReunion.SubHeader ccSubHeader;
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
private void Page_Load(object sender, System.EventArgs e)
{
Table tb = new Table();
TableRow row;
TableCell cell;
Image img;
Hyperlink lnk;
if (Context.User.Identity.IsAuthenticated)
{
//Create a new blank table row
row = new TableRow();
//Set up the News image
img = new Image();
img.ImageUrl = "Images/globe.gif";
img.ImageAlign = ImageAlign.Middle;
img.Width = new Unit(24, UnitType.Pixel);
img.Height = new Unit(24,UnitType.Pixel);
//Create a cell and add the image
cell = new TableCell();
cell.Controls.Add(img);
//Add the new cell to the row
row.Cells.Add(cell);
//Set up the News link
lnk = new HyperLink();
lnk.Text = "News";
lnk.NavigateUrl = "News.aspx";
//Create the cell and the add link
cell = new TableCell();
cell.Controls.Add(lnk);
//Add the new cell to the row
row.Cells.Add(cell);
//Add the row to the table
tb.Rows.Add(row);
}
else
{
//code for authenticated users here...
}
//Finally, add the table to the placeholder
phNav.Controls.Add(tb);
}
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
InitializeComponent1();
base.OnInit(e);
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent1()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
|
|
|
|
|
I have just made a control that is resizable. The resizing is performed with the mouse, in the normal windows way. You put the mouse on the resizer box and drag it to desired shape.
I have currently made this work for bottom and the right side of the control. When I resize using those resizers everything works fine. When I drag them with the mouse the control is smoothly updated. Here I update the controls width and height properties.
But when I try to do the same thing with the top and left side of the control, things dont work as with the bottom and right side. The control gets strange shapes until I release the mouse button and still it doesnt get the correct shape as I would expect. It kind of works, it resizes in the right directions atleast, but not always in the correct distances, and the resize is definately not smooth, it looks completely screwed up during the resize and flickers and everything. The only difference I can see between these edges of the control and the bottom and right is that the top and left sides need to change the controls Top and Left properties and not just its Width and Height. The code is basically exactly the same for all resizes so it seems really strange to me.
|
|
|
|
|
Check your OnPaint Event, most likely you have overridden it, maybe excessive use of Invalidate ?
~Alexander Kent
|
|
|
|
|
Yes I have overridden the OnPaint event, and I really dont know whether the use of invalidate is excessive or not, but it works for the bottom and right sides of the control, and I invalidate them just as much as I invalidate the top and left sides.
The source code is maybe a little too long to show here but if anyone wants to see it I'll be glad to send it to you.
|
|
|
|
|
Keen to take a look at your code
~Alexander Kent
|
|
|
|
|
Hi there
Iam trying to compile a simple vector draw program, but when shapes are drawn it will not give a smooth picture of the shape, i have heared that rubberbanding is the way to do it but haven't had any succes.
Can anyone shed some light on it for me
Many thanks
Sam
|
|
|
|
|
Are you using the WebImageViewer? It has a build in rubberband
~Alexander Kent
|
|
|
|
|
I have a C# application, which is using a several dlls. Sometimes one of dll's is missing, then exception is thrown with message like "The "name.dll" one of it's dependencies is missing". In this case the user (and me) doesn'n know which dll is missing. How can I get it's name at run time?
|
|
|
|
|
|
i've a problem on writing a source code for a bus company with 2 choices:
When invoked the program should present the user with two choices and let user
choose by inputting corresponding number:
1.Make a reservation
2.Sell a ticket.
If user choose (1) the program should,
1.Prompt user to input Bus name and find the file with that name, if not found create
a binary file with given name for keeping reservations for that bus.
2.Create a structure with all information needed to record a reservation.
3.Check for consistency that the seat is not taken already and the bus is not full.
4.Write the reservation into the binary file for chosen bus maintaining consistency.
5.Thank the user and exit.
If user choose (2) the program should,
1.Ask the user to input the name of bus in which reservation was previously made.
2.If the bus file does not exist, inform the user of the problem and repeat step 1.
3.Ask user input name and seat number reserved
4.If name and seat number are correct, mark the seat as sold and record amount of
money paid for the seat.
5.Finally the program should thank the user for using the program and display a
pretty report showing the current status of chosen bus in terms of which seats are
reserved, which ones for which the ticket is sold and total revenue collected so far.
nkacha
|
|
|
|
|
And what are your concrete problems or do you expect us to write the whole application for you?
www.troschuetz.de
|
|
|
|
|
This looks a lot like a homework assignment.
We can help you if you post specific questions, but we'll not code your entire application
Yes, even I am blogging now!
|
|
|
|
|
hi man,
so you have C# in school? Where's the problem? Screen IO? System.Console ...
File IO? System.IO.File ... Algorithm? If it is so, don't drink so much alcohol, or get some sleep, student!
best regards,
David 'DNH' Nohejl
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
Nice job of cutting and pasting your homework assignment! Unless you start writing the code yourself, you will never get any help from us. We help those who help themselves.
Now, if you want someone to write your program for you, just send a cashiers check for $5,000.00US, drawn on a US bank.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
i am using a vc++ 6.0 dll that is returning a 8 bit per pixel graycsale image byte buffer that i want to display into my picturebox
currently i am using
System.Drawing.Bitmap NewBmp=new Bitmap(640,480,640,System.Drawing.Imaging.PixelFormat.Format8bppIndexed ,(System.IntPtr)buff);
my image is grayscale and the format but the constructor is accepting is only Format8bppIndexed which is collored hence macking mess with my bitmap colors
i also tried to use stream but my buffer is not being converted to bitmap and eror is recieved
can anybody help me show my 8bpp inage byte buffer (byte*)in picture box
thanks
|
|
|
|
|
Does anyone actually know how to create a timelimited try out version of an application that is supposed to work offline?
Considerations: I can't really trust the computer clock because of the possibility that the user can easily change it to gain more time for the application
|
|
|
|