473,768 Members | 3,985 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

EventLog.Source Exists question....

I am trying to write to the EventLog from a WindowsService that I have written,
however when I check to see if the Event Log exists (which it does) it fails.

Here's the code.

if (EventLog.Sourc eExists(this.sz LogName.ToStrin g()) == false)

Here are all the iterations of the above that do not work:
if (!EventLog.Sour ceExists(this.s zLogName))
if (EventLog.Sourc eExists(this.sz LogName) == false)

It will work if I explicitly use the string value of this.szLogName, but it
is not my
prefered method.

Any thoughts?
Apr 24 '07 #1
2 2856
On Tue, 24 Apr 2007 08:08:05 -0700, Joe wrote:
I am trying to write to the EventLog from a WindowsService that I have written,
however when I check to see if the Event Log exists (which it does) it fails.

Here's the code.

if (EventLog.Sourc eExists(this.sz LogName.ToStrin g()) == false)

Here are all the iterations of the above that do not work:
if (!EventLog.Sour ceExists(this.s zLogName))
if (EventLog.Sourc eExists(this.sz LogName) == false)

It will work if I explicitly use the string value of this.szLogName, but it
is not my
prefered method.
So what you mean is that if you execute:
if (!EventLog.Sour ceExists("YourE ventSourceName" ))
it works while if you execute
if (!EventLog.Sour ceExists(this.s zLogName))
it fails?

Looks like this.szLogName does not contain what you expect it to contain.
Are you sure that you are setting the (correct) value of szLogName? How are
you initializing it?
Apr 24 '07 #2
Mehdi,

I have verified that it contains what I expect it to.

I've written that value to a debug file and it is what I expect, and well as
the
errors that arise because of the value.

Any other thoughts?
On Tue, 24 Apr 2007 08:08:05 -0700, Joe wrote:
I am trying to write to the EventLog from a WindowsService that I have written,
however when I check to see if the Event Log exists (which it does) it fails.

Here's the code.

if (EventLog.Sourc eExists(this.sz LogName.ToStrin g()) == false)

Here are all the iterations of the above that do not work:
if (!EventLog.Sour ceExists(this.s zLogName))
if (EventLog.Sourc eExists(this.sz LogName) == false)

It will work if I explicitly use the string value of this.szLogName, but it
is not my
prefered method.

So what you mean is that if you execute:
if (!EventLog.Sour ceExists("YourE ventSourceName" ))
it works while if you execute
if (!EventLog.Sour ceExists(this.s zLogName))
it fails?

Looks like this.szLogName does not contain what you expect it to contain.
Are you sure that you are setting the (correct) value of szLogName? How are
you initializing it?
Apr 24 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2381
by: José Joye | last post by:
I know, this kind of question has already been asked. However, I could not find an answer related to the minimal privilege required to be able to create a new event Source in the appplication event log. I have a service app that needs to access shares (therefore, I cannot not start it using the System account). This service needs not to be run with particular privilege. So, I use a account member of users' group. Doing so will fail...
4
4626
by: Steven | last post by:
I just downloaded the June 2005 release and I want to set up basic logging to log problems such as exceptions. I have created a category named Exceptions with the following: <category name="Exceptions"> <destinations> <destination name="Event Log Destination" sink="Event Log Sink" format="Text Formatter" /> </destinations> </category>
2
3546
by: Next | last post by:
Hello all, I have a windows service that was suppose to write some events into its own EventLog. I created the EventLog using the component on VS 2003 toolbar Added an installer for it. Set all the appropriate properties to assign the new Source to a new log. For some reason installutil.exe created the source in the correct log. But
1
15988
by: martin | last post by:
Hi, I'm having some problems with the System.Diagnostics.EventLog class in .NET 2.0 I need to recreate an event message source inside a new log but the messages keeps ending up in the old log?! I have simplified my code into this tiny snippet: EventLog.CreateEventSource("mySrc", "myLog1");
0
1818
by: rene | last post by:
I'm trying to use costome categories in my eventlog for a program I'm writing. But I have some problems with it, I cant get it to work. Checklist for how I did this. 1. Created a resourceful.mc content is like this. MessageId=0x1 Severity=Success SymbolicName=INSTALL_CATEGORY
0
869
by: Taps | last post by:
In the EventLog.Delete method, after you delete a log, it says that you can recreate the log, but then you cannot re-register the logsources (you had earlier created) (refer to the below notes). What's the rationale behind this design ? That means that I now have to have different new logsource names to get my program working. << This method first deletes the file holding the contents of the log. It then accesses the registry and...
0
893
by: TonyJ | last post by:
Hello! Below is a snippet which doesn't work as expected. Here I create a custom event log named MyLog and a source named MyTest but when I look at the MyLog the column which should display the source is empty. It should have displayed MyTest because that is my source. It looks like this Typ Datum Tid Källa ... Information 2007-10-30 16:16:53
2
1187
by: Dennis | last post by:
I have a service with the following startup code... When I start the service I see a new entry under... Computer Management(local) System Tools Event Viewer Application MyServiceLog <--- new entry
1
2046
by: Jeff | last post by:
hi ..Net 2.0 I've created the code below and think I've executed it. After I thought I've executed it I checked in EventLog on the computer (win2k3) and no entry was added. This could mean 2 things: - There are some logical errors in my code - The code wasn't actually executed
0
9576
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9407
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10017
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8840
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6656
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5283
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5425
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3534
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2808
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.