|
Hi,
I have a problem to understand one thing concerning structs.
It is said that structs are value types. But what happens when a Reference Type member is defined for a struct? Because it is a member of a struct does it behave like a value type -meaning both its value and reference address are stroed in the stack together?
Thanks!
|
|
|
|
|
Then, the struct still behaves as a value type; every time you pass it to a function, the struct will be copied.
The reference contained in it is just a pointer to a location in memory where the real object resides. Thus, when the struct is copied, the pointer is copied; but big deal, the real object exists just once and still remains there.
Make sense?
|
|
|
|
|
Definetly makes sense;
Thanks a lot!
|
|
|
|
|
My WebService application responds the clients well generally. But sometimes in some cases or in some environments (which I could not explain when or in which cases yet) web service function calls return back too late (I mean the caller client waits almost 2-3 minutes). Moreover, in spite of this delay, the web service continues to respond clients, meaning no crush or lock occurs.
Normally a client calls web service functions frequently. Every things seems well but after a period of time web service functions become late in responding and returning back..
Not many client requests for Web service functions at the same time. Only one client application exists.
What might cause these delays ?
Thnx in advance..
|
|
|
|
|
Lost packets, perhaps? First thing I'd determine is where the problem is occurring - does your web service actually receive this request that takes 2-3 minutes? Or does the client make a request, but it never makes it to the web service?
|
|
|
|
|
Have you every tried to go to a website and had it not respond but then clicking refresh gets an immediate reply? I think it is the same thing. Some requests will just fail over the internet.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
Hi,
I am getting the below error with only 2/3 forms open in the MDI. Is this a problem with my coding? or just my pc is crap?
A first chance exception of type 'System.OutOfMemoryException' occurred in System.Windows.Forms.dll<br />
MDIMain.OnNewManualFormLoad; Exception: System.OutOfMemoryException: Error creating window handle. ---> System.NullReferenceException: Object reference not set to an instance of an object.<br />
at System.Windows.Forms.NativeWindow.WindowClass.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)<br />
at System.Windows.Forms.UnsafeNativeMethods.IntCreateWindowEx(Int32 dwExStyle, String lpszClassName, String lpszWindowName, Int32 style, Int32 x, Int32 y, Int32 width, Int32 height, HandleRef hWndParent, HandleRef hMenu, HandleRef hInst, Object pvParam)<br />
at System.Windows.Forms.UnsafeNativeMethods.CreateWindowEx(Int32 dwExStyle, String lpszClassName, String lpszWindowName, Int32 style, Int32 x, Int32 y, Int32 width, Int32 height, HandleRef hWndParent, HandleRef hMenu, HandleRef hInst, Object pvParam)<br />
at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)<br />
--- End of inner exception stack trace ---<br />
at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)<br />
at System.Windows.Forms.Control.CreateHandle()<br />
at System.Windows.Forms.Form.CreateHandle()<br />
at System.Windows.Forms.Control.get_Handle()<br />
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)<br />
at System.Windows.Forms.Control.Show()<br />
at UNet.Server.MDIMain.OnNewManualFormLoad(Object sender, EventArgs e) in D:\UNet.Server\MDIMain.cs:line 575
Regards,
Gareth.
|
|
|
|
|
I doubt it's truly out of memory, unless you're allocating huge objects somewhere. How much is being used when this exception occurs?
|
|
|
|
|
Not to sound critical of your, but this is usually caused by coding errors, rather than machine issues. Are you possibly getting into an infinite loop somewhere during this process? There are also some unsafe methods being called. Are you sure of the return from these?
only two letters away from being an asset
|
|
|
|
|
Hi,
Think i've solved it. I was building up a collection of controls which wasn't needed because i can use the this.Controls collection instead. Seems to be working fine now as i can have 20 odd forms open and it doesn't crash.
Regards,
Gareth.
|
|
|
|
|
Hi all,
i'm preparing an exe where i have to get the records from the dataset and display in the listbox.
when there is records then everything is good, when there is no records returned then i have to check the condition in the form load event and i have to close the exe.
this exe will autorun in an installer.
when i close the form in form_load event then the program.cs file is throwing error.
public partial class frmChkStatus : Form
{
public string ConString = string.Empty;
public frmChkStatus()
{
InitializeComponent();
try
{
OdbcConnection strCon = new OdbcConnection();
strCon.ConnectionString = "DSN=STUSTATUS;LOGINID=STU;PWD=ANY";
strCon.Open();
string strExamCnt = "Select DISTINCT ME.stu_NB from MBR_STU ME where Me.STATUS_FL = UPPER('Y')";
OdbcCommand myCommand = new OdbcCommand(strExamCnt, strCon);
DataTable dt = new DataTable();
OdbcDataReader reader = myCommand.ExecuteReader((CommandBehavior.CloseConnection));
dt.Load(reader);
if (dt.Rows.Count <= 0)
{
//lblResult.Text = "No Records Found";
// Application.Exit();
ActiveForm.Hide();
//lstExamCodes.Visible = false;
}
else
{
//lblResult.Text = dt.Rows.Count + " Records found";
lstExamCodes.DataSource = dt;
lstExamCodes.DisplayMember = dt.Columns[0].ColumnName;
}
}
catch (Exception ex)
{
MessageBox.Show("Exception occured while retrieving STUDENTS.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void btnExit_Click(object sender, EventArgs e)
{
frmChkStatus.ActiveForm.Close();
}
}
}
PLEASE LET ME KNOW HOW TO CLOSE THE FORM WHEN THERE IS NO RECORDS AND CONTINUE TO OTHER INSTALLERS EXECUTION
M.MohanVamsi
|
|
|
|
|
Your code looks fine to me. I compiled it and ran it just fine. What error is being thrown?
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
This is the winforms application.
i'm getting error in program.cs file.
when i close the form it is giving the following exception.
System.ObjectDisposedException was unhandled
Message="Cannot access a disposed object.\r\nObject name: 'frmChkStatus'."
Source="System.Windows.Forms"
ObjectName="frmChkStatus"
StackTrace:
at System.Windows.Forms.Control.CreateHandle()
at System.Windows.Forms.Form.CreateHandle()
at System.Windows.Forms.Control.get_Handle()
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at CheckStatus.Program.Main() in C:\Documents and Settings\MedikonM\My Documents\Visual Studio 2005\Projects\CheckStatus\CheckStatus\Program.cs:line 22
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
in short the exception is
ObjectDisposedException was unhandled.
Cannot access a disposed object.
Object name: 'frmChkStatus'.
M.MohanVamsi
|
|
|
|
|
Application.Run(new frmChkStatus());
during this peice of code i'm getting error. this code is in program.cs in static void Main()
M.MohanVamsi
|
|
|
|
|
Ok. Looking at all the code in the OP, all that code was in the forms constructor. What does your code for closing the form in frmChkStatus_Load look like?
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
there is no code in the form load event. initially when the form loads itself it has to connect to database and check whether there is any records or not.
if there is no records then exe has to close with out loading the form.
that is my requirement.
M.MohanVamsi
|
|
|
|
|
Hi
I have a form which is being used by a user to send an e-mail.
the problem I have is thta if a user clicks enter whilst in the textbox(message) then the e-mail form is submitted.
Bascially when they press enter I want them to be able to move onto the next line of the textbox not send the message
cheers
|
|
|
|
|
You need to set both Multiline and AcceptsReturn to true .
Hope this helps.
Matthew Butler
|
|
|
|
|
when i try that in c# it says that the textbox does not contain a defintion for accepts return
code:
tb_message.AcceptsReturn = true;
any more suggestions?
|
|
|
|
|
I'm not sure why it doesn't exist: (I've just tried it successfully compiling under .Net 2.0).
I am assuming when you say 'TextBox'... you are refering to System.Windows.Forms.TextBox not a System.Windows.Forms.RichTextBox .
If you are using a RichTextBox:
On the form (where the enter button is) there will be a property called AcceptButton ... set this to null.
Otherwise I can't help you.
Matthew Butler
|
|
|
|
|
its using System.Web.UI.WebControls;
is this what you mean?
its not a richtextbox
thanks so far
|
|
|
|
|
In that case:
tb_message.TextMode = TextBoxMode.MultiLine;
This should work. (But I've never used web controls so it might not).
Matthew Butler
|
|
|
|
|
hi that worked!!
but how would i use: AcceptsReturn
i cant find the right bit of code that works for web controls
thanks so far!!
|
|
|
|
|
AcceptsReturn is only for System.Windows.Forms.TextBox (not Forms.RichTextBox or the WebControls.TextBox).
Setting TextMode to MultiLine should be the only thing you need to do.
Matthew Butler
|
|
|
|
|
no I am afraid that doesnt work, the form still sends even if i put in the bit of code you posted, thanks anyway i will keep trying
|
|
|
|