|
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.
|
|
|
|
|
code is right or wrong?
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
No, the definitions of internal and internal protected are wrong.
As I explained.
In the code you can totally erase the "internal", because you're only playing with private\public modifiers.
|
|
|
|
|
AS I SAID. the internal part could be erased from here.
What you did here is EQUAL to this:
protected int tusher = 20;
int pavan = 30;
which is also equal to this (by default):
protected int tusher = 20;
private int pavan = 30;
The internal thing only works OUTSIDE of the assembly, not the class, but the ASSEMBLY - means the WHOLE project, not a file or a namespace or a class, but THE WHOLE PROJECT.
|
|
|
|