I've a Unity 5.3.1 iOS project that also uses the new multiplayer network, UNet. Scary stuff. When I build and run the project, I get the following error in Xcode:
Use of undeclared identifier `IL2CPP_RAISE_MANAGED_EXCEPTION`
The project runs fine in the Unity Editor. It's in a huge Bulk_Generics_10.cpp
script that deals with System.Comparison1<UnityEngine.Networking.NetworkSystem.PeerInfoPlayer
Here is the block of code that the error is found.
// System.Void
System.Linq.Enumerable/<CreateDistinctIterator>c__Iterator3`1<System.Object>::Reset()
extern TypeInfo*
NotSupportedException_t1382227673_0_il2cpp_TypeInfo_var; extern const
uint32_t
U3CCreateDistinctIteratorU3Ec__Iterator3_1_Reset_m_1278777949_0_MetadataUsageId;
extern "C" void
U3CCreateDistinctIteratorU3Ec__Iterator3_1_Reset_m_1278777949_0_gshared
(U3CCreateDistinctIteratorU3Ec__Iterator3_1_t1454147488_0 * __this,
const MethodInfo* method) { static bool s_Il2CppMethodIntialized; if
(!s_Il2CppMethodIntialized) { il2cpp_codegen_initialize_method
(U3CCreateDistinctIteratorU3Ec__Iterator3_1_Reset_m_1278777949_0_MetadataUsageId);
s_Il2CppMethodIntialized = true; } {
NotSupportedException_t1382227673_0 * L_0 =
(NotSupportedException_t1382227673_0 *)il2cpp_codegen_object_new
(NotSupportedException_t1382227673_0_il2cpp_TypeInfo_var);
NotSupportedException__ctor_m149930845_0(L_0, /*hidden
argument*/NULL); IL2CPP_RAISE_MANAGED_EXCEPTION(L_0); } }
Looks like Unity did not hand it off cleanly to Xcode. I'm wondering if there's some adjustment I need to make in Unity.
How can I correct this error?
This is a new problem with the build packages for different platforms being optional in the installer. If you install a platform and then upgrade your version of Unity but don't install that platform on the second install the old version of the platform will remain and cause problems.
My solution was to totally wipe out my Unity3d folder and reinstall with the correct platforms.
related thread: http://forum.unity3d.com/threads/il2cpp_raise_managed_exception-undeclared-identifier.382377/
As far as I remember System.Linq is supported by iOS.
Here is a thread also exists regarding this,
Most of Linq extension methods from Linq for Collections are not working with IEnumerables on iOS since they require AOT runtime compiler which is not supported.
However there is a Linq for iOS library on Asset Store that is similar to Linq but doesn't require a runtime compiler. So you can use it on iOS.
Source: http://forum.unity3d.com/threads/linq-on-ios.84147/
Related
I'm attempting to bring FMOD Core 2.02 into my Monogame 3.8 project using the dll's and C# wrappers (which appear to be auto-generated from the C++). I've set the .dll's to Copy to the output directory on build, and I'm accessing them like so:
[DllImport("kernel32.dll")]
public static extern IntPtr LoadLibrary(string path);
public void OnSystemLoad()
{
if (Environment.Is64BitProcess)
LoadLibrary(System.IO.Path.GetFullPath("FMOD\\x64\\fmod.dll"));
else
LoadLibrary(System.IO.Path.GetFullPath("FMOD\\x86\\fmod.dll"));
}
Everything's working just fine up to this point, the .dll's accessible from the pointer. However, once I go to create a new FMOD System using:
FMOD.Factory.System_Create(out FMODSystem);
I get this error in a popup window:
The procedure entry point ?setFadePointRamp#ChannelControl#FMOD##QEAA?AW4FMOD_RESULT##_KM#Z could not be located in the dynamic link library ...fmod.dll.
Followed by this error on the auto generated C# code itself:
System.DllNotFoundException: 'Unable to load DLL 'fmod' or one of its dependencies: The specified module could not be found. (0x8007007E)'
I'm confidant that the .dll is being found just fine, because if I intentionally mess with the Path to something incorrect then the first error never appears.
Has anybody successfully integrated FMOD with Monogame in 2021? If so, please advise, would love any guidance on getting this up and running... don't want to be stuck with Monogame's MediaPlayer!
Other resources I've found on this subject (none of which have worked for me so far):
https://mysteriousspace.com/2015/05/31/fmod-in-c-its-a-pain-to-set-up-heres-how-i-did-it/
https://github.com/Martenfur/ChaiFoxes.FMODAudio
Managed to solve this by reverting to an older release of FMOD, version 2.01.
I'll write a ticket to let the FMOD team know, but my hopes aren't high, since they don't seem to care much for C# beyond Unity.
I recently use Roslyn to compile and execute code at the runtime of a game application. Thank to some useful ressource such as this web site and Vendettamit answer, I manage to code a program on a C# Console Net Core project on window 10 which execute this code located in a txt file at the root of the application.
using System;
namespace Test15
{
public class Program
{
public static int Main()
{
System.Console.WriteLine("Hello World from external Dll !");
System.Console.WriteLine("And it work !");
return 10;
}
}
}
I'm not going to share code because it is really similar to Vendettamit answer, and this program work well on a C# Console Net Core project on window 10.
So next step, I try to make this program work with the C# Monogame Framework on a Android project which use Xamarin.
First problem : when trying to add the nugget package "Microsoft.CodeAnalysis" which seem necessary for Roslyn, I have the 2 following error :
Unable to resolve reference 'Humanizer', referenced by `Microsoft.CodeAnalysis.CSharp.Workspaces`.
Add NuGet package or assembly reference for 'Humanizer', or remove the reference to
'Microsoft.CodeAnalysis.CSharp.Workspaces'. Game2
Unable to resolve reference 'SQLitePCLRaw.core', referenced by `Microsoft.CodeAnalysis.Workspaces`.
Add NuGet package or assembly reference for 'SQLitePCLRaw.core', or remove the reference to
'Microsoft.CodeAnalysis.Workspaces'. Game2
(Translated from French)
When replacing the "Microsoft.CodeAnalysis" nugget package by "microsoft.CodeAnalysis.CSharp", both errors disappears.
However at the runtime, adding the MetadataReference don't work.
For instance in the Console project I use :
MetadataReference.CreateFromFile(typeof(object).GetTypeInfo().Assembly.Location);
To add a MetadataReference to mscorlib.dll, but on an Android project, it crash because typeof(object).GetTypeInfo().Assembly.Location return "mscorlib.dll" instead of somethings like "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.9\System.Private.CoreLib.dll", because we are on Android I guess. (same with other MetadataReference )
So when calling the method CSharpCompilation.Create(), the "reference" argument is an array of null MetadataReference and it crash.
Based on what I read, I think (but I'm not sure) that Roslyn can't work on android because of the missing location of System.Object.
So can someone can confirm (or invalidate) if there is a way to work with Roslyn on Android ?
(Bonus point if you know some other way to compile/execute or "interpret" C# code on any device)
Thank for reading and stay safe.
I try to build my project using Unity 2017.4.34f1, because Google now need both 32 & 64 bit, so i choose IL2CPP.
For Android NDK, I use r13b
However, build failed and I get below error (summary) :
Exception: /Applications/Unity/Hub/Editor/2017.4.34f1/Unity.app/Contents/il2cpp/build/il2cpp.exe did not run properly!
This failure occurs because the code in the project has extern methods in C#. Methods marked as extern with a the [Dllimport("__Internal")] attribute must be present in a native library that is linked with the Unity player when building with the IL2CPP scripting backend.
For example, this in this project one function which causes this issue is named: activateApp
You have two options:
Build a native library with all of the methods marked as extern with the [Dllimport("__Internal")] attribute for the target platform and architecture of the player. See this documentation for details about native plugins: https://docs.unity3d.com/Manual/NativePlugins.html
Remove the C# code which defines this extern method. You can do that with platform dependent compilation: https://docs.unity3d.com/Manual/PlatformDependentCompilation.html
In this case specifically, it looks like the error comes from the Facebook SDK. See if there is a newer Facebook SDK available - I believe this may have been corrected.
We are using Moonsharp (Lua Interpreter) con our Unity new Game (Unity v.5.4.1)
On Android works well. And... thats de key...
However in iOS in the DEV version there are no problems, but in the RELEASE version it does not run correctly.
We have the following error:
"ScriptRunTimeException: Can not convert clr type System.MonoType"
What kind of differences between ios develop or release version?
I repeat. We only get that error once it is released to the iTunes Store, not in Dev mode.
Any solution?
This is likely a bug.
Change UserData.RegisterAssembly()
to
UserData.RegisterAssembly(typeof(Program).Assembly); or something similar.
Just use the RegisterAssembly overload function with the Assembly parameter. This will likely fix your problem.
I'm trying to get a third party SDK working with Unity. Here's a download of the files in said SDK: https://dl.dropboxusercontent.com/u/11217331/VSDK.zip
The "_DotNET.dll" is a .NET wrapper for the unmanaged code in the CPP dll. For some reason, Unity doesn't load the .NET dll whatever I try:
I put both DLLs in the Assets/Plugins folder
I am using Unity Pro 4.5.0f6, on Windows 8.1
The SDK "_DotNET.dll" is x86 .NET 2.0, and seems to be completely compatible with Unity's version of Mono
I tried putting both DLLs in the Program Files/Unity/Editor folder, still doesn't load them
I do not have the source to these DLLs so I can't make any changes to them, but everything points at Unity being weird here
There are no errors in the editor log or anywhere that give me a hint to why Unity just completely ignores these DLLs
If you can get this C# script working in Unity by loading these DLLs, please tell me your secrets:
using UnityEngine;
using System.Collections;
using ViconDataStreamSDK;
public class test : MonoBehaviour {
ViconDataStreamSDK.DotNET.Client e;
void Start () {
bool isConnected = e.IsConnected().Connected;
Debug.Log("Is it connected?: " + isConnected.ToString());
}
void Update () {
}
}
Ok, it seems I can load it by going back one Unity version, to 4.3.4f1. No idea why, culprit must be somewhere in the Unity 4.5 patch notes (http://unity3d.com/unity/whats-new/unity-4.5).
You will probably need to put the source code for the C# plugin into the unity and see what actual errors it gives you.