ubuntu - 如何使用 dllimport 解决 DllNotFoundException? (单声道)

标签 ubuntu libraries .net

我是 Unix/Linux/Ubuntu 的新手。

我正在将 Mono 与 VB 一起使用,我正在尝试通过 DllImport (CliSiTef32I.dll/libclisitef.so) 使用库中的方法,但是它一直给我 DllNotFoundException

在论坛中搜索我已经尝试了一些事情:

  • ld.so.conf 包含库的路径
  • project.exe.config中的dllMap

  • 任何帮助表示赞赏。

    我的代码:(我尝试直接使用 .Dll 和 .SO 导入,但均无效)

    C#
    using System;
    using System.Runtime.InteropServices;
    
    namespace SitefCSharp
    
    {
    
    static class MdlTEF
    
    {
    
    [DllImport("CliSiTef32I.dll")] // [DllImport("libclisitef.so")]    
    private static extern int ConfiguraIntSiTefInterativo(string EndSitef, string IdLoja, string IdTerminal, Int16 Reservado);
    
            static void Main()
            {
                int sts = 0;
                try
                {
                    sts = ConfiguraIntSiTefInterativo("", "", "", 0);                
                }
                catch (Exception ex)
                {
                    string msg = ex.ToString();
                    //the exception is System.DllNotFoundException at (wrapper managed-to-native)
                }
            }
        }
    }
    

    VB
    Imports System
    Imports System.IO
    Imports System.Windows.Forms
    Imports Microsoft.VisualBasic.Interaction
    
    
    Public Module EmptyClass
    
        Public Sub Main()
        Dim sts as Integer
        Try
            sts = ConfiguraIntSiTefInterativo("", "", "", 0)
        Catch ex as Exception
            MsgBox(ex.ToString)
        End Try
    
        End Sub
    
        Public Declare Function ConfiguraIntSiTefInterativo Lib "libclisitef.so" (ByVal EndSiTef As String, ByVal IdLoja As String, ByVal IdTerminal As String, ByVal Reservado As Int16) As Int32
        'Public Declare Function ConfiguraIntSiTefInterativo Lib "CliSiTef32I.dll" (ByVal EndSiTef As String, ByVal IdLoja As String, ByVal IdTerminal As String, ByVal Reservado As Int16) As Int32
    
    End Module
    

    //project.exe.config文件中的dll映射
    <configuration>
        <dllmap dll="CliSiTef32I.dll" target="libclisitef.so"/>
    </configuration>
    

    //我的 ld.so.conf 文件...我尝试将库放在所有这些路径中
    /home/pdv/Projetos/PDV/kaiser/clisitef
    /lib
    /lib64
    /usr/lib
    /usr/lib64
    /usr/local/lib
    /usr/local/lib64
    /home/pdv/Projects/TesteTef/TesteTef/bin/Debug
    include /etc/ld.so.conf.d/*.conf
    

    最佳答案

    我使用 mono log_level=debug 发现了问题
    它无法加载 32 位 dll,我尝试了 64 版本,它工作!

    关于ubuntu - 如何使用 dllimport 解决 DllNotFoundException? (单声道),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56025883/

    相关文章:

    python - SciPy 安装和测试后的奇怪文件

    c# - 如何在 Windows 上过滤到特定域名的网络连接

    python - 导入skimage导入数据报错,过滤器

    python - Pyaudio 2.11 安装失败

    c# - 调用多播委托(delegate)是否分配内存?

    .net - string1 >= string2 未在 Linq to SQL 中实现,有什么解决方法吗?

    ubuntu - nginx.conf 中的过期会在 ubuntu 上引发错误,但在 OSX 上不会

    java - Ant 找不到 javac,在 Ubuntu 上不会设置 JAVA_HOME

    ubuntu - beaglebone 绿色无线中的 connmactl 问题

    iOS SDK - 链接静态库与静态库