|
kASTRATOR wrote: objects
If you mean .NET objects then...
You can use the System.Diagnostics namespace to get process information. From there you can get the paths of any executables or dlls etc, you can load these using the System.Reflection namespace and then scan through the assemblies using Reflection for the objects you want. You probably can't get a copy of the objects currently in memory as Windows and the framework will disallow this (although there might be a way).
Formula 1 - Short for "F1 Racing" - named after the standard "help" key in Windows, it's a sport where participants desperately search through software help files trying to find actual documentation. It's tedious and somewhat cruel, most matches ending in a draw as no participant is able to find anything helpful. - Shog9
Ed
|
|
|
|
|
Hi;
Thanks for your answer.
I did study this possibility but I could'nt find a way to get references to .NET Objects.
By Reflection all I can have is the structure of the loded modules but I can't actually see which calsses have been instanciated , how many times and what are the references to these instances.
I know it is possible though because CLR Profiler can generate a snapshot graph of managed memory with the reference and memory adresses of each .NET object.
|
|
|
|
|
kASTRATOR wrote: CLR Profiler
Yes but is that using Managed or Unmanaged code. If it's C++ with some C++/CLI involved then it might be able to since it can inject itself into processes.
I havn't tried any of this, just giving you my thoughts. I havn't even used the CLR Profiler.
If the profiler is managed (which I doubt) then you can take a look through it's code with Reflector.
Did you know that you can get the source code to the profiler. Just google for CRL Profiler and the first result will be for .NET 1.1. A few results later (~5) there is a blog which contains a link to one for .NET 2.0.
Maybe this will help you if you look through the source code.
|
|
|
|
|
As you advised; I just took a look to see how CLR Profiler manage scanning memory.
It seems he's using a C++ unmanaged library that goes with pointers arithmetics.
I would like to avoid going through pointers; I'd rather find a solution to do it in C#.
|
|
|
|
|
To be honest I don't think that you'll be able to avoid using pointers, the only way would be to use a wrapper around some stuff that did use pointers
Formula 1 - Short for "F1 Racing" - named after the standard "help" key in Windows, it's a sport where participants desperately search through software help files trying to find actual documentation. It's tedious and somewhat cruel, most matches ending in a draw as no participant is able to find anything helpful. - Shog9
Ed
|
|
|
|
|
I'll try to implement an algo similar to GarbageCollector one. With root references and scanning through the tree structure of each root. It won't be as generic as I wanted to. But going through pointers woul be very expensive in time for me.
|
|
|
|
|
kASTRATOR wrote: But going through pointers woul be very expensive in time for me.
That's whats most important
Formula 1 - Short for "F1 Racing" - named after the standard "help" key in Windows, it's a sport where participants desperately search through software help files trying to find actual documentation. It's tedious and somewhat cruel, most matches ending in a draw as no participant is able to find anything helpful. - Shog9
Ed
|
|
|
|
|
Hello,
I am developing a web app and trying to use Enterprise Library 2.0. I am using it for logging for now. I achived the logging on a flat file but when I tried to start doing the logging by using a DataBase Listener. I failed.
Here's how I am using it after including all possible references to my web app.
I configured a datasource with following attributes setup:
-Server (my server name)
-Database (my database in my server)
-Integrated Security (I used API.. something, false, true and I even tested after removing this tag aswell).
-user (my user name)
-pwd (my password)
Then I configured a Database Listner and gave the reference of my datasource.
Then I configured a Logging block by adding different categories and then I added reference to my Database listner in categories.
I also tested by adding and removing following in web.config within CodeDom tag:
type="Microsoft.CSharp.CSharpCodeProvider,
System, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"
compilerOptions="/d:TRACE" />
----------------
After doing this all when I try to log an entry after specifing the category to the entry and other required attributes. NOTHING HAPPENS in tables I generated after running the script file provided by Best Patterns and Practices team. I couldnt log any data.
Is there anybody who can help me or tell me what I am doing wrong?
|
|
|
|
|
Hi every body!
I need the C# code to back up a database and to restore it including sql code(using sql server). There should be ways to select the back up location and to select the backup file to restore. I'm thankful in advance if somebody can kindly provide me this help....please.
-- modified at 9:17 Wednesday 26th July, 2006
|
|
|
|
|
There are articles all over the web on how to do this. Just fire up Google or Search through the articles on this site.
Formula 1 - Short for "F1 Racing" - named after the standard "help" key in Windows, it's a sport where participants desperately search through software help files trying to find actual documentation. It's tedious and somewhat cruel, most matches ending in a draw as no participant is able to find anything helpful. - Shog9
Ed
|
|
|
|
|
In which situation we have to use abstract class & interface?
lavate
|
|
|
|
|
lavate malllik wrote: In which situation we have to use abstract class & interface?
It depends on your requirements, some times they can be interchanged, some times they cant.
|
|
|
|
|
Probably this can help you:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbconabstractclassesversusinterfaces.asp
http://www.codeproject.com/csharp/abstractsvsinterfaces.asp
|
|
|
|
|
1) An abstract class is like an interface with some fuctionality predefined (something an interface cannot have).
2) Multiple inheritance of classes is not possible.
3) Multiple implementation of interfaces is possible.
With these 3 bits of information you should be able to answer your own question.
|
|
|
|
|
Hi all,
I'm fresh man of OOP. so I want know When use static method and when use non static method ?
Any guidelines for use non static method or static method?
c# code sample:
class myclass
{
public myclass() {}
private int _i= 0;
public int Value
{
get { return _i;}
set {_i= value; }
}
public static int GetDoubleValue(int value)
{
return 2 * value;
}
public static int GetDoubleValue(myclass c)
{
return 2 * c.Value;
}
}
class myclass
{
public myclass() {}
private int _i= 0;
public int Value
{
get { return _i;}
set {_i= value; }
}
public int GetDoubleValue()
{
return 2 * this.Value;
}
}
|
|
|
|
|
Use static methods where you imagine the method would be called by someone who doesn't have an instance of your class. For example, a method that creates a class instance needs to be static. Often, a method is static because it's the only method a user is likely to call in a given instance, it doesn't require any state ( static objects are not tied to an instance, and so have no state beyond static variables ) and so a static method means they are not forced to create an instance just to call a method.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi Christian Graus,
Thanks for your reply.
I know that differents between static method and non static, just be at a loss to when use a static method or non static one.
Christian Graus wrote: static objects are not tied to an instance
This is best answer about this question. I will spend more time think about it.
do you have any guideline about it?
Thanks again.
|
|
|
|
|
Here is a great example:
http://www.pp.rhul.ac.uk/~george/PH2150/html/node48.html[^]
The way I understand it, static methods are not object-specific. A static method will always only have one instance, irrespective of what object invokes it.
(Look at the sheep example, old McDonald explains it better than I do)
you can't forget something you never knew...
|
|
|
|
|
hi evilnoodle,
Thanks for your reply.
I have read the article your gave. It's simple but helpful for me.
-- modified at 8:58 Wednesday 26th July, 2006
|
|
|
|
|
You would want to use static methods when it wouldn't make sense to create an instance fo the class for it.
For example:
<br />
Math myMath = new Math();<br />
myPath.sqrt(3.14);<br />
Wouldn't make sense. You don't want to have to create a Math object just to use the square root function. Instead, you make the square root function a static method of the Math class, so you can just say
Math.sqrt(3.14);
Hope that helps some.
using System.People;
Person me = new Person();
me.Certifications = null;
me.Experience = little;
me.WantsToLearn = true;
me.InSchool = true;
me.AskQuestions("C# .NET 2003");
|
|
|
|
|
hi MartyExodus,
MartyExodus wrote: Hope that helps some.
yeah, It's helpful to me.
more and more answers help me understand when use a static method.
Thanks a lot.
|
|
|
|
|
A good time to 'investigate' using a static method is if no 'instance' state needs to be persisted, read, or changed in the method.
|
|
|
|
|
hi A.A.
A.A. wrote: no 'instance' state needs to be persisted, read, or changed in the method.
is detailed with
Christian Graus wrote: static objects are not tied to an instance
Thanks a lot.
|
|
|
|
|
I am developing a Windows Service under VS 2005. Within the code some shared network directories have to be enumerated but when the code attempts to verify the existence of any one of those directories with code similar to: Directory.Exists("\\somedir\subdir") the function returns false every time apparently because network authentication is not automatically done by Directory.Exists. Can anyone point me in the write direction (e.g. example) of what I must do programatically to ensure the network authentication is in place to allow this command to succeed in a Windows Service when using UNC names?
Thank you...
|
|
|
|
|
Never mind. Just had to set up the proper service logon.
|
|
|
|