Nate222
Nate222

Reputation: 886

There is no EventLog source named 'ASP.NET 4.6.81.0'. This module requires .NET Framework 2.0

I just installed VS 2015 Community and upon trying to access an ASP.NET application hosted in IIS (using ASP.NET v4.0 app pool), I get greeted with that error message.

I just downloaded the .NET Framework 4.6 offline installer and it recognized the installation and gave me the option to repair or remove it. I opted to repair the installation and but it didn't fix anything.

Are there any other options available to me?

Upvotes: 4

Views: 6823

Answers (4)

CarlR
CarlR

Reputation: 1768

The answers above are correct to a point however the proposed fix is not really ideal.

The UnhandledExcepton module is a third party piece of code, the source of which is in CodePlex. It's purpose is to catch exceptions that are not handled and log them somewhere. It can be useful therefore removing it is not really the answer to this problem.

Also, creating an event log source of 'ASP.NET 4.6.81.0' is not really a fix. It might get you past the problem shown here but it will most likely break again the next time the .NET framework is updated.

If you look in the source code you can see that the module is using the version of an assembly (WebEngine.dll) shipped with the .NET framework to find the name of the event log source to use. The file can be found in the runtime directory which will depend on the framework version and the "bitness". e.g.

C:\Windows\Microsoft.NET\Framework\v4.0.30319\WebEngine.dll

The offending code is:

string webenginePath = Path.Combine(RuntimeEnvironment.GetRuntimeDirectory(), "webengine.dll");

and

FileVersionInfo ver = FileVersionInfo.GetVersionInfo(webenginePath);
sourceName = string.Format(CultureInfo.InvariantCulture, "ASP.NET {0}.{1}.{2}.0", ver.FileMajorPart, ver.FileMinorPart, ver.FileBuildPart);

If this log source does not exist then the error is thrown.

The reason this is happening now is that .NET 4.6 is a replacement for .NET 4.5 rather than a side-by-side install. The installation has replaced the WebEngine.dll with a new version, 4.6.81.0. The previous version in .NET 4.5.2 was 4.0.30319 (which corresponded with the CLR version).

There is no event log source for "AP.NET 4.6.81.0" hence the error.

The original author of the UnhandledException module should have used code that returns the CLR version rather than relying on the version of a file.

e.g.

System.Environment.Version

Major  Minor  Build  Revision
-----  -----  -----  --------
4      0      30319  34209

If the string that looked for the environment version instead used this then it would continue to work with framework 4.6. Of course this does not guarantee it will continue to work in later versions however it would be a safer choice than file versions.

The answer therefore is to change the code in the UnhandledExceptionModule to do this, recompile it and update your references accordingly.

e.g.

_sourceName = string.Format(CultureInfo.InvariantCulture, "ASP.NET {0}.{1}.{2}.0",System.Environment.Version.Major, System.Environment.Version.Minor, System.Environment.Version.Build);

UPDATE 2015-DEC-04: I have patched this issue and have uploaded a new version of the offending class to the original codeplex site. The original author does not seem to be active on the site any more and therefore I do not expect the patch to get merged into the source control however it is there for anyone to use. See the issue describing the problem and the linked patch

Upvotes: 12

terencetcf
terencetcf

Reputation: 231

I fixed the issue by running this command line: eventcreate /ID 1 /L APPLICATION /T INFORMATION /SO "ASP.NET 4.6.81.0" /D "My first log"

Upvotes: 22

Rasika Godawatte
Rasika Godawatte

Reputation: 81

The answer to the above error is not, removing the "WebMonitor.UnhandledExceptionModule" httpmodule. This module is been used to catch any unhandled exceptions and log them in the O/S EventLog.

As it says in the error message, it's missing the EventLog source in the server/machine.

Create the EventLog source as described in the following link then you can get rid of the error and as well as use the O/S Eventlog to log any unhandled exceptions thrown from your application.

How to fix EventLog source missing error

Good luck!!

Upvotes: 6

J.S.Orris
J.S.Orris

Reputation: 4821

Try this the following:

Navigate to your web.config and find this block:

<httpModules>
        <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <add type="WebMonitor.UnhandledExceptionModule" name="UnhandledExceptionModule"/>
    </httpModules>

Change the above to the following:

<httpModules>
    <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>

Upvotes: 2

Related Questions