problem with writing an event log
-
Hi Guys, I am writing an application where i need to log errors and some information,so for this i have written a class that is working perfectly fine when in debug and in re;ease mode but when i am making an exe and trying same application logs have not been written. am using string baseDir = AppDomain.CurrentDomain.BaseDirectory + AppDomain.CurrentDomain.RelativeSearchPath; to retrive the directory location... can you guide me where i am lost. Thanks Vikas
vikas da
-
Hi Guys, I am writing an application where i need to log errors and some information,so for this i have written a class that is working perfectly fine when in debug and in re;ease mode but when i am making an exe and trying same application logs have not been written. am using string baseDir = AppDomain.CurrentDomain.BaseDirectory + AppDomain.CurrentDomain.RelativeSearchPath; to retrive the directory location... can you guide me where i am lost. Thanks Vikas
vikas da
Can u write down or Upload this class ! So we can see where is the problem ?
-
Hi Guys, I am writing an application where i need to log errors and some information,so for this i have written a class that is working perfectly fine when in debug and in re;ease mode but when i am making an exe and trying same application logs have not been written. am using string baseDir = AppDomain.CurrentDomain.BaseDirectory + AppDomain.CurrentDomain.RelativeSearchPath; to retrive the directory location... can you guide me where i am lost. Thanks Vikas
vikas da
Hi, check the value of baseDir; does it end on a backslash? does the folder exist? can you create a file there? why don't you use Environment.GetSpecialFolder? ApplicationData is probably what you want. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
[The QA section does it automatically now, I hope we soon get it on regular forums as well]
-
Hi Guys, I am writing an application where i need to log errors and some information,so for this i have written a class that is working perfectly fine when in debug and in re;ease mode but when i am making an exe and trying same application logs have not been written. am using string baseDir = AppDomain.CurrentDomain.BaseDirectory + AppDomain.CurrentDomain.RelativeSearchPath; to retrive the directory location... can you guide me where i am lost. Thanks Vikas
vikas da
You could try:
Application.StartupPath
The only difference is in the "\" so
Application.StartupPath
=> "C:\Data\Blah" andAppDomain.CurrentDomain.BaseDirectory
=> "C:\Data\Blah\" As for theAppDomain.CurrentDomain.RelativeSearchPath
: if you do not create it specifically in code something like this:domain.AppendPrivatePath("MyCustomAssembly");
it will return empty string.
-
Hi Guys, I am writing an application where i need to log errors and some information,so for this i have written a class that is working perfectly fine when in debug and in re;ease mode but when i am making an exe and trying same application logs have not been written. am using string baseDir = AppDomain.CurrentDomain.BaseDirectory + AppDomain.CurrentDomain.RelativeSearchPath; to retrive the directory location... can you guide me where i am lost. Thanks Vikas
vikas da
tasumisra wrote:
,so for this i have written a class
Why reinvent the wheel? There are plenty good frameworks for this already like, Enterprise Library, whose pupose is to create a library of common tasks to save developers from having to recreate it each time.
I know the language. I've read a book. - _Madmatt
-
Hi, check the value of baseDir; does it end on a backslash? does the folder exist? can you create a file there? why don't you use Environment.GetSpecialFolder? ApplicationData is probably what you want. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
[The QA section does it automatically now, I hope we soon get it on regular forums as well]
Hi Luc, while debugging i have checked the following check the value of baseDir; it comes with right path does it end on a backslash? yes it end with \\ does the folder exist? yes the folder exist and it none but the base directory of my code path can you create a file there? yes files created there when running in debug or release mode but when ever i am making an exe and installing it to another system files are not created.
vikas da