Mono fails to load a dll - mono

I am trying to load use a native shared library via P/Invoke. However, it won't load from under MonoDevelop. This is the console output with MONO_LOG_LEVEL=debug and MONO_LOG_MASK=dll:
Creating a V8Engine instance ...Mono: DllImport attempting to load: 'V8_Net_Proxy'.
Mono: DllImport error loading library '/localhome/rryk/v8netmonolinux/Source/bin/Debug/libV8_Net_Proxy': '/localhome/rryk/v8netmonolinux/Source/bin/Debug/libV8_Net_Proxy: cannot open shared object file: No such file or directory'.
Mono: DllImport error loading library '/localhome/rryk/v8netmonolinux/Source/bin/Debug/libV8_Net_Proxy.so': 'libv8-x64.so: cannot open shared object file: No such file or directory'.
However, the libv8-x64.so is located in the same directory as libV8_Net_Proxy.so:
/localhome/rryk/v8netmonolinux/Source/bin/Debug [mono-linux *]$ ls
libV8_Net_Proxy.so V8.Net.Console.exe.config V8.Net.dll.mdb V8.Net.Proxy.Interface.x64.dll V8.Net.SharedTypes.dll.mdb x64
libv8-x64.so V8.Net.Console.exe.mdb V8.Net.Proxy.Interface.dll V8.Net.Proxy.Interface.x64.dll.mdb V8.Net.SharedTypes.XML x86
V8.Net.Console.exe V8.Net.dll V8.Net.Proxy.Interface.dll.mdb V8.Net.SharedTypes.dll V8.Net.XML
Even more interesting is that the same very application loads the library just fine when executed from the console:
/localhome/rryk/v8netmonolinux/Source/bin/Debug [mono-linux *]$ MONO_LOG_LEVEL=debug MONO_LOG_MASK=dll mono V8.Net.Console.exe
Creating a V8Engine instance ...Mono: DllImport attempting to load: 'V8_Net_Proxy'.
Mono: DllImport error loading library '/localhome/rryk/v8netmonolinux/Source/bin/Debug/libV8_Net_Proxy': '/localhome/rryk/v8netmonolinux/Source/bin/Debug/libV8_Net_Proxy: cannot open shared object file: No such file or directory'.
Mono: DllImport loaded library '/localhome/rryk/v8netmonolinux/Source/bin/Debug/libV8_Net_Proxy.so'.
I also checked that the same mono binary is used both on the console and in MonoDevelop. In fact I couldn't check which binary is used by MonoDevelop, but .NET Runtimes section in the settings displays version 3.0.12. I only have one Mono binary in the system which has this version and it is the one used on the command line by default (as it's listed first in whichis):
~$ whereis mono
mono: /usr/bin/mono /etc/mono /usr/lib/mono /usr/bin/X11/mono /usr/local/bin/mono /usr/local/etc/mono /usr/local/lib/mono /usr/share/mono /usr/share/man/man1/mono.1.gz
What can cause the difference? Why doesn't Mono find the libv8-x64.so, which is located in the same directory?

Try:
LD_LIBRARY_PATH=`pwd` mono V8.Net.Console.exe

Related

OSError: cannot load library 'libxcb.dll': error 0x7e

I tried to run a python program on the PyQt5 framework but it's giving me .dll file errors.
I've installed tools to fix it but it's still giving me this error :
OSError: cannot load library 'libxcb.dll': error 0x7e
I have already installed all these tools:
**Uniconvertor-2.0rc5-win64_headless.msi
GTK+ for Windows Runtime Environment Installer**
it always gives me this error "OSError: cannot load library 'libxcb.dll': error 0x7e".
Is there any other way to fix this error?

wine tells me to install .NET and mono gives error "File does not contain a valid CIL image."

i want to run hunterpie.exe . I've test wine (i've installed wine-mono) which tells me :
A fatal error occurred. The required library hostfxr.dll could not be found.
If this is a self-contained application, that library should exist in [Z:\home\osafaimal\.local\share\Steam\steamapps\common\MonsterHunterRise\HunterPie\].
If this is a framework-dependent application, install the runtime in the global location [C:\Program Files\dotnet] or use the DOTNET_ROOT environment variable to specify the runtime location or register the runtime location in [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x64\InstallLocation].
The .NET runtime can be found at:
- https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=win7-x64&apphost_version=5.0.1
002c:err:eventlog:ReportEventW L"Description: A .NET application failed.\nApplication: HunterPie.exe\nPath: Z:\\home\\osafaimal\\.local\\share\\Steam\\steamapps\\common\\MonsterHunterRise\\HunterPie\\HunterPie.exe\nMessage: A fatal error occurred. The required library hostfxr.dll could not be found.\nIf this is a self-co"...
i've test to install .NET on my computer (Ubuntu 21.10 x86_64), Same error.
i've test to run with mono and it gives:
Cannot open assembly 'HunterPie.exe': File does not contain a valid CIL image.
Can someone explains what I should to do?

IronPython + Mono error - could not load signature

