I'm very new to C#, MonoMac and Xamarin and am trying to play some generated audio with C# and Xamarin.Mac using this awesome example.
Unforunately the first line:
AudioSession.Initialize();
throws an EntryPointNotFoundException.
I've stumbled upon this forum post where someone is having a similar problem and suggests that it has to do with an incorrect binding.
Can I actually get this to work? If not, what can I use instead?
Thank you so much for your help.
My System
Xamarin.Mac: 1.2.43
Xamarin.Studio Version 4.0.3 (build 13)
Mono 2.10.12 (mono-2-10/c9b270d)
GTK 2.24.16
GTK# (2.12.0.0)
Package version: 210120000
Stack Trace
System.EntryPointNotFoundException: AudioSessionInitialize
at at (wrapper managed-to-native) MonoMac.AudioToolbox.AudioSession.AudioSessionInitialize (intptr,intptr,MonoMac.AudioToolbox.AudioSession/InterruptionListener,intptr) <IL 0x00011, 0x0007b>
at MonoMac.AudioToolbox.AudioSession.Initialize (MonoMac.CoreFoundation.CFRunLoop,string) [0x00013] in /Users/builder/data/lanes/xamcore-lion-bs1/0c83ca0e/source/xamcore/maccore/src/AudioToolbox/AudioSession.cs:225
I think that AudioSession is not used on OS X.
The sample code you are working from is likely for iOS.
If you check the documentation for AudioSession, you will see:
These functions apply only to iOS. They do not apply to Mac OS X.
Additionally, see this discussion. AudioSession is simply not available, which is why you get EntryPointNotFoundException when trying to call it...
Related
I have created a simple Unity application that uses MySQL. The app works perfectly in the Unity Editor, however when I build it for PC Standalone or Android, it does not work.
After checking the log files, the following exception has been thrown
PlatformNotSupportedException: Operation is not supported on this platform.
at MySql.Data.MySqlClient.MySqlConfiguration..cctor () [0x00000] in <5bca8ad0d7cb4bf194403b342b8f0938>:0
Rethrow as TypeInitializationException: The type initializer for 'MySql.Data.MySqlClient.MySqlConfiguration' threw an exception.
at MySql.Data.MySqlClient.Replication.ReplicationManager..cctor () [0x0001e] in <5bca8ad0d7cb4bf194403b342b8f0938>:0
Rethrow as TypeInitializationException: The type initializer for 'MySql.Data.MySqlClient.Replication.ReplicationManager' threw an exception.
at MySql.Data.MySqlClient.MySqlConnection.Open () [0x002be] in <5bca8ad0d7cb4bf194403b342b8f0938>:0
at Main.Start () [0x0008b] in <7257cb8e307a4c4d92671557aa30bf0e>:0
at Main.Update () [0x0000d] in <7257cb8e307a4c4d92671557aa30bf0e>:0
How can MySQL not be supported on either of my platforms (both Android and PC Standalone) yet it works in Unity editor? Furthermore, I have recently created another game that also uses MySQL and works fine on all platforms. What could be the issue?
Feel free to ask me for code files, Unity files or whatever you think you need to help me solve the issue. Thank you!
Edit: Solved | just changed the API compatibility settings to .NET 4.x
I think this because of API Compatibility Level, here are the references to similar problems:
link 1
link 2
API Compatibility Level can be found in:
File > Build Settings > Player Settings > Player > Configuration
I've made a C# console application which compiles with mono (mcs) and I can run that on both Windows and Raspberry Pi (raspbian). The application uses the NuGet package Vlc.DotNet.Core to interface with the VLC installation that exists on my Windows machine, and this works.
I know the path to libvlc.dll (which the api requires in order to work) on my Windows machine, the problem is that I can't find that on the Raspberry Pi even after installing VLC on there with apt-get install vlc.
I've searched the Pi for the location of vlc, and entered that path into the constructor of VlcMediaPlayer as follows;
new VlcMediaPlayer(new DirectoryInfo("/usr/lib/arm-linux-gnueabihf/vlc"));
I have very little confidence that I've used the correct path... Clearly there are major differences between VLC's Windows installation and the one for Raspbian.
The resulting exception on the Pi reads:
Unhandled Exception:
System.IO.FileNotFoundException: Unable to find the specified file.
at Vlc.DotNet.Core.Interops.VlcLibraryLoader..ctor (System.IO.DirectoryInfo dynamicLinkLibrariesPath) [0x0007a] in <baf298be89ec4e8f88b59dde806086ea>:0
at Vlc.DotNet.Core.Interops.VlcLibraryLoader.GetOrCreateLoader (System.IO.DirectoryInfo dynamicLinkLibrariesPath) [0x00051] in <baf298be89ec4e8f88b59dde806086ea>:0
at Vlc.DotNet.Core.Interops.VlcManager..ctor (System.IO.DirectoryInfo dynamicLinkLibrariesPath, System.String[] args) [0x00006] in <baf298be89ec4e8f88b59dde806086ea>:0
at Vlc.DotNet.Core.VlcMediaPlayer..ctor (System.IO.DirectoryInfo vlcLibDirectory) [0x00000] in <9af967e78de14038abf8c3386a2b8049>:0
at MonoApp.Classes.VLCFactory.Create () [0x0000b] in <0b03f50fed2542db8a444bf356ef64b6>:0
at MonoApp.Classes.VLCCommands.VLCCommand_Play.Execute (Vlc.DotNet.Core.VlcMediaPlayer& mediaPlayer, System.String[] args) [0x00007] in <0b03f50fed2542db8a444bf356ef64b6>:0
at MonoApp.Program.Main (System.String[] args) [0x00019] in <0b03f50fed2542db8a444bf356ef64b6>:0
EDIT:
I've found the source files to the VlcLibraryLoader class (as seen in the exception) here, and apparently it's looking for three dlls, only two of which exist on Windows so I'm guessing that the linked source files are slightly outdated. The point here is that they're looking for .dll files, not the .so files that exist on the Raspberry Pi, so I'm not surprised it's failing. The question remains, however...
QUESTION:
Am I using the correct vlc package libvlc-dev, are there any other dependencies I need?
Is Vlc.DotNet.Core API known to work on Raspbian with mono or am I on a hopeless path?
I don't know if Vlc.DotNet.Core can be made to work on raspbian with mono. It is initially targetted to work on Windows, as you know.
LibVLCSharp probably will work on raspbian though, since it works with ubuntu.
LibVLC/GTK linux install guide: https://code.videolan.org/videolan/LibVLCSharp/blob/master/docs/linux-setup.md
LibVLCSharp.GTK sample: https://code.videolan.org/videolan/LibVLCSharp/tree/master/Samples/LibVLCSharp.GTK.Sample
Good luck.
I'm attempting to use the OkHttp-Xamarin library in a Xamarin Android application. Whenever I try to create a new OkHttpNetworkHandler I get the exception below.
Line:
var handler = new OkHttpNetworkHandler();
Throws:
[] Missing method Android.Runtime.JNIEnv::AllocObject(Type) in assembly Mono.Android.dll, referenced in assembly /data/data/com.my.app/files/.__override__/OkHttp.dll
[MonoDroid] UNHANDLED EXCEPTION: System.MissingMethodException: Method not found: 'Android.Runtime.JNIEnv.AllocObject'.
[MonoDroid] at ModernHttpClient.OkHttpNetworkHandler..ctor () <IL 0x00001, 0x00057>
I am using prebuilt binaries from ModernHttpClient version 0.9. My minimum Android version is set to 2.3 and target is set to 4.2. I'm using Xamarin Studio 4.0.13 and Mono 3.2.3.
So this looks like the first call to your binding code.
A couple things could be going on here:
Make sure you are using EmbeddedJar instead of InputJar as the build action for the jar file. Otherwise, you have to include the jar with your main Android application.
Make sure your main application has a reference to the binding DLL, it causes problems if only a dependent project has the reference.
If neither of those fix your issue, let me know, I think there is a working binding Paul Betts has for this library.
Not really an answer to why the Exception is being thrown but at the suggestion of Paul Betts I switched to the Alpha channel and things are working now.
I've added a reference to the CUDAfy.NET library via NuGet.
<package id="CUDAfy.NET" version="1.12.4695.21111" targetFramework="net45" />
When I run my program, I hit a Win32Exception:
The system cannot find the file specified
This happens on the first actual line of the program:
CudafyModule km = CudafyTranslator.Cudafy();
There's no indication from the exception object as to what file they're attempting to load.
How can I get past this problem?
EDIT
I see the same exception when running the bundled examples from the Codeplex download in VS2010 using .NET 4.0.
The strack trace is:
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at Cudafy.CudafyModule.Compile(eGPUCompiler mode, Boolean deleteGeneratedCode)
at Cudafy.Translator.CudafyTranslator.Cudafy(ePlatform platform, eArchitecture arch, Version cudaVersion, Boolean compile, Type[] types)
at Cudafy.Translator.CudafyTranslator.Cudafy(ePlatform platform, eArchitecture arch, Type[] types)
at Cudafy.Translator.CudafyTranslator.Cudafy()
Setting VS to break on thrown exceptions shows the ProcessStartInfo object at the top of the stack in the locals pane of the debugger.
The relevant properties are:
FileName = nvcc
Arguments = -m64 -arch=sm_12 "c:\<path>\CUDAFYSOURCETEMP.cu" -o "c:\<path>\CUDAFYSOURCETEMP.ptx" --ptx
Some information from this article explains that the CUDA Toolkit must be installed. Fair enough.
Ensure that the C++ compiler (cl.exe) is on the search path. This set-up of NVCC is actually the toughest stage of the whole process, so please persevere. Read any errors you get carefully - most likely they are related to not finding cl.exe or not having either 32-bit or 64-bit CUDA Toolkit.
That article discusses version 4 of the toolkit, but version 5 is available now and supported since CUDAfy v1.1.
Download from https://developer.nvidia.com/cuda-downloads
Note that the 64-bit version of the CUDA Toolkit 5.0 is a 942 MB download. If you install everything you'll need an additional 2815 MB. The toolkit alone requires 928 MB.
EDIT After installing the CUDA Toolkit 5.0, the program failed with a CudafyCompileException at the same source line:
Compilation error: nvcc : fatal error : Cannot find compiler 'cl.exe' in PATH
Searching my system drive:
C:\>dir /s cl.exe
This shows many different versions of the compiler/linker, both from VS 10.0 and 11.0. Apparently only cl.exe versions 9 and 10 are supported, so I opted for the VS10.0 amd64 version, I included the following in my PATH environment variable:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64
Your path may be different, depending upon your CPU. I recommend running the search to see your options.
Note that you will have to restart VS after changing the PATH environment variable if you already have it open.
After taking these steps, my basic program ran successfully.
This may also happen if you had at some point installed CUDA Toolkit v7.5, but realized that the most recent version of CUDAfy supports CUDA 7.0.
On uninstalling CUDA 7.5 from the control panel, some files/folders may still remain. You should delete these manually. You may use CUDAfyViewer to see which version of CUDA Toolkit is being accessed.
we are currently having serious problems running a pure c# application on mono 2.8.1 on debian 5.
We are using .net webservices as well as async sockets and probably found a race condition in the mono threadpool.
I would be thankful for every idea.
if someone has informations if mono 2.8.1 has known problems on debian 4/5 that might have something to do with this, please answer too:)
Assertion at mono-wsq.c:73, condition `mono_wsq_count (wsq) == 0' not met
Stacktrace:
Native stacktrace:
mono [0x48f582]
/lib/libpthread.so.0 [0x2abe8f8d2a80]
/lib/libc.so.6(gsignal+0x35) [0x2abe8fb12ed5]
/lib/libc.so.6(abort+0x183) [0x2abe8fb143f3]
mono [0x5cd042]
mono [0x5cd21a]
mono [0x5f271a]
mono [0x5924ca]
mono [0x58c24b]
mono [0x5bd83b]
mono [0x5e9ed6]
/lib/libpthread.so.0 [0x2abe8f8cafc7]
/lib/libc.so.6(clone+0x6d) [0x2abe8fbb064d]
Debug info from gdb:
=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
I fixed this in mono 2.8.2. Someone has reported that they still see it in 2.8.2 (we don't see it in our servers any more) and we are working to debug it.