Tag: mono

如何以便携方式在C#中播放压缩声音文件?

是否有一种便携式,而非专利限制的方式来播放C#/ .Net中的压缩声音文件? 我想在节目中发生的各种事件上播放短暂的“叮当”声。 System.Media.SoundPlayer只能处理WAV,但这些通常很大,可嵌入到可下载的应用程序中。 MP3受专利保护,因此即使有完全管理的解码器/播放器,它也不能自由重新分配。 可用的最佳格式似乎是OGG Vorbis,但我没有运气让任何C#Vorbis库工作(我设法用csvorbis提取原始PCM,但我不知道如何在之后播放它)。 我既不想使用我的应用程序分发任何二进制文件,也不想依赖于P / Invoke,因为该项目至少应该在Windows和Linux上运行。 只要它们与GPL许可兼容,我就可以捆绑.Net程序集。 [这个问题是一年前关于mono-dev邮件列表的邮件列表讨论的后续问题]

OpenCV + Unity3D集成

我是团结开发人员,第一次尝试使用opencv。 我最初的目标是运行相机并通过unity3d中的opencv检测blob。 我是OpenCV的新手,我正在尝试将它集成到Unity3D中(在Windows 8上使用Unity 4.3.2,在Mac上使用Unity 4.2.1f)。 我跟着这个post。 但是,一旦添加新的C#脚本,我就会收到以下错误。 当我删除这个脚本的那一刻,错误发生了(这个脚本是Unity生成的C#脚本)。 Internal compiler error. See the console log for more information. output was: Unhandled Exception: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded. at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool) at System.Reflection.Assembly.GetTypes () [0x00000] in :0 at Mono.CSharp.RootNamespace.ComputeNamespaces (System.Reflection.Assembly assembly, System.Type extensionType) [0x00000] in :0 at Mono.CSharp.RootNamespace.ComputeNamespace (Mono.CSharp.CompilerContext […]

StreamReader.Peek和Thread.Interrupt的替代方案