When trying to run IronPython from Mono, I get the following error:
wayne#arglefraster ~/Downloads/IronPython-2.7.3 ⚘ mono ipy.exe 19:19:23
Could not load signature of IronPython.Runtime.List:get_Item due to:
Failed to load language 'IronPython 2.7': Could not load type 'IronPython.Runtime.List' from assembly 'IronPython, Version=2.7.0.40, Culture=neutral, PublicKeyToken=7f709c5b713576e1'.
Fiddling around here on SO I found MONO_LOG_LEVEL=debug, and got this relevant information
Mono: Assembly Loader probing location: '/usr/lib/System.Numerics.exe'.
Mono: The following assembly referenced from /home/wayne/Downloads/IronPython-2.7.3/IronPython.dll could not be loaded:
Assembly: System.Numerics (assemblyref_index=5)
Version: 4.0.0.0
Public Key: b77a5c561934e089
The assembly was not found in the Global Assembly Cache, a path listed in the MONO_PATH environment variable, or in the location of the executing assembly (/home/wayne/Downloads/IronPython-2.7.3/).
Mono: Failed to load assembly IronPython[0xddd180]
Mono: Could not load file or assembly 'System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies.
Could not load signature of IronPython.Runtime.List:get_Item due to:
Mono: gc took 520 usecs
Mono: Unloading domain ipy.exe[0x7faebd540cc0], assembly IronPython[0xddd180], ref_count=2
How can I get this working?
It turns out that the Numerics library wasn't installed:
wayne#arglefraster ~/Downloads/IronPython-2.7.3 ⚘ apt-cache search mono numerics
libmono-system-numerics4.0-cil - Mono System.Numerics library (for CLI 4.0)
wayne#arglefraster ~/Downloads/IronPython-2.7.3 ⚘ sudo apt-get install libmono-system-numerics4.0-cil
And off it went!

Issues with running nunit-console.exe with Mono

I could make a dll for NUnit NUnit test under mono, but when I tried to run in with nunit-console.exe I get the following error message.
Runtime Environment -
OS Version: Unix 10.3.0.0
CLR Version: 2.0.50727.1433 ( 2.6.4 (tarball Thu Apr 22 13:24:33 MDT 2010) )
ProcessModel: Default DomainUsage: Single
Execution Runtime: mono-2.0
** (/Users/smcho/bin/NUnit-2.5.5.10112/bin/net-2.0/nunit-console.exe:36800): WARNING **: The following assembly referenced from /private/var/folders/m4/m4u1hmP+FHOQaiZbHj1UCk+++TI/-Tmp-/nunit20/ShadowCopyCache/36800_634111616836311880/Tests_-22323139/assembly/shadow/54274fc2/118e035c_45a94c9e_00000001/mut.dll could not be loaded:
Assembly: nunit.framework (assemblyref_index=1)
Version: 2.5.5.10112
Public Key: 96d09a1eb7f44a77
System error: Invalid argument
** (/Users/smcho/bin/NUnit-2.5.5.10112/bin/net-2.0/nunit-console.exe:36800): WARNING **: Could not load file or assembly 'nunit.framework, Version=2.5.5.10112, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77' or one of its dependencies.
What might be wrong? I have nunit.framework.dll under /Users/smcho/bin/NUnit-2.5.5.10112/bin/net-2.0/framework, but it doesn't seem to know about this.
This is another frustrating point about using NUnit in Mono. As far as I've been able to tell, you need to have all of those missing files (there will be more than just nunit.framework.dll) in the same directory as nunit-console.exe.
There might be a command line option either in mono or nunit-console.exe to specify another directory to search for missing DLLs -- I'm not sure. Barring that, you'll have to copy the missing DLLs into the same folder as nunit-console.exe, or you'll have to cd into the framework folder and use mono ../nunit-console.exe /path/to/my/tests.dll
Once nuget is installed, you can use it to install nunit.console like so:
(This is from my .circlci/config.yml file)
- run: mono --runtime=v4.0 nuget.exe install nunit.console
- run: msbuild MySolution.sln
- run: mono --runtime=v4.0 NUnit.ConsoleRunner.3.12.0/tools/nunit3-console.exe FirstModule.Tests/bin/Debug/FirstModule.Tests.dll
- run: mono --runtime=v4.0 NUnit.ConsoleRunner.3.12.0/tools/nunit3-console.exe SecondModule.Tests/bin/Debug/SecondModule.Tests.dll
The trick is to specify the entire path for the NUnit.ConsoleRunner and to watchout for the - changing into a . by version 3

Upgrading App from .NET 3.5 to 4.0, COM fails now

I have an application that I am upgrading from the .NET 3.5 to the .NET 4.0 framework. It uses a COM library which is referenced. It works no problem in 3.5 but after converting to 4.0 I have issues getting the COM to work. The COM is from a 3rd party so we didn't develop it ourselves.
I get the following COM error (generic COM error, not specific to the COM object itself): hr = 0x8007000b
CLR gives me: 'The invocation of the constructor on type 'Skype_Business_Launcher.Main' that matches the specified binding constraints threw an exception.' Line number '3' and line position '5'.
And the C# logs:
=== Pre-bind state information ===
LOG: User = \phillip
LOG: DisplayName = Interop.SKYPE4COMLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : Skype Business Launcher, Version=1.0.5.0, Culture=neutral, PublicKeyToken=null.
LOG: This bind starts in default load context.
LOG: Using application configuration file:
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///bin/Debug/Interop.SKYPE4COMLib.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.
I removed the pathname for security reasons but I have checked all the path information and it's all correct. Also the COM library file exists where it's pointing to. It's also copied to the OBJ folder within the project as well.
Originally I was getting an error about the COM library not supporting embedded types so I made "Embed Interop Types" false (it was true below) and the error went away but I'm not sure if thats connected to this error or not so I thought I'd mention it just in case.
Again, it works just fine with 3.5.
Thanks,
A shot in the dark: it looks like you are using the x64 version of the framework. Was that already the case with 3.5 ? And is the COM server a DLL or an EXE ?
If the COM server is a DLL, there needs to be a "bitness" match between the DLL and your program.
when you convert your project to 4.0 the IDE can perform a issue to convert COM library into 4.0.
when you convert your project to 4.0 remove com library then Re include it in your project then i thing it should be works.