Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. problem with writing an event log

problem with writing an event log

Scheduled Pinned Locked Moved C#
debugginghelptutorial
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tasumisra
    wrote on last edited by
    #1

    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

    J L D N 4 Replies Last reply
    0
    • T tasumisra

      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

      J Offline
      J Offline
      jojoba2010
      wrote on last edited by
      #2

      Can u write down or Upload this class ! So we can see where is the problem ?

      1 Reply Last reply
      0
      • T tasumisra

        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

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        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]


        T 1 Reply Last reply
        0
        • T tasumisra

          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

          D Offline
          D Offline
          Dan Mos
          wrote on last edited by
          #4

          You could try:

          Application.StartupPath

          The only difference is in the "\" so Application.StartupPath => "C:\Data\Blah" and AppDomain.CurrentDomain.BaseDirectory => "C:\Data\Blah\" As for the AppDomain.CurrentDomain.RelativeSearchPath: if you do not create it specifically in code something like this:

          domain.AppendPrivatePath("MyCustomAssembly");

          it will return empty string.

          1 Reply Last reply
          0
          • T tasumisra

            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

            N Offline
            N Offline
            Not Active
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            • L Luc Pattyn

              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]


              T Offline
              T Offline
              tasumisra
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups