471,350 Members | 1,884 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 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 1914
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Kimmo Laine | last post: by
1 post views Thread by Robin | last post: by
1 post views Thread by UJ | last post: by
3 posts views Thread by clsmith66 | last post: by
1 post views Thread by martin | last post: by
3 posts views Thread by Ben | last post: by
reply views Thread by rene | last post: by
3 posts views Thread by Hayden Kirk | last post: by
2 posts views Thread by =?Utf-8?B?Sm9l?= | last post: by

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.