log4net not logging and throwing error - c#

I have been using log4Net to write in a text file when there is any exception in my web service, this was working but today it started to throw error.
System.Web.Services.Protocols.SoapException: Server was unable to
process request. ---> System.TypeInitializationException: The type
initializer for.. threw an exception.
---> System.IO.FileLoadException: Could not load file or assembly
'log4net, Version=1.2.9.0, Culture=neutral,
PublicKeyToken=b32731d11ce58905' or one of its dependencies. The
located assembly's manifest definition does not match the assembly
reference. (Exception from HRESULT: 0x80131040)
File name: 'log4net, Version=1.2.9.0, Culture=neutral,
PublicKeyToken=b32731d11ce58905'
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
If you have any inputs on this stack info, pls. share it.

Did you change the code, or did this just start happening?
I've seen this error occur when the target processor architecture was mismatched. Did you change that by any chance?
If this isn't the case, and you have Windows SDK installed, you can use the Fusion Log Viewer to view assembly binding logs. The utility should be installed on your machine.

Related

Code running fine locally but erroring when published live on GoDaddy

Server Error in '/' Application.
Configuration Error
Description: An error occurred during the processing of a
configuration file required to service this request. Please review the
specific error details below and modify your configuration file
appropriately.
Parser Error Message: Could not load file or assembly 'MySql.Data,
Version=6.4.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or
one of its dependencies. The system cannot find the file specified.
Source Error:
An application error occurred on the server. The current custom error
settings for this application prevent the details of the application
error from being viewed remotely (for security reasons). It could,
however, be viewed by browsers running on the local server machine.
Source File: G:\PleskVhosts\dekhoroom.com\httpdocs\web.config Line:
11
Assembly Load Trace: The following information can be helpful to
determine why the assembly 'MySql.Data, Version=6.4.4.0,
Culture=neutral, PublicKeyToken=c5687fc88969c44d' could not be loaded.
WRN: Assembly binding logging is turned OFF. To enable assembly bind
failure logging, set the registry value
[HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There
is some performance penalty associated with assembly bind failure
logging. To turn this feature off, remove the registry value
[HKLM\Software\Microsoft\Fusion!EnableLog].
If you, on your local development machine, have MySql.Data in your GAC, it will not be in your Web app's bin directory. And if it is that bin directory that gets deployed, Sql.Data will not be there. Do not expect a hosting provider to have all kinds of assemblies in the GAC.
So the solution is to deploy all the assemblies your Web app needs. Deploy MySql.Data, and any other assemblies that it depends upon, along with your Web application.
For the same reason, it is a good idea not to install ASP.NET MVC in your GAC but to simply reference it and deploy it along with your Web application.

How to solve .Net Framework Version Issue?

It works fine on server. But now I'm deploying this on new server. I just copied the Package from my old server to this server.
When I browse application, getting the below mentioned error.
Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or
one of its dependencies. The system cannot find the file specified.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace
for more information about the error and where it originated in the
code.
Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its
dependencies. The system cannot find the file specified.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
On new Server its showing .net clr version v4.0.30319, but on old server it is
.net version v4.0.30319 for Application Pool.
Is this Framework related Issue? or m I missing something?
You new server might not have an ASP.NET-MVC installed on. You can set the reference to System.Web.WebPages.Razor copied to local set to true.
Right click on the System.Web.WebPages.Razor in your references and click properties. Set the Copy Local to true.

System.IO.FileLoadException: Could not load file or assembly

While trying to execute my web application, it throws the following error. It says Matrix.Data.dll could not load. I tried to rebuild the assembly and reference it again. But no use. Also, it is showing a warning 'Assembly binding logging is turned OFF' and what will be the performance penalty associated with assembly bind failure logging...?
Error in detail:
System.IO.FileLoadException: Could not load file or assembly 'Matrix.Data, Version=5.0.3.16,
Culture=neutral, PublicKeyToken=ed19106b2f44b5a8' or one of its dependencies.
The located assembly's manifest definition does not match the assembly reference.
(Exception from HRESULT: 0x80131040)
File name: 'Matrix.Data, Version=5.0.3.16, Culture=neutral,
PublicKeyToken=ed19106b2f44b5a8'
at Matrix.Administration._Administration.DoRequest(Boolean& plReplacePlaceholders)
at Matrix.AppServerHTTPHandler.doRequestDefault()
in D:\FX\AppServer\Appserver.vb:line 443
at AppServer.AppServerHTTPHandler.doRequest(Kernel pKernel)
in D:\FX\AppServer\Appserver.vb:line 373
at AppServer.AppServerHTTPHandler.processRequest(HttpContext context)
in D:\FX\AppServer\Appserver.vb:line 107
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value
[HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated
with assembly bind failure logging.
To turn this feature off, remove the registry value
[HKLM\Software\Microsoft\Fusion!EnableLog].
Your Accessibility.dll is most likely corrupted. You will not be able to delete the file, even as Administrator.
You must go into the security settings and change the owner from TrustedInstaller to a different user and give yourself permissions on the file. Once done, get an Accessibility.dll from a working computer and replace your corrupted version.
Best I can guess, an installer from Microsoft corrupted the DLL as no user has permission to edit/delete/replace files owned by TrustedInstaller.

UNC Path and Unhandled Exception: System.BadImageFormatException in C#

I compiled the whole project with x86 platform target. It is working fine when I copy .exe and the reference dlls on to the server and run .exe from server cmd window.
Our requirement is to copy the exe and dlls onto some network path and execute the exe on the server using UNC path. When I execute using UNC path, I am getting the error:
Unhandled Exception: System.BadImageFormatException: Could not load
file or assembly 'XXXX, Version=3.0.10.19399, Culture=neutral,
PublicKeyToken=null' or one of its dependencies. An attempt was made
to load a program with an incorrect format.
File name: 'XXXX, Version=3.0.10.19399, Culture=neutral, PublicKeyToken=null'
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
Can someone help?
I'm just guessing now, but I would probably blame the path itself - it's most likely "untrusted", reason unknown. Enable Assembly Bind Logging (tip: google :) ) to figure out what's happening

Problems upgrading MVC Mini Profiler to latest release

I've been using Mini Profiler in dev and production (azure) for a while and LOVE it.
It tried to upgrade to the latest release today via NUGET. The DLL get's placed in the bin but my site gets an error. If I go back to the old dll it works fine. Does anyone know how to fix this?
Server Error in '/' Application.
Could not load file or assembly 'MvcMiniProfiler, Version=2.0.4177.17902, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileLoadException: Could not load file or assembly 'MvcMiniProfiler, Version=2.0.4177.17902, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'MvcMiniProfiler, Version=2.0.4177.17902, Culture=neutral, PublicKeyToken=null' could not be loaded.
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
Stack Trace:
[FileLoadException: Could not load file or assembly 'MvcMiniProfiler, Version=2.0.4177.17902, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
MyGlobal.application_BeginRequest(Object sender, EventArgs e) in C:\Users\Nate\Documents\Visual Studio 2010\Projects\TrainerRoad\com.TrainerRoad.DataAccess\MyGlobal.cs:15
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +270
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.237
Be sure to read the documentation on http://code.google.com/p/mvc-mini-profiler/
In particular:
Ensure you remove all the modifications you made to web.config.
If you are profiling Entity Framework grab the MiniProfiler.EF package
If you are running latest EF see: Problem using SQL Server CE with Entity Framework code-first and ASP.NET MVC 3 and mvc miniprofiler
There is not MiniProfiler version 2.0.4177.17902 so I really do not know where it is coming from.

Categories

Resources