472,950 Members | 2,211 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,950 software developers and data experts.

creating EventLog code, is this code correct?

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

string Log = "MIIS_AH";
if ((!(EventLog.SourceExists(Log))))
{
EventLog.CreateEventSource(Log, Log);
}
EventLog logEntry = new EventLog();
logEntry.Source = Log;
logEntry.WriteEntry("HELLOWORLD");

This code is part of a method with more code inside it. Below I've posted
more of that method just in case you need to see it (MIIS 2003, Provisioning
code). I have some problems with this code, no Connector Space objects are
created (not important what that is), so I added the EventLog code you see
above to my code for the purpose of debugging my code (I wanted to see if my
code actually was executed). As I've heard that I cannot use breakpoints in
the code here. Cannot as this code will be compiled to a .dll which MIIS
(microosft integrated indentry server) will execute. As far as I know it
won't execute debug code. But would be great if I'm wrong about it, as then
I've learned something new ;)

you see any reason why the eventlog code wasn't executed?

CSEntry csentry;
ConnectedMA connectedMA = mventry.ConnectedMAs["Bil 2"];
if (connectedMA.Connectors.Count == 0)
{
csentry = connectedMA.Connectors.StartNewConnector("Bil");
csentry.DN = connectedMA.CreateDN("id");
csentry["Bileier"].Values.Add(mventry["Bileier"].Value);
csentry["Bilmerke"].Values.Add(mventry["Bilmerke"].Value);
csentry.CommitNewConnector();
string Log = "MIIS_AH";
if ((!(EventLog.SourceExists(Log))))
{
EventLog.CreateEventSource(Log, Log);
}

EventLog logEntry = new EventLog();
logEntry.Source = Log;
logEntry.WriteEntry("HELLOWORLD");
}
Jul 15 '08 #1
1 2006
On Jul 15, 5:12*am, "Jeff" <it_consulta...@hotmail.com.NOSPAMwrote:
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

string Log = "MIIS_AH";
if ((!(EventLog.SourceExists(Log))))
{
EventLog.CreateEventSource(Log, Log);}

EventLog logEntry = new EventLog();
logEntry.Source = Log;
logEntry.WriteEntry("HELLOWORLD");
from seeing it it seems ok, did you see the examples in msdn lib?

Just a dumb question, did you do a refresh in the event log?
do you at least see the new log you are creating?

This code is part of a method with more code inside it. Below I've posted
more of that method just in case you need to see it (MIIS 2003, Provisioning
code). I have some problems with this code, no Connector Space objects are
created (not important what that is), so I added the EventLog code you see
above to my code for the purpose of debugging my code (I wanted to see ifmy
code actually was executed). As I've heard that I cannot use breakpoints in
the code here. Cannot as this code will be compiled to a .dll which MIIS
(microosft integrated indentry server) will execute. As far as I know it
won't execute debug code. But would be great if I'm wrong about it, as then
I've learned something new ;)

you see any reason why the eventlog code wasn't executed?
Maybe you get an exception before the code is executed.
Why don't you first use a file log. and handle all the unhandle
exceptions event
Jul 15 '08 #2

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

Similar topics

1
by: Kimmo Laine | last post by:
Hello, is it possible, when creating new Event log (C#), to specify the log size or other related options. if( !EventLog.SourceExists( sourceName ) ) { EventLog.CreateEventSource( sourceName,...
1
by: Robin | last post by:
On a Windows 2003 server how do you create a new event log that can be written to from an Asp.Net page?
1
by: UJ | last post by:
I am trying to have a service write out to a custom log in the event log. I'm using the following code: Dim lsEventSource As String = "test1234" Dim lsEventLog As String = "CustomLog" If...
3
by: clsmith66 | last post by:
I hope this is just something stupid I'm missing and someone can easily point out my error. I'm trying to do a few turorials on windows services, and the couple I found so far just create an event...
1
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...
3
by: Ben | last post by:
I am trying to write an eventlog monitor. I am using the sample code provided by VB2005 SDK as the bases for my application. I need to monitor all three logs (application, system, and security)....
0
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...
3
by: Hayden Kirk | last post by:
Hi, I'm having a bit of trouble. I want to create a number of controls on the fly. They are all the same control type. How is the best way to do this? I have a name I can assign to them so I...
2
by: =?Utf-8?B?Sm9l?= | last post by:
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...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...

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.