Could not load file or assembly 'log4net' - c#

I am attempting to deploy a Crystal Reports desktop application, but the application is not able to find my log4net assembly, even though I have verified that my installer is registering the log4net DLL in the GAC. Below is the exception and stack trace.
Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral,
PublicKeyToken=692fbea5521e1304' or one of its dependencies. The system
cannot find the file specified.
at CrystalDecisions.Shared.SharedUtils..cctor()
I am honestly completely lost as to why this isn't working... The versions are the same and everything. Do I need to configure log4net before this will work?
Editing: I am using InstallShield 2012 to install my application assembly to the GAC. The only other things I am installing are a very small exe that references my dll, and a few files in Program Files folder to handle configuration.

Turns out I was using the same version of the dll, but the one I was using had a different PublicKeyToken. After I fixed that, it worked.

Setting platform to x86 worked for me. Previous was AnyCPU

Assuming that the dll is already in the application folder, go to the properties of the project, click on Application Files and change the dll from "prerequisite" to "include", and save it. It would then be in GAC.

Related

Could not load file or assembly 'Microsoft.SqlServer.Replication

I have an c# application using 'Microsoft.SqlServer.Replication .NET Programming Interface DLL.
(Microsoft.SqlServer.Rmo.dll)
I need there the TransSubscription and TransPublication.
I can build the solution without any error or warning, and run it in Debug and Release mode on my computer. But if I would like to start the release application an another computer, i receive the error:
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.SqlServer.Replication, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.SqlServer.Replication, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'
I tried it to have as x64 and x86 application, no affect. I cannot interop the DLL, there will be errors in Vistual studio.
Anyone has an idea?
Thank you
Edit:
Meanwhile i did some more testing..
I have installed on a new VM SQL server to get only the available, and in the rght version dll. Installed VS and build the project. This was sucessful, no errors. But if i am starting the app, already in debug mode it crashed with the same error code. any idea?
The dll is referenced all build is completed.
Edit:
According: https://learn.microsoft.com/en-us/sql/relational-databases/replication/concepts/replication-management-objects-concepts?view=sql-server-ver15 i need to add Replication Agent Library (REPLAGNT.dll) but this i cannot do in VS, "A reference to .... could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component". What do i do wrong?
For me it sounds like you referenced a dll which is located in a local folder, which works okay as long as you are working on your machine, but crashes as soon as you using another machine. After a build/rebuild a dll should be located in the bin folder.

.NET exe not picking dll dependencies

I have developed an EXE again :)
The problem is it has refernces of SQLite dll file so I included the file on the same path. Now in Windows 8 it is running fine, but in Windows 7 it is not
The error is
System.IO.FileLoadException: Could not load file or assembly 'System.Data.SQLite, Version=1.0.90.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139' or one of its dependencies. The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail. (Exception from HRESULT: 0x800736B1)
File name: 'System.Data.SQLite, Version=1.0.90.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139' ---> System.Runtime.InteropServices.COMException (0x800736B1): The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail.
I did everything I could but it is not running on Windows 7
It's a standalone EXE. No Setup.
EDIT:
This is what application event log says
Activation context generation failed for "C:\System.Data.SQLite.dll". Dependent Assembly Microsoft.VC80.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.6195" could not be found. Please use sxstrace.exe for detailed diagnosis.
I think thats the reason as you mentioned, SQLLite is searching 64 bit dll!
Try to download 64 bit url and pack it with exe
You can download from here
http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki
side-by-side configuration is incorrect
That means Either:
One of your reference DLLS do not match your project target type
Or Your reference DLLS are of mixed target types
Solution:
Make sure your Project is set to build to target x86 for x86 reference DLLs or target x64 for x64 reference DLLs, and the same for the .NET versions
Make sure all your reference DLLs are either all x86 or all x64 versions and not x86 and x64, and the same for the .NET versions
If you are not sure you can use IlSpy to check by right clicking on the reference.
Generally this error indicates that a dependent assembly is missing.
Activation context generation failed for "C:\System.Data.SQLite.dll".
Dependent Assembly
Microsoft.VC80.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.6195"
could not be found. Please use sxstrace.exe for detailed diagnosis.
This assembly is more commonly known as
Microsoft Visual C++ 2005 Redistributable Package (x86)
and can be downloaded from here.
But, often there is another cause. Today, for us, it was "Bit9 Security" which did not like us digitally signing the SQLite.dll assembly on our local machine and uploading the signed assembly to our server application folder with a different time stamp to the rest of the assemblies in the application folder.
The work around was to recompile the application, sign all the assemblies, upload and overwrite the existing application files.

Deleting ReportViewer from .NET web app, something still looking for ReportViewer dll

