|
One of our customers receives an error message while running our application and many other applications on their computers. The error message is in German: "Win32Exception (0x80004005): Fehler beim Erstellen des Fensterhandles" which likely corresponds to "Win32Exception (0x80004005): Error while creating window handle".
Now we are trying to find out how that is caused.
When searching the web, there is a lot of confusion about those "handles". When looking into Windows Task Manager: which column in the Processes tab does correspond to the "correct" type of "handles": "Handles", "User objects", "GDI objects", ... (found all of them)
Or better take Process Explorer, and look at which columns?
And: what's the limit of those handles (system-wide, per application, ...)? (Found numbers from 1000 for the application to 16 million for the system; Process Explorer shows currently some 47000 Handles system-wide on my PC...)
Thanks a lot for trying to help me get rid of the confusion.
|
|
|
|
|
The max number of handles has values as both pre-process and system-wide, depending on the version of Windows you're talking about and the conditions under which it is running. It's not exactly a straight forward answer. Read this[^] for more information.
Truthfully, if you're getting this message, you might want to look at the Task Manager Handles column on the affected machines, not yours. There are cases where software leaks resources and handles, exhausting the system handle pool and causing problems like this. Usually the culprit process will stand out prominently. It's very rare to see a process go over 10,000 handles.
I had a Dell OSI service leak handles years ago, showing over 100,000 handles in that one process alone, before causing Windows to lose it's mind generating all kinds of problems over every other process that was running.
|
|
|
|
|
Thanks for this information.
According to the link you provided, some 16 million handles are allowed, but allocating handles in handle pages may reduce the number.
So things are complicated to analyse: on the custumer's computer, an application used up some 22 thousand handles when our application crashed, but at a different crash that application was below 1000 handles... And even with 22000 handles: that's some 1.5% of available system resources, we will hardly be able to convince the manufacturer of that program that they do something terribly wrong thus causing our application to crash...
By the way, how can an existing window handle be lost? In one case, our application crashed at an Invoke: the window handle did no more exist. A dialog had been opened, a control with its own window handle had been used succesfully; then the user had a break, the computer was locked (session switch event); after unlocking an hour later, the user did something else on the computer before using our program again, and then it immediately crashed due to the missing handle. I do not understand that. We did not Dispose() of it.
And all those problems happen with one single customer only, hundreds other customers never experience such problems (and remote access is not possible here: everything top secret).
|
|
|
|
|
Bernhard Hiller wrote: how can an existing window handle be lost?
Open a handle to an object and never properly close it, then orphan it by letting the variable that was holding the handle fall out of scope.
In a .NET app, that's quite easily done by, say, creating a Graphics object and never calling Dispose on it when your done with. Or by allocating a Font, Brush, Pen, Stream, ... by no means an exhaustive list.
Bernhard Hiller wrote: In one case, our application crashed at an Invoke: the window handle did no more
exist. A dialog had been opened, a control with its own window handle had been
used succesfully; then the user had a break, the computer was locked (session
switch event); after unlocking an hour later, the user did something else on the
computer before using our program again, and then it immediately crashed due to
the missing handle. I do not understand that. We did not Dispose() of it.
I don't have a clue there. You'd have the find out what else is running on the machine, such as virus scanner, and see if you can replicate the problem outside of their environment.
|
|
|
|
|
Hi
i have two forms , first form has a datagrid to show Rows record of table and Second Form is the details of every record in dataGrid , when we double Click the row .
In the Second Form , I need to Update Records . So I check the record ("RegNo") is Duplicate for a specific Year.
Here is My code . But I couldn't Update the Records ...:
-----
try
{
if (txtFname.Text == FnameDataGrid && txtLname.Text == LnameDataGrid
&& txtRegNo.Text == RegNoDataGrid && txtYearReg.Text == YearRegDataGrid)
{
OleDbConnection ocn_Edited = new OleDbConnection(ConnectionStringEdited);
OleDbCommand ocmd_Edited = new OleDbCommand();
ocmd_Edited.CommandText = @"UPDATE RegTable SET FNAME=@p1,LNAME=@p2,
YearReg=@p3,RegNo=@p4,
WHERE YearReg=@g1
AND RegNo=@g2";
ocmd_Edited.Parameters.Clear();
ocmd_Edited.Parameters.AddWithValue("@p1", txtFname.Text);
ocmd_Edited.Parameters.AddWithValue("@p2", txtLname.Text);
ocmd_Edited.Parameters.AddWithValue("@p3", txtYearReg.Text);
ocmd_Edited.Parameters.AddWithValue("@p4", txtRegNo.Text);
ocmd_Edited.Parameters.AddWithValue("@g1", YearRegDataGrid);
ocmd_Edited.Parameters.AddWithValue("@g2", RegNoDataGrid);
ocmd_Edited.Connection = null;
ocmd_Edited.Connection = ocn_Edited;
ocn_Edited.Open();
ocmd_Edited.ExecuteNonQuery();
ocn_Edited.Close();
ocmd_Edited.Dispose();
ocn_Edited.Dispose();
MessageBox.Show(" ... This Table Updated ...");
frmShowGrd frmGrd = (frmShowGrd)Application.OpenForms["frmShowGrd"];
frmGrd.boolEdit = true;
frmGrd.FnameDataGrid_1 = txtFname.Text;
frmGrd.LnameDataGrid_1 = txtLname.Text;
frmGrd.YearRegDataGrid_1 = txtYearReg.Text;
frmGrd.RegNoDataGrid_1 = txtRegNo.Text;
this.Close();
}
else
{
OleDbConnection ocn = new OleDbConnection(ConnectionStringEdited);
strSql =@"SELECT RegNo WHERE RegNo=@s1 AND YearReg=@s2";
OleDbDataAdapter oda_Edited = new OleDbDataAdapter(strSql, ocn);
oda_Edited.SelectCommand.Parameters.Clear();
oda_Edited.SelectCommand.Parameters.AddWithValue(" @s1", txtRegNo.Text);
oda_Edited.SelectCommand.Parameters.AddWithValue(" @s2", txtYearReg.Text);
DataTable dt_Edited = new DataTable();
dt_Edited.Clear();
oda_Edited.Fill(dt_Edited);
if (dt_Edited.Rows.Count > 0)
{
MessageBox.Show("Already Exists!! ");
txtRegNo.Focus();
}
else
{
OleDbCommand ocmd_Edited02 = new OleDbCommand();
ocmd_Edited02.CommandText = @"UPDATE RegTable SET FNAME=@t1,LNAME=@t2,
YearReg=@t3,RegNo=@t4,
WHERE YearReg=@e1
AND RegNo=@e2";
ocmd_Edited02.Parameters.Clear();
ocmd_Edited.Parameters.AddWithValue("@t1", txtFname.Text);
-----
I don't don't where's my Mistake .
Plz Help Me .
Thanks
modified 3-Sep-13 8:16am.
|
|
|
|
|
smh1392 wrote: But I couldn't Update the Records
What does that mean? Do you get an error message? If so, tell us the message. Does the table contain values different from those you expected? Does "first form" still show old values instead of the updated values? Anything else different from what you expected?
|
|
|
|
|
according to the code that I wrote above , I want to check the Value of "RegNo" (preventing duplicate the value of "RegNo" Field ), before Updating , but Always Execute this :
if (dt_Edited.Rows.Count > 0)
{
MessageBox.Show("Already Exists!! ");
txtRegNo.Focus();
}
So my database never Update ...
....
Thanks
|
|
|
|
|
Is there is way to invoke solid edge using c#
Thanks
|
|
|
|
|
|
Thanks For reply
But not get proper answer
|
|
|
|
|
If you give a proper question, you'll get a proper answer. As I asked, what is Solid Edge? I could have assumed it was the CAD package, but that would have been an assumption which could have ended up wasting your time by supplying details of something that was completely inappropriate.
|
|
|
|
|
I Want to create Solid Edge drawing using C# application
Thanks
|
|
|
|
|
Again, WHAT IS SOLID EDGE??
When speaking with humans, the quality of the answer you get is directly dictated by the quality of the question you ask!
|
|
|
|
|
Thanks..
Solid edge is a software for making mechanical 3D drawings...I is just Like Autocad Software used for mechanical engineers drawings..
Thanks
|
|
|
|
|
The best place to ask your question would be the makers of SolidEdge, not a bunch of people who have never heard of it.
|
|
|
|
|
Not sure - but this set[^] of samples on Codeplex might help you.
|
|
|
|
|
|
My SQL command returns 3 rows which is verified in a SQL GUI. I run the same code and SqlDataReader returns only 2 of them. The same sql command returns 3 rows with SqlDataAdapter. Here is my code.
ds has 3 rows.
using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["VPO"].ConnectionString))
{
string sql="SELECT DISTINCT A.account_id, A.fname, A.lname,
FROM T_Test1 A WITH (NOLOCK) JOIN T_Test2 AF WITH (NOLOCK) ON A.Account_id=AF.Account_id
WHERE account_status = 'A' AND A.card IS NOT NULL
AND A.dateFrom >= '09-02-2013 00:00:00' AND A.dateFrom <= '09-30-2013 00:00:00' AND AF.code = 'INE'";
SqlCommand command = new SqlCommand(sql.ToString(), connection);
command.CommandTimeout = 3600;
connection.Open();
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{}
}
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(command.CommandText, connection);
da.Fill(ds);
}
|
|
|
|
|
I know that isn't an answer to your question but why are you executing this query twice?
NarVish wrote: using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{}
}
and
NarVish wrote: DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(command.CommandText, connection);
da.Fill(ds);
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Just to show the difference, I added the SqlDataAdapter code. It will be removed.
|
|
|
|
|
what happens if the you run the query direct on your database?
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
If I run the query on database (SQL GUI), it is showing three records
|
|
|
|
|
What are the three rows, and which one is not being returned?
This message is manufactured from fully recyclable noughts and ones. To recycle this message, please separate into two tidy piles, and take them to your nearest local recycling centre.
Please note that in some areas noughts are always replaced with zeros by law, and many facilities cannot recycle zeroes - in this case, please bury them in your back garden and water frequently.
|
|
|
|
|
DataReader didn't read first record.
|
|
|
|
|
Hm. Unlikely - but suspicious.
I use code very similar to yours every day - and it has never missed out a row (particularly not the first row). I notice that the code you show a fragment of isn't the code you are actually using - can you post that bit? It seems unlikely that a "missing the first row" problem would be that specific is it was an SQlReader bug. Oh, and can you show the three rows worth of data and I'll try it here, see what happens.
This message is manufactured from fully recyclable noughts and ones. To recycle this message, please separate into two tidy piles, and take them to your nearest local recycling centre.
Please note that in some areas noughts are always replaced with zeros by law, and many facilities cannot recycle zeroes - in this case, please bury them in your back garden and water frequently.
|
|
|
|
|