c# - 树莓派上的单声道在共享对象 (.so) 文件的 DLLImport 处抛出 DLLNotFoundException

标签 c# mono dllimport raspberry-pi dllnotfoundexception

我目前在树莓派 (B) 上使用单声道运行时。我使用适用于 Windows 桌面的 Visual Studio Express 2012。我基本上想要实现的是将网络摄像头 (Logitech C270) 中的一系列图片保存到 .jpg 文件中。

我找到了一个似乎可以满足我需要的项目: http://www.raspberry-sharp.org/romain-flechner/2012/10/projects/use-a-webcam-plugged-in-a-raspberry-pi-with-mono-in-c-using-raspberrycam/ 所以我通过 NuGet 将它安装到我的项目中并复制了代码示例:

Cameras cameras = Cameras.DeclareDevice()
.Named(“Camera 1″).WithDevicePath(“/dev/video0″)
.Memorize();

cameras.Get(“Camera 1″).SavePicture(new PictureSize(640, 480), “/var/www/test.jpg”, 20);

正如项目页面上的说明所写,我将 RaspberryCam.so 复制到/lib 目录(为此我也将它复制到/Lib)。然后我将构建的文件(my.exe、RaspberryCam.dll)下载到我的 Raspberry PI。

现在这是我的问题: 每当我尝试使用单声道执行我的程序时,我都会收到 RaspberryCam.so 的 DllNotFoundException。

我将我的项目路径添加到/etc/ld.so.conf 并运行了 ldconfig 但这没有帮助。

我还尝试在 Debug模式下运行单声道 (MONO_LOG_LEVEL="debug"MONO_LOG_MASK="dll"mono/var/www/my.exe),它似乎在搜索“libRaspberryCam.so”,所以我复制了/lib/RaspberryCam.so 到/lib/libRaspberryCam.so,但这也没有改变任何东西。

顺便说一句,我将 .so 文件的访问权限更改为 755(root 用户读、写、执行,world 用户读、执行)。

老实说,我对 DLL 导入的东西了解不多,所以我可能只是在这里犯了一些愚蠢的错误。但是我上周已经在 raspberrycam 项目页面上写了评论,但我还没有得到任何答复。

谁能帮我解决这个问题?

谢谢 多米尼克

编辑: 实际 DLLImport 的代码来自 Raspberrycam 项目“RaspberryCamInterop.cs”:

using System;
using System.Runtime.InteropServices;

namespace RaspberryCam.Interop
{
    public class RaspberryCamInterop
    {
        [DllImport("RaspberryCam.so", EntryPoint = "TakePicture")]
        public static extern PictureBuffer TakePicture(string device, uint width, uint height, uint jpegQuantity);

        [DllImport("RaspberryCam.so", EntryPoint = "OpenCameraStream")]
        public static extern IntPtr OpenCameraStream(string device, uint width, uint height, uint fps);

        [DllImport("RaspberryCam.so", EntryPoint = "CloseCameraStream")]
        public static extern void CloseCameraStream(IntPtr src);

        [DllImport("RaspberryCam.so", EntryPoint = "ReadVideoFrame")]
        public static extern PictureBuffer ReadVideoFrame(IntPtr src, uint jpegQuantity);

        [DllImport("RaspberryCam.so", EntryPoint = "GrabVideoFrame")]
        public static extern PictureBuffer GrabVideoFrame(IntPtr src);
    }
}

编辑 2: soft-float 喘息声似乎有些问题。我现在已经安装了标准的 hard-float raspbian(正如它在项目页面的指南中所写:http://www.raspberry-sharp.org/eric-bezine/2012/10/mono-framework/installing-mono-raspberry-pi/)并且它可以工作,虽然不是特别快,但它确实保存了图片。 我发现他们使用 hard-float raspbian 图像有点令人恼火,尽管 mono 与 ARM hard-float abi 不兼容。 在单声道安装指南中,他们也没有提到任何 hard-float 补丁,我什至在 RaspberryCam 项目的源代码中找到了一些解决方法,因此他们确实注意到了与在 hard-float abi 上运行单声道相关的错误。

来自“PicturesCache.cs”的片段

//Timespan bug with ARM version of MONO, so we will use int in milliseconds
private readonly int duration;

但是,我将坚持使用 soft-float wheezy,并使用一个名为 uvccapture 的工具与一些 shell 脚本协作来完成这项工作。

但我仍然感谢您的任何建议或解决方案。

最佳答案

对我有用的是:我复制了 .exe 文件夹中的库并将其重命名为 libRaspberryCam.so。

在我这边,质量很差。我无法从此库配置相机。

关于c# - 树莓派上的单声道在共享对象 (.so) 文件的 DLLImport 处抛出 DLLNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17522907/

相关文章:

.net - Android 版 Mono 中的 Web 引用

c++ - 将一个dll导入另一个dll C++

c# - 从 Entity Framework Core IQueryable<T> 获取 SQL 代码

c# - 使用 linq 从 IEnumerable 中排除类型

c# - 我们如何在 C# 中从 C++ DLL 获取所有方法?

c# - 动态操作<T> : Invalid Arguments when executed

ios - Xamarin.iOS 应用程序因缺少 Mono 运行时而崩溃;没有找到合适的图片;代码签名阻止了 mmap

c# - 在 MonoDevelop 中获得漂亮的小部件尺寸 (Gtk#)

c++ - 导出 DLL 类和函数并将它们导入 Win32 应用程序

c# - 这个 API 到底是什么,它在做什么?