Get LineNumber, MethodName, ClassName and so on

R

Rene Sørensen

I'm trying to make things alot easyer for my self, by useing a
formatet error report, but i need some info to do that, like etc...

MessageBox.Show( "Error In File: " + GetFileNAme() + " \n" + "Class
Name: " + GetClassName() etc.....

i have been looking at StackFrame, and this is ok, but only useable in
debug mode, anyone have any idea how to do this is release mode???

Thnks in Advanced

Rene
 
F

Franco, Gustavo

string nameSpace = this.GetType().Namespace;
string fullClassName = this.GetType().FullName;
string className = this.GetType().Name;

string fullPath =
Path.Combine(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath),
nameSpace.Replace(".", "\\"), className);

Usually the file name should be the same as Class Name and the path should
be the same as the namespace.... Of course you can change that. But if you
are methodic you can use it.

It doesn't work if your code will be obfuscated because you will get
something like a.D.v

Gustavo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top