SQLite on Mono/Ubuntu: DllNotFoundException SQLite.Interop.dll - c#

I developed a SQLite/C# application on Windows and am deploying it on a Ubuntu server.
I downloaded the pre-compiled DLLs for MONO here
https://system.data.sqlite.org/downloads/1.0.104.0/sqlite-netFx451-binary-Mono-2013-1.0.104.0.zip
I downloaded the source code and compiled libSQLite.Interop.so using this script, and then moved libSQLite.Interop.so into the website's bin folder alongside the other DLLs
https://system.data.sqlite.org/index.html/artifact?ci=trunk&filename=Setup/compile-interop-assembly-release.sh
It still complains about System.DllNotFoundException: SQLite.Interop.dll. I tried renaming libSQLite.Interop.so to SQLite.Interop.dll and that doesn't help.
What else do I need to do to get SQLite(EF6) to run on MONO on Ubuntu?

I fix familliar problem by acting as
http://blog.wezeku.com/2016/10/09/using-system-data-sqlite-under-linux-and-mono/
telled.
You may clone source codes, and compile it in specific linux-env.
A shortcut:
Building System.Data.SQLite Interop under Linux
There’s no System.Data.SQLite package for Linux, so you’ll have to build it yourself on your target Linux machine. You can build using this procedure, which is tested in Raspbian Jessie on a Raspberry Pi 3 and Ubuntu 16.04.1 on a PC:
Download System.Data.SQLite full source code from this download page. There’s a ton of files there, and the one you should look for is named something like sqlite-netFx-full-source-<version no>.zip.
Unzip it and transfer it to a directory on your Linux machine. In the rest of this description, I’ll call this directory “<source root>”.
Issue these commands in a Linux terminal:
sudo apt-get update
sudo apt-get install build-essential
cd <source root>/Setup
chmod +x compile-interop-assembly-release.sh
./compile-interop-assembly-release.sh
Now, you will have a freshly built library file called libSQLite.Interop.so in the <source root>/bin/2013/Release/bin directory. This file might have execution permission which isn’t relevant for a library, so remove it by
chmod -x <source root>/bin/2013/Release/bin/libSQLite.Interop.so
Copy libSQLite.Interop.so the directory where your Mono/.NET application’s binaries reside (not the x64 or x86 subdirectories containing SQLite.Interop.dll), and you’re set to go.
And that, ladies and gentlemen, is how we do that!

Do not use the interop version at all, instead stick to the libmono-sqlite4.0-cil package which you probably already have installed. If the sqlite dll is deployed with your application, delete it so the system picks up the packaged version from the GAC.

Related

Microsoft.AspNetCore.Server.Kestrel.Transport.Quic - error after NET6 migration

I have already updated my app (asp.net API) from NetCore3.1 to Net6. There was no breaking changes. To build my app I use command
dotnet publish --runtime win-x64 --self-contained -c release -o build
When I run app on local env everything works fine, but when I copy package into CICD server I get error when app is starting
Could not load file or assembly
'Microsoft.AspNetCore.Server.Kestrel.Transport.Quic, Version=6.0.0.0, PublicKey=adb9...'. The system cannot find the file specified.
There is such dll in bin folder, but different version (ver 6.0.4 and public key started with f9ae).
I don't understand why correct version isn't present in build folder (I publish as self-contained).
How can I check where is such DLL located on my local environment (can I log it)? What should I do to finish migration to NET6?
I find answer, on server there was old app.runtime.json which made mess with dependencies.
Please remember to update [app].runtime.json when you migrate from NetCore3.1 to NET6 :)

Build mono for detecting runtime memory leakcage (in sources) for Linux

I had some problems with mono on linux. My application, which was build with c# on windows doesn't leak, but with mono I have different situation. After searching mono site I found this post, I build and install it (without asan). After I downloaded mono sources, used mono 5.8. And build It with flags for detecting memory leakage and set path :
# Ensure that all required packages are installed.
sudo apt-get install git autoconf libtool automake build-essential gettext cmake python
./autogen.sh --prefix=/usr/local --with-malloc-mempools=yes
make get-monolite-latest
make
make install
After building and installing, I run My application with
mono --profile=malloc:log-malloc ATS_RW_PTD.exe
And get result:
The 'malloc' profiler wasn't found in the main executable nor could it be loaded from 'mono-profiler-malloc'.
I can't understand where I'm wrong and which profile I have to use. Is it step by step instruction for runtime memory leakage detection in mono?

how to include nuget package on raspberry pi without internet?

