Windows Desktop App - Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' - winforms

I have a Windows Desktop c# application in .Net Framework 4.6.2. This Application is using Crystal Reports (13.0.3500.0) as well.
Everything was working fine, I have just changed my development machine. On the new machine with Windows 11 and Visual Studio 2022, When I open any Form (Which has Crystal Report Viewer), I get the following error.
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.
I have tried all available solutions:
Installed both 32-bit and 64-bit Crystal Reports SDK
I have removed and re-added log4net from Nuget.
I have placed log4net in GAC in both 32bit and 64bit folders.
Enabled / Disabled Preferred 32 bit from settings.
I believe the issue is with Public Token 692fbea5521e1304. How can I find log4net with this public token? Even on Nuget or on Apache log4net with this public token is not available.

Related

IdentityServer4 Could not load file or assembly Microsoft.IdentityModel.Tokens

I created an IdentityServer as described in https://identityserver4.readthedocs.io/en/latest/quickstarts/1_client_credentials.html with .NET Core 3.1 on Windows 10. We use it in development, to mock some services. On most machines, it runs ok, but on two machines we get the error:
Could not load file or assembly Microsoft.IdentityModel.Tokens
I see, that Microsoft.IdentityModel.Tokens is referenced by Microsoft.IdentityModel.Protocols, which is referenced by Microsoft.IdentityModel.Protocols.OpenIdConnect, which is referenced by IdentityServer4.
We uninstalled Nuget package IdentityServer4 and reinstalled it. That worked for about 10 minutes, but then the same problem occurred.
I found here in Stackoverflow the similar issue Could not load file or assembly Microsoft.IdentityModel.Tokens problem, but it is in Azure Functions, whereas we have it on our Windows 10 development machines with Visual Studio 2019 installed.
Does anybody have an idea how to fix this?

Interop Forms Toolkit DLL and "Class does not support Automation or does not support expected interface" error

I have a .NET WinForms application that I've converted into a COM dll using the Interop Forms Toolkit 2.1. Thet setup project for the application has both my tlb as well as the Microsoft.InteropFormTools.tlb file set to Register as vsdrpCOM. The prerequisites for the project are to ensure that Windows Installer 3.1, .NET Framework 3.5 SP1, and the Microsoft Interop Forms Redistributable Package 2.0a is installed.
When I run this locally on a Windows XP box with both Visual Studio 2010 and Visual Studio 6 installed, it works fine. However, on this Windows XP machine, I receive an error stating: "Class does not support Automation or does not support expected interface."
Any ideas?
I got it. For those of you that are running into the same, do the following:
Go into Visual Studio 2005, 2008, or 2010 (I used 2010) and build your Interop Form.
Then, go into Visual Basic 6. If your library is not already referrenced, reference the
library.
Build your VB6 executable.
Go back into Visual Studio (.NET version) and build only your installer. This way the installer and VB6 both have the same .tlb file
You're good to go. Thanks for the suggestion Kris!
You have RegAsm the assembly (see stackoverflow for more) on the machine you want to install the application on. The assembly should also be in the directory where the VB6 application runs, or installed in the GAC.

Open Source Embedded Database Options for .Net Applications

I have a .Net 4.0 WPF application that requires an embedded database.
MS Access doesn't work on 64 bit Windows I'm told. And I'm having issues with SSCE:
Unable to load DLL 'sqlceme35.dll': This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem. (Exception from HRESULT: 0x800736B1)
sqlceme35.dll is installed into my application's program files directory, so I can't seem to figure out why Windows XP Pro doesn't see it.
I was wondering about other embedded database options I might use (that work on both 32 and 64 bit windows). Any suggestions?
SQLite
...and the System.Data.SQLite provider.

SQL Server Compact error: Unable to load DLL 'sqlceme35.dll'. The specified module could not be found

