writing to Windows Event logs in VB.Net 2010

I am having difficulty in writing to the windows event logs. I am specifically trying to write to the application log.

The test code I am working with is;

       Dim sSource As String
        Dim sLog As String
        Dim sEvent As String
        Dim sMachine As String

        sSource = "dotNET Sample App"
        sLog = "Application"
        sEvent = "Sample Event"
        sMachine = "."

        If Not EventLog.SourceExists(sSource, sMachine) Then
            EventLog.CreateEventSource(sSource, sLog, sMachine)
        End If

        Dim ELog As New EventLog(sLog, sMachine, sSource)
        ELog.WriteEntry(sEvent, EventLogEntryType.Warning, 234, CType(3, Short))

some of the code is identified as being obsolete, unfortunatly I cannot find documentation at MSDN for the replacement code.  Further there is an issue with a system.securityexception
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

It looks like the obeolete method is EventLog.CreateEventSource() with the overload of 3 arguments.  You may want to try with two string arguments.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AlyantoAuthor Commented:
Hi Alex
I have tried what is within the article unfortunatly I am still getting the same result.  I am also getting an issue with security access rights.  I think if I can find the current object/code I could eliminate that from the issue.  I am currently working on Windows 7 and the server that will eventually host the application will be Windows Server 2008 R2

Any and all ideas are most welcome.

AlyantoAuthor Commented:
Cheers :)

This solved the issue in the question,  I will place a second question that keys onto the issue of running the scheduler and security needs.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.