[Bug Report] Plugin does not start, only creating new project (with same code) in Xamarin helps

mac
bug

#1

When trying to run my Rhino plugin out of Xamarin it suddenly does not start any longer with the following Exception:

System.NotSupportedException The invoked member is not supported in a dynamic module.

stack trace:

at System.Reflection.Emit.AssemblyBuilder.get_Location () [0x00000] in /Users/curtis/Projects/McNeel/mac5/src4/rhino4/MacOS/Mono64Framework/mono-4.0.2/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs:337 
at Rhino.Runtime.AssemblyResolver.CurrentDomain_AssemblyResolve (System.Object sender, System.ResolveEventArgs args) [0x00272] in /Users/bozo/TeamCity/buildAgent/work/1390813b57292860/src4/DotNetSDK/rhinocommon/dotnet/resolver.cs:140 

Starting Rhinoceros continues to work. Only when starting my specific plugin from Xamarin it does not.

Frequency

The error seems unrelated to any code change as clean & rebuilding the project or checking out previous versions does not help.
I just had the following incident the second time. The first time it happened 2 days ago.

Workaround

creating a new project in Xamarin and copying/linking all existing code and resources.

What does not help is:

  1. Restarting Xamarin, Rhino, or the operating system
  2. Updating Xamarin
  3. Clean and rebuild the project

My system

Xamarin Studio Community Edition 6.1.5 (build 0)
Rhinoceros 5.3.1
Mac OSX 10.11.6


(Curtis Wensley) #4

Hi @jups23,

I have not seen this issue before. It is very odd that creating a new project and copying the existing code over fixes the problem, so it might have something to do with the intermediate files that are placed in your bin folder (which may not be cleaned up with a rebuild).

Would you be able to send a copy of a project that exhibits this behaviour to us? I may be able to track down the cause a bit quicker that way.

Also, what version of mono framework are you using? You can find out by opening Terminal.app and entering the following command mono --version

Cheers!
Curtis.


#5

Thank you very much for your quick answer! I deleted the entire obj/Debug and build/Debug folder without any effect.
I sent you a private message with my project.

My mono version is 4.6.2. See details below.

> mono --version
Mono JIT compiler version 4.6.2 (mono-4.6.0-branch/ac9e222 Wed Dec 14 17:02:09 EST 2016)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           normal
	SIGSEGV:       altstack
	Notification:  kqueue
	Architecture:  x86
	Disabled:      none
	Misc:          softdebug 
	LLVM:          yes(3.6.0svn-mono-master/8b1520c)
	GC:            sgen

(Curtis Wensley) #6

Hey @jups23,

Thanks for sending the project! I’m looking into the problem and can’t replicate it so far. Do you have a MechanismRemix.userprefs file that wasn’t included in the .zip? The particular error you’re running into is in a try/catch block so it shouldn’t be crashing. I’m thinking maybe it’s the exception settings you have set up for Xamarin Studio.

It is definitely also related to the QuickGraph library that you’re using - it uses reflection emit to create some helper delegates, etc. which would cause this issue, even though it should be ignored.

Also, when exactly does Rhino crash? Are you loading a particular 3dm that causes it?

Thanks!
Curtis.


#7

Today, I installed the latest updates. No difference :frowning:


#8

@curtisw Thanks for your investigation! I’ll research tomorrow.


#9

Yes, I have a .userprefs. I’ve just sent it to you along with a screencast demonstrating that the crash happens before the splash screen of Rhino appears. The application output stops with loading Newtonsoft.Json.dll:

