|
Hi
In recent times I often get an application error that it is impossible to create a new control object, because there are no more window handles left. The application is written in C# (.Net 1.1) and is used to create extensive content specific dialogues. At the moment I’m not quite sure how to identify the source of error. Within my object model, I use every time dispose() to destroy any existing graphical object. But it seems that this process doesn’t work correct. It is possible to retrieve the number of window handles that are currently used by an application? Last week I read a thread that states to locate the application process and then use the MainWindowHandle property in relation with EnumWindows to get the total count of all window handles. Unfortunately, I’ have no idea how to implement this procedure (especially how shall I use EnumWindows). Does anyone knows how to perform this task or does anyone have another idea to determine the total count of used window handles?
Thanks in advance
Erik
|
|
|
|
|
|
That’s right. In my opinion, I have used up all window handles. It doesn’t happen at once, but it is an ongoing process. It seems that I don’t destroy every created control. Therefore an advisor can process normally a lot of orders, before the error occurs.
|
|
|
|
|
Hi!
There's a thread on this topic a few entries down the page:
here
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Hi,
thanks for the excellent link. This is exactly what I was looking for. Using GetGuiResources shows that even if I dispose (or I think that I dispose them) the gui objects, not all used window handles were disposed. Just to give a small example:
Before opening an order : 204 / 375
After opening an order : 370 / 1988
After closing an order : 267 / 699
I guess that if everything would work correct the total numbers of available gui handles after closing an order should be the same as before opening the order. Is there any way to detect this memory leak?
Regards
Erik
|
|
|
|
|
Microsoft has a free tool called the CLR Profiler that can alert you to memory leaks. Commercial apps such as Ants Profiler also can alert you to memory leaks.
|
|
|
|
|
Hi all.
how can I fire a keydown / keyup event?
|
|
|
|
|
Look at the SendKeys class.
|
|
|
|
|
|
I've realized a custom UserNamePasswordValidator.
And I can't run my Service anymore.
if I remove the line :
tcpBinding.Security.Mode = SecurityMode.Message;
it works again, but without user validation....
here the source:
class Program
{
static void Main(string[] args)
{
ServiceHost myHost = new ServiceHost(typeof(classServerFunktionen));
NetTcpBinding tcpBinding = new NetTcpBinding();
tcpBinding.TransactionFlow = false;
tcpBinding.Security.Mode = SecurityMode.Message;
tcpBinding.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
myHost.Credentials.UserNameAuthentication.UserNamePasswordValidationMode = System.ServiceModel.Security.UserNamePasswordValidationMode.Custom;
myHost.Credentials.UserNameAuthentication.CustomUserNamePasswordValidator = new CustomUserNameValidator();
myHost.AddServiceEndpoint(typeof(IServerFunktionen), tcpBinding, "net.tcp://localhost:8777/MyProdService");
//Server starten
myHost.Open();
Console.WriteLine("The service is ready.");
Console.WriteLine("Press <enter> to terminate service.");
Console.ReadLine();
//Server schließen
myHost.Close();
}
}
public class CustomUserNameValidator : System.IdentityModel.Selectors.UserNamePasswordValidator
{
public override void Validate(string userName, string password)
{
if (null == userName || null == password)
{
throw new ArgumentNullException();
}
if (!(userName == "test1" && password == "1tset") && !(userName == "test2" && password == "2tset"))
{
throw new System.IdentityModel.Tokens.SecurityTokenException("Unknown Username or Incorrect Password");
}
}
}
//Implementierung des Interfaces mit den Serverfunktionen...
public class classServerFunktionen : IServerFunktionen
{
public String rights;
public String getMessage()
{
return "Hallo Session:" + OperationContext.Current.SessionId;
}
public String getMessage2()
{
return "Hallo2 Session:" + OperationContext.Current.SessionId;
}
}
and my interface:
[ServiceContract]
public interface IServerFunktionen
{
[OperationContract] //(ProtectionLevel = ProtectionLevel.EncryptAndSign)
String getMessage();
[OperationContract]
String getMessage2();
}
|
|
|
|
|
I get the error thet the ChannelDispatcher can't open his IChannelListener
|
|
|
|
|
I need code in C# to populate checkbox in gridview to delete records.
Please help.
Thank you
Saranya
|
|
|
|
|
SJSaranya wrote: populate checkbox in gridview to delete records.
Add a column to the datatable, which you want to assign as a data source to the gridview
like the following
dataTable1.Columns.Add("Name of My Column for the checkbox",typeof(bool),"0");
assign it as datasource.
kss
|
|
|
|
|
I have written code for windows application using C# where in on a button click, a new memo should be opened with email id, subject and body. I am using the code below
System.Diagnostics.Process.Start(String.Format("mailto:{0}?Subject={1}&Body={2}" , txtContEmail.Text.Trim(), strSubject, strBody));
The above code is working if the text specified in the variable strBody is short. But I have to create a body with the text given below
"Dear Customer,
Thank you for utilizing the the application.
The following license file(s) will expire in few days: .
The application will not operate with an expired license file. Please detach the license file attached to this e-mail and place it in the following location:C:\Program Files\SID\Bin. Replace the existing file with this new file.
Note: This file should only be saved in the before mentioned directory. Attempting to open the file may result in an “invalid file format” message.
Please also note that if you loose that license file and request to replace it, it would incur a USD 500 fee to cover the time and administration costs.
If our contact information has changed, please transfer this e-mail to the correct person and kindly provide us with his/her name, e-mail and phone number, thank you!
Don't hesitate to contact us if you have further questions.
Best regards,"
Because of this huge text nothing happens. But if I make the text shorter then the code is working. My default email account is Lotus Notes. Please help me.
Looney
|
|
|
|
|
Please - don't repost the same question so quickly. This is a volunteer based forum, where people get to your messages in their own time.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
How would I end another process from a C# app?
I do not want to call Process.Kill() as I have code that needs to run when the ApplicationExit event fires. I do not have a MainWindow so I can't call Process.CloseMainWindow(). Does anyone have another suggestion that I have missed?
|
|
|
|
|
Have you thought of putting in a kill method in the other process that you could call via remoting?
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I hadn't thought of that. I was hoping for a nice simple way like the CloseMainWindow() function that I might have missed but that is certainly an option. Thanks.
|
|
|
|
|
You could add a main form, and make it invisible.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
I gave that a go but if you set ShowInTaskBar to false the MainWindowHandle for the process is always 0 which prevents me from calling CloseMainWindow(). I have solved the problem with remoting now.
|
|
|
|
|
I'm glad that you solved it, and I'm glad that I managed to help even in a small way.
__DanC__ wrote: ShowInTaskBar to false the MainWindowHandle for the process is always 0
I know - it's a real bummer, which is why I didn't suggest this. Ho hum.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Ah, sh!t - sorry Pete, I voted you a 1 by accident (cack handed mouse skillz "r" us!)
Me: Can you see the "up" arrow?
User:Errr...ummm....no.
Me: Can you see an arrow that points upwards?
User: Oh yes, I see it now!
-Excerpt from a support call taken by me, 08/31/2007
|
|
|
|
|
No bother - I'm not in this for the votes. But thanks anyway.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hello to all.
My problem is, that I can't seem to understand how to pass the updating of my progressBar control to
the function it supposed to be updated by.
my function sits in a different class then my form and does some measurments that return values and
then it manipulates it for my bussiness needs.
the problem is that I want that function(called from a background worker thread in my form) that belongs to another class to be updating the progressBar on the form created in the main thread.
if I was inside the same thread background workerThread I don't have a problem using the reportProgress method, the problem is that start_ChannelA_Offsetting function belongs to another class
here is some relevant code, please help me...
private void frmPicoBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
PICO.start_ChannelA_Offsetting(ref updateProgress);
frmPicoBackgroundWorker.ReportProgress(updateProgress);
}
private void frmPicoBackgroundWorker_ProgressChanged(object Sender, ProgressChangedEventArgs e)
{
progressBarSampling.Step = updateProgress;
progressBarSampling.PerformStep();
}
public void start_ChannelA_Offsetting(ref int updateProgress)
{
if (!Opened)
{
MessageBox.Show("device is not opened!!!");
return;
}
this.SetChannel(Channel_A, A_enabled, A_coupling, range);
this.RunStreaming((short)timeIntervalMs, this.maxSamples, windowed);
this.totNumOfSamples = (this.numValues / 2) * offsetChA.Length;
try
{
int i, j = 0, t;
for (j = 0, t = 0; j < totNumOfSamples - 1 || t == offsetChA.Length; t++)
{
Thread.Sleep((this.numValues / 2) * Convert.ToInt32(this.Intervalms));
values_collected = this.GetValues(bufferA, bufferB, bufferC, bufferD, out overflows, numValues);
if (values_collected < numValues / 2)
{
if (t >= 0)
t--;
continue;
}
updateProgress = Convert.ToInt32((j / totNumOfSamples) * 100);
for (i = 0; i < values_collected; i++, j++)
{
if (j == totNumOfSamples - 1)
{
break;
}
bufferA_mV[i] = this.adc_to_mv(bufferA[i], realRange);
}
if (i < values_collected - 1)
break;
this.offsetChA[t] = (sumBuffer(bufferA_mV) / (double)(i));
}
}
catch (Exception e)
{
MessageBox.Show("Finishing in an orederly fasion");
Console.WriteLine(e);
this.Stop();
}
if (Opened)
{
this.Stop();
MessageBox.Show("finished all requested sampling");
}
}
all help will be most appreciated.
|
|
|
|
|
Y isn't anyone answering me???????????????
|
|
|
|