I'm developing a Windows Forms application using Visual Studio 2008 C# that uses an SQL Server Compact 3.5 database on the client. The client will most likely be 32 bit Windows XP or Windows Vista machines. I'm using a standard Windows Installer project that creates an MSI file and setup.exe to install the application on a client machine. I'm new to SQL Server Compact, so I haven't had to distribute a client database like this before now. When I run the setup.exe (on new Windows XP 32 bit with SP2 and Internet Explorer 7) it installs fine, but when I run the application I get this error:
Unable to load DLL 'sqlceme35.dll'. The specified module could not be found
I spent a few hours searching for this error already, but all I could find were issues relating to installing on 64 bit Windows and none relating to normal 32 bit that I'm using.
The install application copies the all the dependent files that it found into the specified install directory, including the System.Data.SqlServerCe.dll file (assembly version 3.5.1.0). The database file is in a directory called 'data' off the application directory, and the connection string for it is
<add name="Tickets.ieOutlet.Properties.Settings.TicketsLocalConnectionString" connectionString="Data Source=|DataDirectory|\data\TicketsLocal.sdf" providerName="Microsoft.SqlServerCe.Client.3.5" />
Some questions I have:
Should the application be able to find the DLL file if it's in the same directory, that is, local to the application, or do I need to install it in the GAC? (If so, can I use the Windows Installer to install a DLL file in the GAC?)
Is there anything else I need to distribute with the application in order to use a SQL Server Compact database?
There are other DLL files also, such as MS interop for exporting data to Excel on the client. Do these need to be installed in the GAC or will locating them in the application directory suffice?
You don't need it to be in the GAC for SQL Server Compact to run, and it will pick them up from the application directory. There are several ways to deploy an SQL Server Compact project. The two main ways are:
Deploying the SQL Server Compact redistributable installer with your project, but this way is painful and also can be unistalled by the end user, or upgraded by Windows updates and breaking your application.
Including the DLL files in your application folder. Depending on the features of SQL Server Compact you are using (replication or whatever), there is a handful of DLL files to deploy in your application folder.
If you have SQL Server Compact installed on your machine, they are most likely located at "C:\Program Files\Microsoft SQL Server Compact Edition\v3.5". They can be added to the project in Visual Studio and then set their project output type to "copy always". And the main reference to System.Data.SqlServerCe that you have in your project references should have copy local set to true.
sqlceca35.dll
sqlcecompact35.dll
sqlceer35en.dll
sqlceoledb35.dll
sqlceqp35.dll
sqlcese35.dll
If you have these all set, then in your installer project all you have to include is the project output of this project and you're good. In my opinion this is the only way to go. It is a simple deployment, of a couple of files and you are in control of what DLL versions your application uses.
I hope that helps.
I had a similar problem, a Visual Studio 2008 Windows application targeting 32-bit Windows XP and Windows Vista that used SQL Server Compact 3.5 SP1 - that then got this error when installed on 64-bit Windows 7:
Unable to load DLL 'sqlceme35.dll'. The specified module could not be found
I was embedding an MSI for SQL Server Compact into the installer for the application.
Following this rather confused discussion on MSDN revealed that I needed to use the 64-bit MSI for SQL Server Compact on 64-bit machines. D'oh! That is, from page Microsoft SQL Server Compact 3.5 Service Pack 1 and Synchronization Services for ADO.NET version 1.0 Service Pack 1 for Windows Desktop I needed SSCERuntime-ENU-x64.msi rather than SSCERuntime-ENU-x86.msi for 64-bit machines.
How to: Deploy a SQL Server Compact Edition Database with an Application should help, at least with your first two questions.
In general, I think you should not install anything in the GAC for a single application.
The following provide a solution to the problem and an explanation also.
Troubleshooting: Can’t load SQL Server Compact DLL
SqlCeException on application's first use of SQL Server Compact
Laxmi Narsimha Rao Oruganti 's blog
I hope this helps.

Reference library problem in Release configuration on another computer

I get this error when I open a program I created in Windows Vista in C# with WPF on a computer with Windows XP:
Could not load file or assembly
'Microsoft.Office.Interop.Word,
Version=12.0.0.0, Culture=neutral,
PublicKeyToken=71e9bce111e9429c' or
one of its dependencies. The system
cannot find the file specified.
This is rather strange because MS Office 2007 is installed... and MS Office 2003 seems to be also installed. Could there be some sort of conflict between the two?
Also, .NET framework is installed up to 3.5!
How can I solve this problem?
What was installed first, .NET or MS Office 2007? If Office is installed before the .NET framework, the interop assemblies will not be installed in the GAC.
You could try downloading the PIA redistributable from MS and running it on your XP box: http://www.microsoft.com/downloads/details.aspx?FamilyID=59daebaa-bed4-4282-a28c-b864d8bfa513&displaylang=en. This redistributable will load the MS Office interop assemblies into the GAC.

Resources