I have a web app which used ReportViewer, from which I am trying to delete ReportViewer and all its dependencies.
As far as I can see, I have deleted everything I need to and all works fine locally. However, when I deploy to our QA server and run the site, I get the following error:
System.IO.FileNotFoundException: Could not load file or assembly
'Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral,
PublicKeyToken=89845dcd8080cc91' or one of its dependencies.
The system cannot find the file specified.
I suspect that some other dll in the system depends on the ReportViewer.WebForms.dll, but I cannot work out which one. This dll is not referenced directly from anywhere in the app.
Does anyone know what dlls commonly reference ReportViewer.WebForms.dll?
I think the dll's reside in GAC, causing this error. According to MSDN;
When you run ReportViewer.exe, the following files are installed in
the Global Assembly Cache folder on the deployment computer.
Microsoft.ReportViewer.Common.dll
Microsoft.ReportViewer.ProcessingObjectModel.dll
Microsoft.ReportViewer.WebForms.dll
Microsoft.ReportViewer.WinForms.dll
Microsoft.ReportViewer.DataVisualization.dll
Refer http://msdn.microsoft.com/en-us/library/ms251723.aspx for more clarification.

Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Common' or one of its dependencies

I have searched google for this and could not find the solution to the problem.
My Website references DAL (custom dll) which references Enterprise Library Data Access Components.
I have added the Enterprise Library from the NuGet Package Manager and when I try to build the Website this compilation error pops up:
Error 44 Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Common' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference
I have tried setting the Copy Local = True in the DAL for the Enterprise Library dlls and the dlls are transferred to the Bin directory of the website along with DAL dll, but still the error pops up.
Can anyone guide me on this....
The problem is that the DLL that you are using and the one that is referenced in your project are different. I'm not sure what the difference in the manifest is, but it could be version and/or public key.
You have a couple of things to try:
Open the properties for the DLL reference in your project and set Version Specific to false.
Remove the reference, delete the DLL from the bin folder, and re-add the reference.
You could also have a different/incorrect version in your GAC. In order to make sure that you are always using a specific, known version create an assemblies folder relative to your project directory, copy the dll to that directory, and add a reference to the DLL in the assemblies directory rather than one in GAC or elsewhere on your machine. This will ensure that only the specific version that you have targeted for the application will be used rather than any version that is updated on your machine at a later time.
NuGet CommonServiceLocator
Install-Package CommonServiceLocator
This dll is likely to be in the GAC on developer machines as part of some windows application installation (my best guesses are Visual Studio or SSMS).
That’s why we are likely to get warnings or errors on the build machine which we try our best to keep the GAC as clean as the production server’s.
To download the file manually, you can go to https://servicelocation.codeplex.com/
To fix the build warnings and errors, you simply need to run a NuGet command to install the CommonServiceLocation package. The package contains only this one dll file. Microsoft has released only 1 version (1.0.0.0) of this file since 2008. The file is fully compatible with all .NET versions and all Unity versions.
I was able to resolve this issue by removing from ALL the Logging references in the app.config file::
, Version=6.0.0.0, Culture=neutral, PublicKeyToken=null
ie:
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings,
Microsoft.Practices.EnterpriseLibrary.Logging,
Version=6.0.0.0, Culture=neutral, PublicKeyToken=null"
requirePermission="true" />
Becomes:
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings,
Microsoft.Practices.EnterpriseLibrary.Logging"
requirePermission="true" />
This is not ideal, but it does work...
The Enterprise Library Configuration Tool, sets the values back, so you need to watch for that. I know there is a way to tell the config file to accept these mis-matched settings -- but I I am not sure how.
Setting the PublicKeyToken values for each of the EnterpriseLibrary references in Web.Config fixed it for me.
Remove the reference, delete the DLL from the bin folder and VS, and re-add the reference.

Deploying assembly normally in the GAC with my project?

I built a web application that uses the J# libraries which works fine in my cpu, however, when I deploy it to my shared server. I get an error message: Parser Error Message: Could not load file or assembly 'vjslib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
So basically, the server doesn't have visual j# installed. The problem is they wont install it because it is a shared server.
Is there a way I can deploy the J# assemblies with my project so that it will work on the shared server without it being registered in the GAC?
Thanks for your help!!
Simplest solution: Try to copy the assemblies your application needs into the same folder where your application resides.
The following MSDN article explains How the Runtime Locates Assemblies.
Also, you may find more options (including copying all J# related dlls into a subfolder of the application folder if needed) in the following link when the runtime cannot find the assembly in the GAC: Locating the Assembly through Codebases or Probing
Without knowing anything about J# I can only suggest that you try just distributing the required libraries along with your program (place them in the same directory), I believe if it can't find the library in the GAC it will revert to look in the current directory.

Categories

Resources