|
There is nothing native in the .NET BCL that'll do this for your. You'll have to call into (P/Invoke) the Win32 WNet (Windows Networking) API to get this information. Everything will come from the MPR.DLL file.
To enumerate the connected resources (mapped drives), you'll need to use the WNetOpenEnum , WNetEnumResource , and WNetCloseEnum functions. You'll also need to supply the structures used, NETRESOURCE , and the values for the constants used by WNetOpenEnum .
You can pickup the declarations for the functions, structures and constants from PInvoke.net, here[^].
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Back in my C++ days, I relied on BoundsChecker to help identify potential memory leaks and resource leaks since I write mainly server-based services that run 24x7.
With .NET, managed code and garbage collection, is there still a need for these third-party tools? What's your experience?
Also, can someone explain this...I have a console .NET application that starts up taking around 9K of memory. By the time everything gets loaded, Task Manager shows it taking around 20K. Fine. But when the console window is minimized, the memory (as reported by Task Manager goes down to like 3K! WTF?!
Barry Etter
|
|
|
|
|
Well the suite that BoundsChecker is in is changing to more of a profiling and performance tool. They actually have a free profiler (community edition) for VS.Net. Its not the best, but its not bad either. Compuware [^]
As for you memory question, if you look at any application, esp VS.Net when its up and then minimize it and there will be a difference in the memory used. I think that this is due to the OS getting rid of some of the memory pages that it does not need. I have observed this with all windows apps, not just console apps.
Steve Maier, MCSD MCAD
|
|
|
|
|
Yes there is such a use, but a CLR profiler is a better choice. Many classes in the .NET BCL (and third-party libraries) rely on native resources. These are unmanaged resources because the CLR does not manage them. File handles are a good example. FileStream (actually, any String ) implements IDisposable because there may be a file handle (there is for a FileStream ) or some other native resource that must be closed when finished. You must call the IDisposable.Dispose implementation when finished with such an object. If you are a class designer, you should follow the dispose pattern discussed in the .NET Framework SDK and other articles:
class MyObject : IDisposable
{
~MyObject()
{
Dispose(false);
}
void IDisposable.Dispose()
{
Dispose(true);
}
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
}
}
} Unmanaged resources will be freed aventually. There is no gaurantee of when the GC runs, however, and you should almost never call GC.Collect (repeated calls can greatly hinder the performance of your application). This is why IDisposable exists. The using block statement is good to make sure that - even in case of exception - your objects are disposed:
using (FileStream file = File.Open("file.txt", FileMode.Open))
{
} Is the same as:
FileStream file = File.Open("file.txt", FileMode.Open));
try
{
}
finally
{
if (file != null) ((IDisposable)file).Dispose(0;
} So, exceptions will still be thrown, but at least the file is disposed and the native file handle is released.
So, in a round-about way, you should be able to see that while objects are garbage collected, resources they use (i.e., unmanaged resources) are not. Using a profile will help you find those problems, although it's a good rule of thumb to always dispose of any object that implements IDisposable anywhere up the class inheritance hierarchy.
Profilers can also help you find bottlenecks in your code; any platform is susceptible to that since it's typically human fault.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hi People,
I have a problem with changing the BackColor of a System.Windows.Forms.DataGrid cell. Actually I don't want to change the whole Style of the DataGrid - what I want is to change just the backcolor of an exact Cell that corresponds to certain requirements.
Does anyone knows how can this be done. I have looked in the MSDN and I'm starting to believe that this is not possible.
I would be grateful for any help.
|
|
|
|
|
hi,
I wrote an article for datagrid and its custom formattings. Please go through the entire article. Sure you will get the answer. Your requirement is mentioned in the third section of my article.
Take idea from that and try to impliement in your application.
You can view the article infomation on my profile.
http://www.codeproject.com/csharp/Apply_DataGridTableStyle.asp
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Hi Sreejith Nair,
really thank you for your fast answer. I downloaded your sourse and there i found everything I need. Really much obliged for your help
Kamen
|
|
|
|
|
I have a web application running on a server which will authenticate a user against a user name and password. Once authenticated this should pass a url to another server with the username and password as querystring. These two application are different. I tried using server.transfer but it does not work and i came to know it will not work between two different application in two different servers. I also donot want the query string to be visible as it is not secure. can any body help. response.redirect reveals the passwords. i also cannot encrypt the password as the second application does not know that the password is encrypt. i have no control over the second web application. It is a 3 rd party stuff.
any help appreciated
anand
|
|
|
|
|
hi,
i think you will instant answers once if you submit thsi queary on Asp.Net forum.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Hi. I need to add the help to my application. I want to add a chm file. I'm trying with HelpProvider, but it only shows the help pressing F1. How can I show it pressing a main menu item?
Regards,
Diego F.
|
|
|
|
|
hi,
Eg 1.
Write this much in code in your menu event handler
System.Diagnostics.Process.Start(Hlp.HelpNamespace.ToString());
Eg 2.
You can use app.config file to store your .chm file and then try call your .chm file through starting a process.
System.Diagnostics.Process.Start(ConfigurationSettings.AppSetting[0].ToString())
Both are using Process.Start() method to call your external .chm file.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Thank you, but where is the dll to use System.Process? I can't find it in Visual Studio 2003 Professional.
|
|
|
|
|
hi,
System.Diagnostics.Process.Start(Hlp.HelpNamespace.ToString());
if you are trying to show help using app.config then you need to add a namespace called
using System.Configuration;
And then you can use like this
System.Diagnostics.Process.Start(ConfigurationSettings.AppSettings["helpfile"].ToString())
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Thank you! It's working now
|
|
|
|
|
You don't need the .ToString() calls. Both HelpNamespace and AppSettings[] return Strings to begin with. Why execute .ToString() on a String object?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I would like to cretate excel files with my app written in C#, is it possible?
Does someone have an example?
thanks
|
|
|
|
|
hi,
I would like to cretate excel files with my app written in C#, is it possible?
Do you want to export your data into excel file format or You want to create a excel sheet from C#.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Export them, i have my data sorted in files (text files) someth like this:
STATE X Y
1 2112 54545
2 344 342 etc..
I need to create diagrams from this data, and because of that I need a File to be opened in Excel
|
|
|
|
|
hi,
Oki. Please go through this link. This is your correct requirement.
http://www.experts-exchange.com/Programming/Q_20970156.html
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
|
THANKS
|
|
|
|
|
Hi,
Which one is faster ?? Value Type or Reference Type.
Regards,
Hatim Ali.
|
|
|
|
|
hi,
I don't know in which sence that you are asking 'Value Type or Reference Types are fast'. I recommand you to read some C# syntax and C# basics.
Value type and reference types are two type of Common Type System. We can say all numeric types are value type and which are stored in stack memory. Variables of reference types, referred to as objects, store references to the actual data. Reference type store data in Managed Heap memory.
And the visibility of both types are entirly different.
In some cases we need to convert value type to reference type or reverse. So this is also possible.
Converting value type data into reference type data is called BOXING.
Converting Reference type data into value type data is called UNBOXING.
I recommand you to read MSDN or some book which explain the C# language.
**************************
S r e e j i t h N a i r
**************************;)
|
|
|
|
|
Objective answer: Value types are faster.
Notes:
If you have a finite (and preferably short) storage requirement, value types (for example a structure) are your best friends. But use them lavishly and you will end up with a Stack overflow.
|
|
|
|
|
Here is my problem:
I have done a web application; on this web application you can start a "slideshow". This slideshow consists of four pages that display data in tables and graphs. Each page get a lot of data from the database (SQL Server) and some of the pages use a lot of nestled ArrayLists to calculate the data before it's presented. Everything is done in c# and I use the data application block from MS.
The problem: I start the problem and the pages are displayed fine (the user can choose the delay in seconds before the next page are displayed, in this case 10 seconds). After 30 minutes - x hours Internet Explorer just hangs (the whole page turns white and no code is executed). No error turns up in my errorlog either.
I thought it had something to do with IE, so I've started to do a Windows Form application of this instead. The same (?) problem happens again. The program eats CPU and after 30-60 minuts the CPU is at 100% and the application almost stalls. I have run CLR Profiler but I don’t know how to read the results.
Can anyone help me how to get further with this problem? I’m starting to think if I have the same problem both on my web application and on my windows application? And if so, what is eating CPU? The pages are really simple, no multithreads, just get data in a dataset, transform the data and display it?
Thanks for any help, tips how to get further!
Rgds,
Stefan
|
|
|
|