Could not load file or assembly 'Microsoft.SqlServer.Replication - c#

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.

Related

Could not load file or assembly C# Console Application with Class Library

I've created a Class Library in C# .Net Framework 4.8, and in the solution I've also included a Console Application, same target.
I'm running both in a x64 configuration.
No errors on build.
I referenced the App in the Library, and when I run a Button in a Form in the Class Library I'm getting an error:
System.IO.FileNotFoundException: Could not load file or assembly
'ExampleApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or
one of its dependencies. The system cannot find the file specified.
File name: 'ExampleApp, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null'
I've combed the internet and SO for a solution. I tried repairing Visual Studio, I tried deleting the .vs folder in the projects, I tried things like:
solution 1
and
solution 2
I seriously tried everything I could think of. It has to be something to do with the .dll dependencies imho, because the only one that my ExampleApp is using is the Microsoft.CognitiveServices.Speech reference which I installed via NugetPackage in my solution.
No idea how to debug this further or get a proper trace stack from this error...
Any ideas on how to proceed?
Thanks
Solved by changing the .dll's Copy Local property to True
Exactly #Yafim Simanovsky, I solved also my problem by changed <Private> flag to True.
My problem (“Could not load file or assembly…”) was with new Designer ‘WpfSurface.exe’ from VS 2022, which after changing the reference tags ‘Private’ to True, was able to copied all dependent .dll files to Cache.

.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 'log4net'

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.

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