Exception 可以在xamarin.forms+;F#?
我正在测试将Xamarin.Forms+F#用于辅助项目的可行性。当事情进展顺利时,一切都很好。但当代码出现问题时,我总是会遇到以下异常:Exception 可以在xamarin.forms+;F#?,exception,f#,xamarin,xamarin.forms,Exception,F#,Xamarin,Xamarin.forms,我正在测试将Xamarin.Forms+F#用于辅助项目的可行性。当事情进展顺利时,一切都很好。但当代码出现问题时,我总是会遇到以下异常: System.TypeInitializationException: An exception was thrown by the type initializer for <StartupCode$BestSellerPOS>.$Forms System.TypeInitializationException: An exception w
System.TypeInitializationException: An exception was thrown by the type initializer for <StartupCode$BestSellerPOS>.$Forms
System.TypeInitializationException: An exception was thrown by the type initializer for <StartupCode$BestSellerPOS>.$Forms ---> System.Exception: Missing or incorrect header for method .cctor
--- End of inner exception stack trace ---
at BestSellerPOS.Forms.get_mainForm () [0x00000] in <filename unknown>:0
at BestSellerPOS.App.get_FormDocs () [0x00000] in /Users/mamcx/Proyectos/BestSeller/BestSellerNET/Core/App.fs:7
at BestSellerPOS.AppDelegate.FinishedLaunching (UIKit.UIApplication app, Foundation.NSDictionary options) [0x0001c] in /Users/mamcx/Proyectos/BestSeller/BestSellerNET/iOS/AppDelegate.fs:16
at at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) [0x00005] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:62
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:46
at BestSellerPOS.Main.main (System.String[] args) [0x00000] in /Users/mamcx/Proyectos/BestSeller/BestSellerNET/iOS/AppDelegate.fs:23
System.TypeInitializationException:类型初始值设定项为.$Forms引发异常
不管错误为什么发生。所以,我需要从一开始就一步一步地了解每一行,看看发生了什么
这一次是完全异常(这已经发生了好几次,但我没有记录以前的错误,以查看是否是相同的精确回溯…请记住,这是相同的初始异常):
System.TypeInitializationException:类型初始值设定项为.$Forms-->System.exception:方法.cctor的标头缺失或不正确
---内部异常堆栈跟踪的结束---
在BestSellerPOS.Forms.get_mainForm()[0x00000]中:0
在/Users/mamcx/Proyectos/BestSeller/BestSellerNET/Core/App.fs:7中的BestSellerPOS.App.get_FormDocs()[0x00000]
在BestSalePase.AppReaveT.FiSimHeDebug(UIKIT.UIAPP应用程序,基础.NS字典选项)[0x000 01C]中/用户/ MAMCX/PROYCOTES/BestSale/BestSaleNET/iOS/AppDealt.FS:16
在(包装器管理为本机)UIKit.UIApplication:UIApplicationMain(int,string[],intptr,intptr)
在/Developer/MonoTouch/Source/MonoTouch/src/UIKit/UIApplication.Main中的UIKit.UIApplication.Main(System.String[]args,IntPtr主体,IntPtr委托)[0x00005]
在/Developer/MonoTouch/Source/MonoTouch/src/UIKit/UIApplication.cs:46中的UIKit.UIApplication.Main(System.String[]参数,System.String principalClassName,System.String delegateClassName)[0x00038]处
在/Users/mamcx/Proyectos/BestSeller/BestSellerNET/iOS/AppDelegate.fs:23中的BestSellerPOS.Main.Main(System.String[]args)[0x00000]处
我有约塞米蒂岛上所有东西的最新版本
p.D.:
我已经用最少的编码设置了一个空白解决方案,并强制启动一个除以零的错误。仍然无法获取该错误,而是一条通用消息
然后创建另一个黑色解决方案,这次没有共享项目,与xamarin ios模板提供的完全相同。这给了一个很好的例外,并指出了确切的位置 在F#中,当模块
初始化期间发生异常时,您将获得类型初始化异常
。这表明,在某个地方,让
绑定值爆炸。如果看不到代码,就很难准确说出它发生在哪里
但解决方案通常意味着将初始化期间执行的let
绑定值更改为函数,方法是在几个关键位置添加say()
,并将执行延迟到一个更有意义的时间,以便您可以根据需要处理异常。或者,您可以将您的值声明为lazy
,并使用它延迟执行
通常,我建议不要在
模块
初始化期间出现异常,因为模块初始化发生的时刻不容易预测。您好,是的,我发现了。我删除了这类函数的所有痕迹,仍然得到了错误。然而,问题是:存在一种方法来知道到底是什么导致了异常,因为在黑暗中拍摄是不好的。这是F#,Mono,Xamarin的问题吗?