473,775 Members | 2,611 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 2857
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
15990
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
2047
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
9454
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
10268
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10107
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...
1
10048
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9916
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7464
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6718
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
5360
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
5486
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.