By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,895 Members | 1,106 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,895 IT Pros & Developers. It's quick & easy.

creating EventLog code, is this code correct?

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.