我正在尝试做的快速序言。 我想启动一个进程并启动两个线程来监视stderr和stdin。 每个线程都会剔除流中的一些内容,然后将其发送到NetworkStream。 如果任一线程中都有错误,则两个线程都需要立即死亡。 具有stdout和stdin监视线程的这些进程中的每一个都由主服务器进程分离。 这变得棘手的原因是因为在任何给定时间都可以容易地有40或50个这样的过程。 只有在早上重新启动时才会有超过50个连接,但它确实需要能够处理100个或更多。 我测试100个同时连接。 try { StreamReader reader = this.myProcess.StandardOutput; char[] buffer = new char[4096]; byte[] data; int read; while (reader.Peek() > -1 ) // This can block before stream is streamed to { read = reader.Read(buffer, 0, 4096); data = Server.ClientEncoding.GetBytes(buffer, 0, read); this.clientStream.Write(data, 0, data.Length); //ClientStream is a NetworkStream […]

使用具有“params”参数的reflection调用函数(MethodBase)

我有两个函数的MethodBases: public static int Add(params int[] parameters) { /* … */ } public static int Add(int a, int b) { /* … */ } 我有一个通过我制作的类调用MethodBases的函数: MethodBase Method; object Target; public object call(params object[] input) { return Method.Invoke(Target, input); } 现在,如果我AddTwoMethod.call(5, 4); 它工作正常。 但是,如果我使用AddMethod.call(5, 4); 它返回: 未处理的exception:System.Reflection.TargetParameterCountException:参数与签名不匹配 是否有任何方法可以使两个调用都正常工作而无需手动将参数放入数组中用于params int[] ?

Mono和Gtk的全球热键#

我正在尝试使用Mono在Linux中使用全局热键。 我找到了XGrabKey和XUngrabKey的签名,但我似乎无法让它们正常工作。 每当我尝试调用XGrabKey ,应用程序都会遇到SIGSEGV崩溃。 这是我到目前为止: using System; using Gtk; using System.Runtime.InteropServices; namespace GTKTest { class MainClass { const int GrabModeAsync = 1; public static void Main(string[] args) { Application.Init(); MainWindow win = new MainWindow(); win.Show(); // Crashes here XGrabKey( win.Display.Handle, (int)Gdk.Key.A, (uint)KeyMasks.ShiftMask, win.Handle, true, GrabModeAsync, GrabModeAsync); Application.Run(); XUngrabKey( win.Display.Handle, (int)Gdk.Key.A, (uint)KeyMasks.ShiftMask, win.Handle); } [DllImport(“libX11”)] internal […]

如何使“mkbundle –deps”选项与mono 3.2.3一起使用

我试图将应用程序与单声道3.2.3捆绑到一个独立的可执行文件。 为此,我遵循本指南。 声明变量后: mono_version=”3.2.3″ export MONO=/cygdrive/c/progra~2/Mono-$mono_version machineconfig=$PROGRAMFILES\\Mono-$mono_version\\etc\\mono\\4.5\\machine.config export PATH=$PATH:$MONO/bin export PKG_CONFIG_PATH=$MONO/lib/pkgconfig export CC=”i686-pc-mingw32-gcc -U _WIN32″ mkbundle –deps命令无法本地化引用的程序集: Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly ‘gtk-sharp’ or one of its dependencies. The system cannot find the file specified. File name: ‘gtk-sharp’ 使用mono 2.10.9执行完全相同的操作: mono_version=”2.10.9″ export MONO=/cygdrive/c/progra~2/Mono-$mono_version machineconfig=$PROGRAMFILES\\Mono-$mono_version\\etc\\mono\\4.0\\machine.config export PATH=$PATH:$MONO/bin export PKG_CONFIG_PATH=$MONO/lib/pkgconfig export CC=”i686-pc-mingw32-gcc -U […]

使用SSL向GMail发送邮件时,身份validation或解密失败

我指的是关于C#SMTP邮件的本指南 。 这是我的代码: MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient(“smtp.gmail.com”); mail.From = new MailAddress(“dave.stockinger@gmail.com”); mail.To.Add(“dave.stockinger@gmail.com”); mail.Subject = “Test Mail”; mail.Body = “This is for testing SMTP mail from GMAIL”; SmtpServer.Port = 587; SmtpServer.Credentials = new System.Net.NetworkCredential(“MyUserNameInGmail”, “MyGmailPassWord”); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); 不幸的是,有一个关于SSL的例外,我无法修复它: 未处理的exception:System.Net.Mail.SmtpException:无法发送消息。 —> System.IO.IOException:身份validation或解密失败。 —> System.InvalidOperationException:SSL身份validation错误:RemoteCertificateNotAvailable,System.Net.Mail.SmtpClient.m__4上的RemoteCertificateChainErrors(System.Object sender,System.Security.Cryptography.X509Certificates.X509Certificate证书,System.Security.Cryptography.X509Certificates。 X509链接,SslPolicyErrors sslPolicyErrors)[0x00000] in:0在System.Net.Security.SslStream + […]

将UIImage转换为字节数组

我需要将UIImage转换为字节数组。 我正在使用Xamarin的Visual Studio插件来生成iOS应用程序。 下面的代码位获取图像,但我需要将其作为字节数组而不是UIImage发送到服务堆栈。 var signatureView = new SignaturePad.SignaturePadView(new RectangleF(10, 660, 300, 150)); signatureView.BackgroundColor = UIColor.White; this.View.AddSubview(signatureView); UIImage signatureImage = signatureView.GetImage();

Visual Studio 2015 UNITY项目中的参考System.Data

我在我的Unity项目中使用Visual Studio。 (Unity使用单声道框架,而不是.net)。 我正在使用数据库,所以我必须在我保留在Assets / Plugins文件夹中的项目中使用System.Data.dll: 如您所见,Visual Studio在查看System.Data库时遇到问题。 所以我很难编码: 还有一些红线: 令人惊讶的是,我在Unity中没有错误,代码实际上正在工作: 我在VS中也有这个恼人的黄色图标: 你能帮我强迫Visual Studio看看System.Data库吗?

如何使用Mono C#截取屏幕截图?

我正在尝试使用代码在Mono C#中获取屏幕截图,但是当我调用CopyFromScreen时,我得到一个System.NotImplementedException。 我的代码适用于.NET,那么是否有另一种使用Mono获取屏幕截图的方法? Bitmap bitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height); Graphics graphics = Graphics.FromImage(bitmap as Image); graphics.CopyFromScreen(0, 0, 0, 0, bitmap.Size); System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(); bitmap.Save(memoryStream, imageFormat); bitmap.Save(@”\tmp\screenshot.png”, ImageFormat.Png); 我使用的是Mono JIT编译器版本2.4.2.3(Debian 2.4.2.3 + dfsg-2) 更新:Mono无法截屏。 伤心。 瘸。