|
I did.
1.) It happens when an exception occurs within Framework .NET. The solution is to put a breakpoint before a certain excpetion occurs (you have to find out an approximate location in the code) and then debug step by step up to the broken code. The fastest way is to put a breakpoint before the method call (not inside it's body).
2.) Check if your use "Debug" configuration (not "Release"), because some stuff may be optimized out.
3.) You are able to debug only if you reference to a project (when u can access the code through IDE), not just a DLL file.
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
I want to read external application exe name when it’s focused. It’s like this.
Consider now MSWord, Notepad and Google Talk are running in my computer as minimized (nothing focused). If I will click on notepad icon at taskbar to restore it, I want to pop-up a message box to say application name as Notepad.exe (because now it’s the focused application).
Please help me. Thanks.
|
|
|
|
|
Hello,
I think the "System.Diagnostics.Process" in combination with "user32.dll" method "IsIconic" could help you.
I did a little test:
First I Import the method from the user32.dll:
[System.Runtime.InteropServices.DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool IsIconic(IntPtr hWnd);
I declare two ArrayList: one for all processes (with mainwindowhandle), and one for the Procceses which state is Iconic.
using System.Collections;
private ArrayList ProcessesWithMainWindow = new ArrayList();
private ArrayList ProcessesIconic = new ArrayList();
Then I have a method which checks all Process.
If the process has a mainwindowhandle, it will be added to a ArrayList for further usage.
Additionally I enable the "EnableRaisingEvents" property of the processes and handle the "Exited" Event.
private void SearchRunningProcesses()
{
Process[] allRunningProcesses= Process.GetProcesses();
foreach(Process actProcess in allRunningProcesses)
{
if(actProcess.MainWindowHandle!=IntPtr.Zero)
{
if(!ProcessesWithMainWindow.Contains(actProcess))
{
ProcessesWithMainWindow.Add(actProcess);
actProcess.EnableRaisingEvents = true;
actProcess.Exited+=new EventHandler(actProcess_Exited);
}
}
else
{
actProcess.Dispose();
}
}
}
Then I added a method which validates the Processes inside the "ProcessesWithMainWindow " List, by checking "IsIconic".
If a processes mainwindow is iconic, I add it to the "ProcessesIconic" List.
If it is not iconic but is in the "ProcessesIconic" List, it would mean that the state of the meinwindow has changed and you could show your messagebox there.
private void ValidateProcesses()
{
foreach(object actObject in ProcessesWithMainWindow)
{
Process actProcess = actObject as Process;
if(actProcess.MainWindowHandle!=IntPtr.Zero)
{
if(IsIconic(actProcess.MainWindowHandle))
{
if(!ProcessesIconic.Contains(actProcess))
{
ProcessesIconic.Add(actProcess);
}
}
else
{
if(ProcessesIconic.Contains(actProcess))
{
ProcessesIconic.Remove(actProcess);
}
}
}
}
}
If the Exited event of a process get's fired, I remove the instance out of the collections, unregister the event and dispose it.
private void actProcess_Exited(object sender, EventArgs e)
{
Process actProcess = sender as Process;
ProcessesWithMainWindow.Remove(actProcess);
if(ProcessesIconic.Contains(actProcess))
{
ProcessesIconic.Remove(actProcess);
}
actProcess.Exited-=new EventHandler(actProcess_Exited);
actProcess.Dispose();
}
You can call the two methods in a tick or elapsed event of a timer.
SearchRunningProcesses();
ValidateProcesses();
Note: I just did a quick test, which means that it might not work under all conditions.
Hope it helps!
-- modified at 6:17 Tuesday 28th August, 2007
actProcess = null;
All the best,
Martin
|
|
|
|
|
Dear Martin,
Thank you very much for your valuable time and knowledge. Now I am trying to apply the method you mentioned. If there will be any question then I will continue this thread again. Thanks.
|
|
|
|
|
You are wellcome!
All the best,
Martin
|
|
|
|
|
Hi,
I'm currently in the process of developing an utility that executes the SQL Query's.
(More or less similar to SQL QUERY ANALYZER).
I have defined the Database name in the App.config file itself.
And , t's working fine.
Now the problem is, I need to modify the Database Name in the App.config while I select the
Database name from the Listbox automatically.
The app.config file code is
<configuration>
<appsettings>
<add key="QueryAnalyzer" value="Data Source=(local);Integrated Security=True;User ID=;Password=;Initial Catalog=Northwind">
Please any one help me in finding the solution
BhuMan
|
|
|
|
|
I am working on an existing c# code which reads .csv files.
Some of these files are about 120 MB in size.
When the program is going through these big files it produces the following error.
Message: "Exception of type 'System.OutOfMemoryException' was thrown."
I have been asked to solve this issue in the code.
Any thoughts please?
Thanks
|
|
|
|
|
Hello,
A wild guess:
Maybe you are not Closing / Disposing the file streams!
It would help us to help you, if you show some code snippeds.
All the best,
Martin
|
|
|
|
|
|
To me this happend when I created a non terminating recursion. Maybe you are hanging in some loop? Forgot to increase the index while creating new objects?
Rudolf Heijink
|
|
|
|
|
Hi People...
My boss (and project leader) comes from the Visual Object environment... and is concerned about the use of SortedLists because of memory performances.
Can somebody tell me when the Garbage Collector is called to clean sorted lists that are not used anymore?
I.E.: we use a sorted list to do some calculation in a method. When will this sorted list be cleaned? at the end of the method or when we call the dispose() method of the container?
Thanks a lot
|
|
|
|
|
Hello,
JoZ CaVaLLo wrote: and is concerned about the use of SortedLists because of memory performances.
This is what the documentation say:[^]
Operations on a SortedList object tend to be slower than operations on a Hashtable object because of the sorting. However, the SortedList offers more flexibility by allowing access to the values either through the associated keys or through the indexes.
JoZ CaVaLLo wrote: Can somebody tell me when the Garbage Collector is called to clean sorted lists that are not used anymore?
No, the GC will clean up your object when he wants and is able to do so!
But, he is only able if there are no references left, which hold the instance of the sorted List.
Therefor you have to call the Dispose() method.
The Dispose method frees the instance from unmanaged resources.
If you are creating and using an instance of the SortedList inside of a method, I would suggest a "using"-block.
sample code:
private void YourMethod()
{
using(SortedList yourSL = new SortedList())
{
yourSL.Add(....
}
}
If you have a SortedList instance as a member of a class, you should implement "IDisposable" in your class,
and dispose the instance of SortedList at the Dispose method of your class.
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(yourSL != null)
yourSL.Dispose();
}
base.Dispose( disposing );
}
Additionaly:
Interesting disussion here on the forum![^]
How To Dispose by Joe Duff[^]
Implement IDisposable by Scott Dorman[^]
Hope it helps!
All the best,
Martin
|
|
|
|
|
Hi Martin,
Martin# wrote: But, he is only able if there are no references left, which hold the instance of the sorted List.
Therefor you have to call the Dispose() method.
Martin# wrote: using(SortedList yourSL = new SortedList())
SortedList does not implement IDisposable, the code snippet will not compile.
A SortedList item will be garbage collectable as soon as no references to it
exist any longer.
An item in a SortedList will be garbage collectables as soon as the reference
to it inside the SortedList becomes the last reference AND the
SortedList becomes collectable.
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
|
|
|
|
|
Ooops!
True, Only have .Net 1.1 so I couldn't test it, but same with ArrayList and Hashtable!
Thanks, for pointing it out!
All the best,
Martin
|
|
|
|
|
Hi Joz,
The GC runs when it needs to run, i.e. when your process needs free memory
(because you are creating a new object, typically with the "new" keyword)
and the OS does not give it more memory, so it has to go and look if anything
it holds can be thrown out. The execution of the GC is not periodic, and
is not invoked by closing a scope (as in returning from a method).
A SortedList is not threated any different by the GC than any other object.
A SortedList item will be garbage collectable as soon as no references to it
exist any longer.
An item in a SortedList will be garbage collectables as soon as the reference
to it inside the SortedList becomes the last reference AND the
SortedList becomes collectable.
"garbage collectable" means the next time GC runs it will be able to collect
the object (i.e. actually collecting it, or putting it on the finalizing list,
which is handled by a separate GC thread).
SortedList does not implement IDisposable, the code snippet using (... SortedList)
will not compile, because SortedList does not implement IDisposable.
Hope this helps.
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
|
|
|
|
|
Is there any free open source viewers for .Net that supports SVG.
I tried with Adobe SVG viewer 3.03 ,but can't figure out any way to add it in the toolbox.
|
|
|
|
|
SVG needs to be installed on the client. Then you can generate SVG using any classes you like. The Adobe viewer is the file that your user needs to install, it doesn't get added to the toolbox.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi Christian ,thanks for your reply,It's Ok for a web application.But how could I display an SVG graph in a windows application.
I think I have to check out the older versions of adobe viewer for any activex controls.
-- modified at 5:08 Tuesday 28th August, 2007
|
|
|
|
|
|
Thanks vasudevan,this sounds cool. I will check it out, though I got solution in another way.
|
|
|
|
|
I went back to svg viewer 3.0 and there we have an activex control.
|
|
|
|
|
im looking for a custom textbox that when you enter some text it will automatically create space to the next entry.
ex: when entering the text "CODE PROJECT" in the textbox
it will automatically becomes "C O D E P R O J E C T" while typing
or
a textbox that can make an entry on an individual box.
|C|O|D|E| |P|R|O|J|E|C|T|
TheCardinal
|
|
|
|
|
Did you try the MaskedTextBox?
Life is not short... the problem is only how you organize yourself
|
|
|
|
|
Internal-Access is limited to the current assembly.
Internal Protected-Access is limited to the current assembly or types derived from the containing class.
after then i implemented it , for that i created window application project and a class library project.
in class library project namespace i did the following code
namespace ClassLibrary1
{
public class Class1
{
protected int aniket = 10;
protected internal int tushar = 20;
internal int pavan = 30;
}
}
and in the window application project , after adding the reference of class library project , in the class file , i did the following code.
namespace validation1
{
class Class2: Class1
{
void method()
{
//variable aniket and tushar are accessible in thederived class due to reason that they are protected inernal and protected respectively.
//while the member named pawan is not assessible, because it's datatype is intenal.
Is this all the difference between internal and internal protected.
I mean , i wanted to ask that the findings i did for these two access modifiers are correct , or there is somethig else , that is needed to be understood the difference between them.
}
}
}
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
You got something wrong.
Public = Accessible from everywhere
Protected = Accessible from class or derived classes.
Private = Accessible only from the same class (if you don't specify anything, by default it will be Private)
internal = Access is only for the same assembly.
internal means that if I\anyone-else download your class library file (dll) and try to use it, I won't be able to use the stuff that signed with "internal".
So what that you basically did was playing with the "Private" modifier.
Hope you get what I wrote (I can be not-understandable in the morning).
NaNg.
|
|
|
|