I got the below error when I try to open up an SQLiteConnection using System.Data.SQLite
System.DllNotFoundException: Unable to load shared library 'SQLite.Interop.dll' or one of its dependencies.
In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(libSQLite.Interop.dll, 0x0001): tried: 'libSQLite.Interop.dll' (no such file),
'/usr/local/lib/libSQLite.Interop.dll'
(mach-o file, but is an incompatible architecture
(have 'x86_64', need 'arm64e')), '/usr/lib/libSQLite.Interop.dll' (no such file)
I had the same issue. After some search on google, it seems that the implementaion on M1 is not yet done.
https://sqlite.org/forum/info/f985511fd94fb44cd77465195f88416631590cb3cee84003f9d8561c8e2a58fe
Related
I downloaded this repository from GitHub and try to run it on my MacOS laptop. It uses Signal R and web sockets.
It builds, it starts, it works
But when I try to open web socket I get an error:
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
System.TypeInitializationException: The type initializer for 'Gdip' threw an exception.
---> System.DllNotFoundException: Unable to load shared library 'libgdiplus' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(liblibgdiplus, 0x0001): tried: 'liblibgdiplus' (no such file), '/System/Volumes/Preboot/Cryptexes/OSliblibgdiplus' (no such file), '/usr/lib/liblibgdiplus' (no such file, not in dyld cache), 'liblibgdiplus' (no such file), '/usr/local/lib/liblibgdiplus' (no such file), '/usr/lib/liblibgdiplus' (no such file, not in dyld cache)
at System.Drawing.SafeNativeMethods.Gdip.GdiplusStartup(IntPtr& token, StartupInput& input, StartupOutput& output)
at System.Drawing.SafeNativeMethods.Gdip..cctor()
--- End of inner exception stack trace ---
I did brew install mono-libgdiplus but it didn't help.
I'm new to C# and Microsoft frameworks so what else can I do? (MacOS Ventura, Apple M1)
Solved: System.Drawing is not supported on my MacOS, so the peaces of code where this library is using should not be executed.
While the project you played with was very well designed for cross platform, it was unfortunately developed before .NET 6 introduced an important breaking change, that System.Drawing related API is only supported on Windows.
Like you found out, commenting out the lines related to System.Drawing works. But if you want similar functionalities, you will have to rewrite that part with another drawing library. There are many such options out there if search engines are used.
I have a problem only on a specific machine.
I have two programs with a reference to Sap.Data.Hana.v4.5.dll, the ADO.NET Provider for .NET 4.5 for HANA database.
When my programs instantiates a connection object with
dbConnection = new HanaConnection(...);
I get this error:
System.TypeInitializationException: The type initializer for 'Sap.Data.Hana.HanaConnection' threw an exception. ---> System.IO.FileNotFoundException: Cannot find libADONETHDB.dll.
at Sap.Data.Hana.HanaUnmanagedDll.SearchNativeDlls(String regKeyName)
at Sap.Data.Hana.HanaUnmanagedDll..ctor()
at Sap.Data.Hana.HanaUnmanagedDll.get_Instance()
at Sap.Data.Hana.HanaConnection..cctor()
--- End of inner exception stack trace ---
at [...my program calls...]
Why can't it find libADONETHDB.dll?
My applications are build one in 32-bit, the other in 64-bit.
On this machine I installed SAP HANA client 2.8.20.23662 (latest version) both 32-bit and 64-bit.
The file that cannot be found seems to exist:
You could use Process Monitor while running the relevant part of the program to see, which file is missing and the path it should be in. Exclude all other events than file events and filter out all SUCCESS messages.
Perhaps it is referenced relative to the calling DLL (where Sap.Data.Hana.HanaUnmanagedDll.SearchNativeDlls is defined).
My hipotesis is that GAC had been corrupted with version 1 of Sap.Data.Hana.v4.5.dll:
Probably in the past HANA Client version 1 had been installed and removed and uninstallation hadn't cleaned the GAC.
My program uses HANA Client of any version, works both with version 1 and 2. For some reason when they start they seem to take version 1 of Sap.Data.Hana.v4.5.dll in the GAC. Process Monitor (thanks #sc911) confirms it:
This .NET DLL then looks for some unmanaged DLLs in C:\Program Files (x86)\hdbclient. Version 1 seems to look for libADONETHDB.dll in root folder.
But currently in this machine in that folder we have HANA Client 2.x and its folder structure is quite different from that of version 1 (there is no libADONETHDB.dll in root folder).
Hence the error in this question.
All this is valid both for 32-bit and 64-bit HANA Client.
I solved renaming or deleting version 1 folder in C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Sap.Data.Hana.v4.5 (probably there are better ways for performing this cleanup).
I try to connect to a fiscal device with a C#.
I use this documentation to do so: http://integration.atol.ru/api-en/#connection-to-project
So basically I have a driver of the device installed on my PC (fprt10.dll) and there is a "wrapper" assembly that allows me to work with this driver from C# (Atol.Drivers10.Fptr.dll). I import this wrapper into my project as a reference.
I have the following constructor in my class:
public MyClass()
{
IFptr fiscalPrinter = new Fptr();
// Here comes several settings to configure connection
fiscalPrinter.applySingleSettings();
fiscalPrinter.open();
fiscalPrinter.beep();
fiscalPrinter.close();
}
To test the solution I use another application, that loads my Class Library as a dependency.
When I call a constructor of MyClass I get an exception:
System.IO.FileNotFoundException: Driver not installed
at Atol.Drivers10.Fptr.Fptr.loadDriver(String path)
at Atol.Drivers10.Fptr.Fptr..ctor()
at MySolution.MyClass.MyClass()
...
If I create instance of Fptr with a path to the driver
IFptr fiscalPrinter = new Fptr(#"C:\path\fptr10.dll")
I get the slightly different exception, but I believe the problem is the same:
System.IO.FileNotFoundException: Can`t load driver library "C:\path\fptr10.dll"
at Atol.Drivers10.Fptr.Fptr.raiseNotFoundError(String path, Exception reason)
at Atol.Drivers10.Fptr.Fptr.loadDriver(String path)
at Atol.Drivers10.Fptr.Fptr..ctor(String libraryPath)
at MySolution.MyClass.MyClass()
...
But when I create a Console Application and put in there exact same code (both versions with path and without), everything works: the device beeps, there are no exceptions.
What could be the reason for that behavior and how to fix this?
The issue may be one of the following
The test application is using 'target platform' different than the console application which works fine. The device driver folders expected for each platform could be different. e.g. Changing the targeted platform from 'any CPU' to 'x64' / 'x86' (depending on the type of OS where you are running it) will help
Try running the test application from admin command prompt. Permissions issue may reflect as 'file not found' (instead of 'file could not be loaded').
Use an assembly binding viewer tool to debug the issue further
Refer to Could not load file or assembly or one of its dependencies for more discussion and inputs on the assembly loading issues.
Thank you samiksc.
The issue was in the test app. The driver and OS that I use are both x64, but the test application is x86. With x86 driver everything works.
In my program I have this simple code:
using System;
using System.Data;
using Mono.Data.SqliteClient;
....
IDbConnection cnx = new SqliteConnection("URI=file:reestr.db");
cnx.Open();
....
And this is how I compile it:
$ mcs Test.cs -r:System.Data.dll -r:mono.data.sqliteclient.dll
It compiles ok. But when I run it with ./Test.exe, I get this error messages:
Missing method .ctor in assembly ....
Unhandled Exception:
System.IO.FileNotFoundException: Could not load file or assembly 'Mono.Data.SqliteClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' or one of its dependencies.
File name: 'Mono.Data.SqliteClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756'
I'm not sure what I'm doing wrong here and how to repair it.
PS. I'm using Ubuntu as my OS.
It appears that Mono.Data.SqliteClient can not find the native SQLite binaries:
Prerequisites If you do not have SQLite, download it. There are
binaries for Windows and Linux. You can put the .dll or .so along side
your application binaries, or in a system-wide library path.
Ref: http://www.mono-project.com/docs/database-access/providers/sqlite/
To obtain pre-compiled native binaries (or source) for your platform:
http://www.sqlite.org/download.html
Also if you have the SQLite native shared libraries installed, are they available via dlopen? If not, you can assign the LD_LIBRARY_PATH env. var so Mono can find them at runtime.
Linux Shared Library Search Path From the dlopen(3) man page, the
necessary shared libraries needed by the program are searched for in
the following order:
A colon-separated list of directories in the user’s LD_LIBRARY_PATH
environment variable. This is a frequently-used way to allow native
shared libraries to be found by a CLI program. The list of libraries
cached in /etc/ld.so.cache. /etc/ld.so.cache is created by editing
/etc/ld.so.conf and running ldconfig(8). Editing /etc/ld.so.conf is
the preferred way to search additional directories, as opposed to
using LD_LIBRARY_PATH, as this is more secure (it’s more difficult to
get a trojan library into /etc/ld.so.cache than it is to insert it
into LD_LIBRARY_PATH). /lib, followed by /usr/lib.
Ubuntu Notes:
$ sudo apt-get install sqlite
$ ls -1 /usr/lib/libsqlite*
/usr/lib/libsqlite.so.0
/usr/lib/libsqlite.so.0.8.6
$ export LD_LIBRARY_PATH=/usr/lib:$LD_LIBRARY_PATH
$ mono ./Test.exe
I solve the problem in my Mac in this way. Right Click in Mono.Data.Sqlite on References and click in Local Copy. This make mono copy dll to debug folder and your application will find the library.
OBS: Sorry for my bad english.
I am trying to read an xlsx file.
I got exception that
The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine. c#
then I installed it from here
http://www.microsoft.com/en-us/download/details.aspx?id=13255
then I changed the platform target to x64
now i got this exception:
BadImageFormatException was unhandeled
{"Could not load file or assembly 'LinqToExcel, Version=1.9.0.0, Culture=neutral, PublicKeyToken=9c8ea65a58f03f1f' or one of its dependencies. An attempt was made to load a program with an incorrect format."}
Update 1
I already installed the linq_to_excel
using
Install-Package LinqToExcel
and then add the lib files to references
You have two options to solve
Enable IIS to run 32 bits app
Install LinqToExcel_x64
if change 32 bit app in iis From false to true,all conflicts about exteltolinq version solve
Please install Microsoft office in your machine it will automatically solve your problem. It worked for me as well.