Loaded assembly: /Applications/Rhinoceros.app/Contents/Resources/monostart.exe
Loaded assembly: /Applications/Rhinoceros.app/Contents/Resources/RhinoMac.dll
Loaded assembly: /Applications/Rhinoceros.app/Contents/Resources/Mindscape.Raygun4MacRhino.dll
Loaded assembly: /Applications/Rhinoceros.app/Contents/Resources/RhinoCommon.dll
Loaded assembly: /Applications/Rhinoceros.app/Contents/Resources/Eto.dll
Loaded assembly: /Applications/Rhinoceros.app/Contents/Frameworks/Mono64Rhino.framework/Versions/4.0.2/Resources/lib/mono/4.5/Facades/System.Runtime.dll
Loaded assembly: /Applications/Rhinoceros.app/Contents/Resources/Eto.Mac64.dll
Loaded assembly: /Applications/Rhinoceros.app/Contents/Frameworks/Mono64Rhino.framework/Versions/4.0.2/Resources/lib/mono/4.5/Facades/System.Collections.dll
Loaded assembly: /Applications/Rhinoceros.app/Contents/Frameworks/Mono64Rhino.framework/Versions/4.0.2/Resources/lib/mono/4.5/Facades/System.Threading.dll
Loaded assembly: /Applications/Rhinoceros.app/Contents/Resources/Rhino.UI.dll
Loaded assembly: /Applications/Rhinoceros.app/Contents/Resources/lib/mono/gac/System.Drawing/4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
Loaded assembly: /Applications/Rhinoceros.app/Contents/Frameworks/Mono64Rhino.framework/Versions/4.0.2/Resources/lib/mono/gac/System/4.0.0.0__b77a5c561934e089/System.dll
Loaded assembly: /Applications/Rhinoceros.app/Contents/Resources/MonoMac.dll
Loaded assembly: /Applications/Rhinoceros.app/Contents/Resources/MonoMac.dll
Loaded assembly: /Applications/Rhinoceros.app/Contents/Frameworks/Mono64Rhino.framework/Versions/4.0.2/Resources/lib/mono/gac/System.Core/4.0.0.0__b77a5c561934e089/System.Core.dll
Loaded assembly: ObjCImplementations
Loaded assembly: /Applications/Rhinoceros.app/Contents/Frameworks/Mono64Rhino.framework/Versions/4.0.2/Resources/lib/mono/gac/Mono.Security/4.0.0.0__0738eb9f132ed756/Mono.Security.dll
Loaded assembly: /Applications/Rhinoceros.app/Contents/Frameworks/Mono64Rhino.framework/Versions/4.0.2/Resources/lib/mono/gac/System.Web/4.0.0.0__b03f5f7f11d50a3a/System.Web.dll
Loaded assembly: /Applications/Rhinoceros.app/Contents/Frameworks/Mono64Rhino.framework/Versions/4.0.2/Resources/lib/mono/gac/System.Configuration/4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
Loaded assembly: /Applications/Rhinoceros.app/Contents/Frameworks/Mono64Rhino.framework/Versions/4.0.2/Resources/lib/mono/4.5/Facades/System.ObjectModel.dll
Loaded assembly: /Applications/Rhinoceros.app/Contents/Frameworks/Mono64Rhino.framework/Versions/4.0.2/Resources/lib/mono/4.5/Facades/System.Reflection.dll
Loaded assembly: /Applications/Rhinoceros.app/Contents/Frameworks/Mono64Rhino.framework/Versions/4.0.2/Resources/lib/mono/4.5/Facades/System.Reflection.Extensions.dll
Loaded assembly: /Applications/Rhinoceros.app/Contents/Frameworks/Mono64Rhino.framework/Versions/4.0.2/Resources/lib/mono/4.5/Facades/System.Linq.Expressions.dll
Loaded assembly: /Applications/Rhinoceros.app/Contents/Frameworks/Mono64Rhino.framework/Versions/4.0.2/Resources/lib/mono/4.5/Facades/System.ComponentModel.dll
Loaded assembly: /Applications/Rhinoceros.app/Contents/Frameworks/Mono64Rhino.framework/Versions/4.0.2/Resources/lib/mono/4.5/Facades/System.Globalization.dll
Loaded assembly: /Applications/Rhinoceros.app/Contents/Frameworks/Mono64Rhino.framework/Versions/4.0.2/Resources/lib/mono/4.5/Facades/System.Linq.dll
Loaded assembly: /pathToMyProject/bin/Debug/MyPluginName.rhp
Loaded assembly: /pathToMyProject/bin/Debug/MyPluginName.rhp
Loaded assembly: /pathToMyProject/bin/Debug/QuickGraph.dll
Loaded assembly: /pathToMyProject/bin/Debug/Newtonsoft.Json.dll

In the .userprefs Line 21 may look suspicious but removing it did not change anything for me:

<Catchpoint exceptionName="System.Exception" includeSubclasses="True" />

Also attached are my debugger settings.


#10

Thank you for your hint, it works again. Turns out I had one catchpoint on System.Exception that caused the trouble.


(Curtis Wensley) #11

Excellent! I’m glad you found the problem.

Happy coding!
Curtis.