I'm trying to compile a C# project using Mono and am getting the following exception during compilation using xbuild:
Error: Fody: An unhandled exception occurred:
Exception:
The requested feature is not implemented.
StackTrace:
at Mono.Cecil.Mdb.MdbReaderProvider.GetSymbolReader (Mono.Cecil.ModuleDefinition,System.IO.Stream) <0x00017>
at Mono.Cecil.ModuleReader.ReadSymbols (Mono.Cecil.ModuleDefinition,Mono.Cecil.ReaderParameters) <0x000cb>
at Mono.Cecil.ModuleReader.CreateModuleFrom (Mono.Cecil.PE.Image,Mono.Cecil.ReaderParameters) <0x000e7>
at Mono.Cecil.ModuleDefinition.ReadModule (System.IO.Stream,Mono.Cecil.ReaderParameters) <0x00063>
at ModuleWeaver.GetTemplateModuleDefinition () <0x00133>
at ModuleWeaver.ImportAssemblyLoader (bool) <0x00027>
at ModuleWeaver.Execute () <0x00113>
at (wrapper dynamic-method) object.lambda_method (System.Runtime.CompilerServices.Closure,object) <0x0004c>
at InnerWeaver.ExecuteWeavers () <0x002cb>
at InnerWeaver.Execute () <0x00123>
Source:
Mono.Cecil.Mdb
TargetSite:
Mono.Cecil.Cil.ISymbolReader GetSymbolReader(Mono.Cecil.ModuleDefinition, System.IO.Stream)
(Hybrasyl)
The project is using Fody, which appears to be what's throwing the error. From what I can tell Fody should support Mono. I'm using the latest version of Mono (v4.0.1.0), Fody (v1.28.3.0), and Costura Fody (v1.3.3.0).
Q1: What feature is the compiler claiming is not implemented? I'm having trouble understanding the error message.
Q2: Is this expected behavior? I'm having trouble finding references to Fody's status with respect to Mono support and am not sure if this is truly missing support or whether I'm doing something incorrectly. I'm new to the .NET + Mono world so let me know if I need to clarify further.
Thanks!
Related
The problem has already been discussed earlier, but I got it after the update in September. Environment: the latest vs studio for mac, all the frameworks are updated, I also tried to switch to the preview channel, the error is the same. Actually the problem: after the update, the error of creating a native object began to appear.
From my renderer to - at Foundation.NSObject.InitializeObject (System.Boolean alloced) [0x0002e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.8.2.2/src/Xamarin.iOS/Foundation/NSObject2.cs:196 at Foundation.NSObject..ctor (Foundation.NSObjectFlag x) [0x0000d] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.8.2.2/src/Xamarin.iOS/Foundation/NSObject2.cs:131 at UIKit.UIResponder..ctor (Foundation.NSObjectFlag t) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.8.2.2/src/Xamarin.iOS/UIResponder.g.cs:69 at UIKit.UIView..ctor (Foundation.NSObjectFlag t) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.8.2.2/src/Xamarin.iOS/UIView.g.cs:83
Error message: Could not create an native instance of the type 'xxx': the native class hasn't been loaded. It is possible to ignore this condition by setting ObjCRuntime.Class.ThrowOnInitFailure to false.
if set ObjCRuntime.Class.ThrowOnInitFailure = false; - native constructor returns null;
lib in Binding project is fat, all architectures are supported. i have no its code, only headers. ApiDefinition and Structs generated by sharpie, and works well.
mtouch options: --optimize=-remove-dynamic-registrar
please give some ways to solve, project is on fire..
If exist way to rollback all mono frameworks i can try, but its not good way.
I am using .NET Core 2.1 to load an assembly calling Assembly.ReflectionOnlyLoadFrom(...) but am getting a System.PlatformNotSupportedException exception. Microsoft documentation seems to indicate that it should work. Has this been implemented? If not, are there any alternatives to get exported types from a .NET 4.7.2 assembly using .NET Core?
Assembly.ReflectionOnlyLoadFrom(fileName)
'Assembly.ReflectionOnlyLoadFrom(fileName)' threw an exception of type 'System.PlatformNotSupportedException'
Data: {System.Collections.ListDictionaryInternal}
HResult: -2146233031
HelpLink: null
InnerException: null
Message: "ReflectionOnly loading is not supported on this platform."
Source: "System.Private.CoreLib"
StackTrace: " at System.Reflection.Assembly.ReflectionOnlyLoadFrom(String assemblyFile)"
TargetSite: {System.Reflection.Assembly ReflectionOnlyLoadFrom(System.String)}
As written above, reflection is not supported yet on .net core.
You can use the experimental use TypeLoader from the LAB's repo.
If you want to use the experimental NuGets, you need to follow instructions on:
https://github.com/dotnet/corefxlab (basically adding the NuGet repo - https://dotnet.myget.org/F/dotnet-corefxlab/) and fetch the System.Reflection.TypeLoader.
Don't expect much support though :)
I am using Xamarin.Auth to authenticate to my identity provider with implicit flow on Android. I can't get the native ui (chrome custom tabs) to work with Xamarin.Auth as I get the following error:
UNHANDLED EXCEPTION: 06-30 11:40:48.903 I/MonoDroid( 7670):
System.MissingMethodException: Method
'Android.Support.CustomTabs.CustomTabsIntent.LaunchUrl' not found.
06-30 11:40:48.903 I/MonoDroid( 7670): at
Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (System.IntPtr
jnienv, System.IntPtr native__this, System.IntPtr
native_savedInstanceState) [0x0000f] in
<93e2413825534efca8b597098003b511>:0 06-30 11:40:48.903 I/MonoDroid(
7670): at (wrapper dynamic-method)
System.Object:ce197f13-7701-4b2e-840f-19029a77ef6c
(intptr,intptr,intptr) 06-30 11:40:48.913 W/art ( 7670): JNI
RegisterNativeMethods: attempt to register 0 native methods for
android.runtime.JavaProxyThrowable 06-30 11:40:48.918 D/HockeyApp(
7670): Writing unhandled exception to:
/data/user/0/com.mycompany.myapp/files/9a7dae18-3c5a-4e97-b7cb-4a3f1581c690.stacktrace
My authenticator is set up like this:
var authenticator = new OAuth2Authenticator(
AuthSettings.ClientId,
AuthSettings.Scope,
new Uri(AuthSettings.AuthorizeUrl),
new Uri(AuthSettings.RedirectUrl),
null,
true);
I am not using linking either.
Any ideas?
After a quick google search I came accross an issue thread on a github page for the 'SharePlugin' for Xamarin, fortunately James Montemagno is in their helping out. The issue listed is similar to yours so for reference purposes it can be found Here.
It appears to have been a fairly common issue with this method 'Android.Support.CustomTabs.CustomTabsIntent::LaunchUrl'. In that thread they obviously mention that:
Release Mode => Linker option => None , Every thing works.
So that's worth double checking, to make sure that's what you're doing. (I realise you've mentioned you've had a look at the linked assemblies, but always worth a double check).
There is also some conversation on the GitHub repository for Xamarin.Auth iteself, a particular issue found Here talks about the versions of both Xamarin Auth and Xamarin Forms, needing to match in a certain way, I would suggest updating xamarin.forms to it's latest version, and trying again, perhaps even downgrading Xamarin.Auth.
It worked with 1.5.0-alpha-03. Tried with 1.5.0-alpha-09 but it
failed.
First post. Let me know if I break any rules!
I would like to experiment with Pure Data and Unity 5. It seems uPD would be the best fit. I have followed the instructions on the github page and loaded the first sample scene. The unity console reports errors with the dll:
Failed to load 'Assets/Magicolo/AudioTools/PureData/Plugins/libpdcsharp.dll', expected 64 bit architecture (IMAGE_FILE_MACHINE_AMD64), but was IMAGE_FILE_MACHINE_I386. You must recompile your plugin for 64 bit architecture.
So I cloned the main libpd repo and used the included batch file to build an x64 dll. I replaced the libpdcsharp.dll in the unity project and the console now reports:
DllNotFoundException: Assets/Magicolo/AudioTools/PureData/Plugins/libpdcsharp.dll
LibPDBinding.LibPD.ProcessArgs[Int32] (System.Int32[] args, System.String& debug) (at Assets/Magicolo/AudioTools/PureData/LibPD/LibPDNativeMessaging.cs:402)
LibPDBinding.LibPD.SendMessage[Int32] (System.String receiver, System.String message, System.Int32[] args) (at Assets/Magicolo/AudioTools/PureData/LibPD/LibPDNativeMessaging.cs:354)
(wrapper synchronized) LibPDBinding.LibPD:SendMessage (string,string,int[])
LibPDBinding.LibPD.ComputeAudio (Boolean state) (at Assets/Magicolo/AudioTools/PureData/LibPD/LibPDNativeMethods.cs:238)
(wrapper synchronized) LibPDBinding.LibPD:ComputeAudio (bool)
LibPDBinding.LibPD.Release () (at Assets/Magicolo/AudioTools/PureData/LibPD/LibPDNativeMethods.cs:207)
(wrapper synchronized) LibPDBinding.LibPD:Release ()
LibPDBinding.LibPD.ReInit () (at Assets/Magicolo/AudioTools/PureData/LibPD/LibPDNativeMethods.cs:79)
(wrapper synchronized) LibPDBinding.LibPD:ReInit ()
LibPDBinding.LibPD..cctor () (at Assets/Magicolo/AudioTools/PureData/LibPD/LibPDNativeMethods.cs:65)
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for LibPDBinding.LibPD
Magicolo.AudioTools.PureDataBridge.SetAudioSettings () (at Assets/Magicolo/AudioTools/PureData/PureDataBridge.cs:46)
Magicolo.AudioTools.PureDataBridge.StartLibPD () (at Assets/Magicolo/AudioTools/PureData/PureDataBridge.cs:25)
Magicolo.AudioTools.PureDataBridge.Start () (at Assets/Magicolo/AudioTools/PureData/PureDataBridge.cs:50)
PureData.StartAll () (at Assets/Magicolo/AudioTools/PureData/PureData.cs:141)
PureData.Initialize () (at Assets/Magicolo/AudioTools/PureData/PureData.cs:58)
PureData.Awake () (at Assets/Magicolo/AudioTools/PureData/PureData.cs:173)
I have also tried copying the libPDBinding.dll file from the main libpd repo to the unity project no avail. I lack the understanding to know where to go next so any help at all would be appreciated!
Further Progress
It was suggested to try NuGet to obtain the binding dll. On this - I get an error about a framework mismatch between my unity project/visual studio solution and the nuget package libPDBinding version 0.10.0. This is to do with unitys profiles as described in an article titled: "Using NuGet in Visual Studio Tools for Unity". I cant post the link here because I am too new.
However, I think I am sucessful in compiling my own libPDBinding.dll. Apologies for dragging this out, just making sure I am doing this right:
After using libPD\mingw64_build_csharp.bat to compile a x64 version of libpdcsharp.dll, I reference this and libpd\libs\mingw64\libwinthread-1.dll in the VS solution and get the resulting LibPDBinding.dll which was built with .NET 3.5. As mentioned libpdcsharp.dll was compiled using the batch/make file, so am I correct to assume this file has been built with the correct settings?
I proceed to copy these 3 dll's the unity assets folder
For reference it's a blank unity project with uPD as the only package, loaded to a uPD example scene.
I still get some errors at run time and some visual studio warnings as follows.
Unity run time error:
EntryPointNotFoundException: libpd_safe_init
LibPDBinding.LibPD.ReInit () (at Assets/Magicolo/AudioTools/PureData/LibPD/LibPDNativeMethods.cs:81)
(wrapper synchronized) LibPDBinding.LibPD:ReInit ()
LibPDBinding.LibPD..cctor () (at Assets/Magicolo/AudioTools/PureData/LibPD/LibPDNativeMethods.cs:65)
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for LibPDBinding.LibPD
Magicolo.AudioTools.PureDataBridge.SetAudioSettings () (at Assets/Magicolo/AudioTools/PureData/PureDataBridge.cs:46)
Magicolo.AudioTools.PureDataBridge.StartLibPD () (at Assets/Magicolo/AudioTools/PureData/PureDataBridge.cs:25)
Magicolo.AudioTools.PureDataBridge.Start () (at Assets/Magicolo/AudioTools/PureData/PureDataBridge.cs:50)
PureData.StartAll () (at Assets/Magicolo/AudioTools/PureData/PureData.cs:141)
PureData.Initialize () (at Assets/Magicolo/AudioTools/PureData/PureData.cs:58)
PureData.Awake () (at Assets/Magicolo/AudioTools/PureData/PureData.cs:173)
Visual studio warnings x 50 or so:
Warning CS0436 The type 'LibPD' in 'D:\unity projects\libpdinunity\Assets\Magicolo\AudioTools\PureData\LibPD\LibPdNativeUnity.cs' conflicts with the imported type 'LibPD' in 'LibPDBinding, Version=0.3.0.177, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'D:\unity projects\libpdinunity\Assets\Magicolo\AudioTools\PureData\LibPD\LibPdNativeUnity.cs'. libpdinunity.CSharp D:\unity projects\libpdinunity\Assets\Magicolo\AudioTools\PureData\PureDataCommunicator.cs 87 Active
Thanks again for any help. Much appreciated.
Looking at your error, libpdcsharp is currently placed at <ProjectDirectory>/Assets/Magicolo/AudioTools/PureData/Plugins/
This DLL file should be placed at <ProjectDirectory>/Asset.
Also, make sure that libpdcsharp is compiled with .NET 2.0 or 3.5. This won't work if you compile it with .NET 4.0 and above.
I am the maintainer of C# binding for LibPD.
You also need to change the link to the correct libwinpthread-1.dll version (64 bit instead of 32). In your final project you need all 3 dlls:
LibPDBinding.dll (the managed wrapper)
libpdcsharp.dll (the native dll)
libwinpthread-1.dll (for enabling POSIX threads on Windows)
Also: Have you tried the version from NuGet? No need to compile your own version of the binding.
EDIT: Your warning are from a different source: You have two classes named LibPD, and the C# compiler does not know, which one to use.
I am not sure, if these types are in the same namespace.
If they are in the same namespace, then change your namespace.
If they are in different namespaces, add a line using LibPd = LibPDBinding.LibPD; if you want to use the version from NuGet, or using LibPd = <yournamespace>.LibPD; if you want to use your version.
It's working. The uPD github code has an error as far as I can tell. So hopefully it gets fixed. In the meantime I just started the process from scratch and this is what I did to get the uPD test scene working in unity 5:
Get uPD from github. Theres a unity package in there
Get libPD from github.
Follow the instructions on the libPD github page to compile a x64
vresion of libpdcsharp.dll
replace the existing libpdcsharp.dll inside your unity project with
the x64 version you compiled
locate libpd\libs\mingw64\libwinthread-1.dll in the libpd files and
place this in the your unity project - the same place as the other dll is fine. I
don't think it matters where you put the Dll's (at least it made no
difference in my tests)
Run the project and notice you get an error in unity EntryPointNotFoundException: libpd_safe_init
double click the error to open up the problem script.
Find the following line of code: [DllImport("libpdcsharp", EntryPoint="libpd_safe_init")]
Change it to [DllImport("libpdcsharp", EntryPoint="libpd_init")] That's the real entry point for the init function in libpdcsharp. I don't know what libpd_safe_init is.
Thanks to the contributors who helped me to troubleshoot and find the issue!
I'm brand new to Iron.io's IronWorker, and I'm attempting to interface with it via C#.NET. I have managed to get the sample on the site to work, which utilizes the System.Web.Script.Serialization library. However, I want to use Newtonsoft.Json library for serialization/deserialization. My .worker file (located in the \bin directory of a Visual Studio project) looks like this:
runtime 'mono'
exec 'Debug\hello.exe'
file 'Debug\Newtonsoft.Json.dll'
I'm fairly certain that Newtonsoft.Json is being loaded, because adding the 3rd line of file: 'Debug\Netwonsoft.Json.dll' fixed the error that said that Newtonsoft could not be found.
The error I'm receiving when attempting to run a task is the following (I removed any seemingly sensitive information):
{"code_id":"[CODE_ID]","code_name":"hello","created_at":"2014-11-
16T13:48:01Z","duration":2452,"end_time":"2014-11-16T13:48:06Z","id":"[ID]","msg":"Unhandled
Exception: System.TypeLoadException: Could not load type
'System.Runtime.CompilerServices.ExtensionAttribute' from assembly
'Newtonsoft.Json'.\n at HelloWorld.Main (System.String[] args) [0x00000] in <filename
unknown>:0 \n[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could
not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly
'Newtonsoft.Json'.\n","project_id":"[PROJECTID]","start_time":
"2014-11-16T13:48:04Z","timeout":3600,"updated_at":"2014-11-16T13:48:07Z","status"
:"error"}
In the course of tracking down the error: Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'Newtonsoft.Json', I ran across a SO thread that suggested there might be a .NET framework mismatch between v4.0 and v4.5. I'm using v4.5, and I tried changing it to v4.0 with no luck (so this may not be the issue).
Can someone please point me in the right direction as to how to properly utilize a dependency, such as Newtonsoft.Json (so at least the sample on Iron.io will work)?
P.S. I've been toying with IronSharp as an API to assist with interfacing with Iron.io products (once I get past this dependency issue). But, I'm open to suggestions if there's anything better I should be checking out.
SOLUTION
#Featalion's answer below really helped, becuase he pointed me to the stack command, which I placed in like so:
runtime 'mono'
stack 'mono-3.6'
exec 'Debug\hello.exe'
file 'Debug\Netwonsoft.Json.dll'
I believe it resolved the error at hand, because the higher mono framework seems to handle the latest version of Newtwonsoft.Json.dll. I'll post here if I find otherwise.
Make note that as of 11/17/2014, it seems the highest stack version supported by IronWorker is 3.6 (even though 3.10 is available, details found here). Check the highest stable release from Iron.io at this link.
This is, possibly, related to mono version on the IronWorker service. I found related question on StackOverflow. Try to change the stack in your .worker file to mono-3.6 or mono-3.0. See all possible runtime environments on Iron.io's dev site. mono runtime is default, and it is alias for mono-2.10.