is there are way to use nuget Packages with dotnet on a raspberry PI without Internet?
I have installed dotnet SDK on a raspberry PI.
I have also installed nuget CLI on raspberry PI.
I am using nuget CLI with mono.
I followed the second Answer from this Question :
dotnet add package with local package file
I created a feed from package. When I enter:
dotnet add package MyPackage -s ./packages
I get this as output:
Writing /tmp/tmp3Ax5wm.tmp
info: Adding PackageRefernce for package 'system.device.gpio' into project '/home/pi/ws/dotnet/testapp.csproject'.
info: Restoring packages for /home/pi/ws/dotnet/testapp.csproject...
error: Unable to load the service index for source https://api.nuget.org/v3/index.json.
error: Resource temporarily unavailable
Somebody has an idea? I coppied the .nupkg with a usb stick on the raspberry pi.
Maybe running a nuget Server on the raspberry pi and push it the local server and install it from there? For example https://github.com/ai-traders/liget ?
Is there a easy way to solve the problem?
I would recommend you add directory with all your packages you need as a local file share. Then you just need to define that local file share as a source in a nuget.config file at the root of your app. Then when you run the command it will check that file share for the package. Much easier to implement then having to host a nuget server.
Here are some docs on it: https://learn.microsoft.com/en-us/nuget/hosting-packages/local-feeds
I would recommend you to not use the .Net core SDK on your raspberry but .Net core Runtime then you can develope your .Net core app on a real PC and publish to a publish folder. During publish .Net core restores all DLLs of nuget packages into the publish folder. After that you can easily copy paste your publish folder on your raspberry and start your app with dotnet yourpath/yourApplicationName.dll in Linux-cli or execute for windows the application.exe in the publish folder.

How to run .NET 4.5 on XSP using Mono?

I have installed Mono 3 however when I run xsp or xsp4 it shows that I'm using .NET 4.0. I need to have .NET 4.5. Is it possible? Where can I configure it?
I've seen this page but I don't have any of those folders where I downloaded sources.
This is what it shows when I enter website by running xsp4:
Version Information: 3.2.7 (master/1eef047 C nov 28 18:16:30 EET 2013); ASP.NET Version: 4.0.30319.17020
How I installed Mono and XSP
Firstly I downloaded Lubuntu 13.10 32bit and launched it inside VirtualBox. Then did apt-get update and apt-get upgrade. After that rebooted the system.
Make sure all commands are executed as super user.
sudo -s
Got dependencies
apt-get install autoconf automake libtool g++ gettext libglib2.0-dev libpng12-dev libfontconfig1-dev mono-gmcs git
Downloaded sources of Mono and XSP
cd /opt
git clone git://github.com/mono/mono.git
git clone git://github.com/mono/xsp.git
Installed latest stable Mono from github
cd /opt/mono
./autogen.sh --prefix=/usr
make
make install
Installed latest stable XSP from github
cd /opt/xsp
./autogen.sh --prefix=/usr
make
make install
Tested that I have 4.0 running on XSP instead of 4.5
cd /home/pc/web
xsp4 # 4.0
xsp2 # 2.0
xsp # 2.0
My configuration
/usr/bin/xsp4 looks like it should use 4.5. Just like this answer suggested. Also, I don't have xsp4.exe in my /usr/lib/mono/4.0/ only in /usr/lib/mono/4.5/ so I cannot copy anything like suggested in that answer.
#!/bin/sh
exec /usr/bin/mono $MONO_OPTIONS "/usr/lib/mono/4.5/xsp4.exe" "$#"
You say "I don't have any of those folders where I downloaded sources" referring to /opt/mono/bin/xsp4. But you're confusing things, and I know it because you shared how you installed mono.
/opt/mono should not be the place where you clone the mono repository to compile it. You should clone it somewhere else like your home folder. I.e.: /home/username/code/mono.
/opt/mono is where usually people install a custom version of mono. The way they do it is passing this path to the --prefix argument. But you're passing /usr as the prefix argument! So then you're installing it to a different location compared to the SO answer that you point out.
Also, it is not recommended that you do ALL those operations as a superuser. You normally compile code without root privileges, and you only need sudo for the install phase. So don't do "sudo -s" before everything. Just compile, and when you're done, do sudo make install. This will also make you have binaries that are not owned by root.

Getting G-WAN to work with Mono

I have followed the instructions on the G-WAN site FAQ and read through the manual, but I can not get G-WAN to "see" the Mono installation on my Debian 6 (x64) setup.
I have tried with the recommended Mono version (3.0.2) and the latest(3.0.4).
I am using the latest (today's) version of G-WAN.
Have I missed some configuration (e.g. environment variables...) or do I need to run Mono as a daemon?
mono by default installs on "/usr/local".
Compiling mono 3.0.6 using
./configure --prefix=/usr
make
make install
Worked for me. It will install libmono*.so on "/usr/lib"
G-WAN searches libmono*.so under /usr/lib and then links dynamically with it to compile C# scripts.
If you have installed Mono elsewhere then you should either provide links or re-build and install Mono (from source code) in the proper directory (which is simpler to do).
You can verify where Mono is installed by running:
find -L /usr/lib -name 'libmono*.so'
/usr/lib/libmono-2.0.so

Categories

Resources