Mono 无法加载 Facebook 库(来自 NuGet)
Mono can't load Facebook library (from NuGet)
我正在尝试使用单声道在 ubuntu 服务器上启动 C# 控制台应用程序。此控制台应用程序需要访问 facebook,因此我在 visual studio 2015 年为 facebook 添加了 NuGet 包。我的 dot net 目标版本是 4.5 Full Profile。
我一实例化 FacebookClient class,我就得到这个异常:
Missing method .ctor in assembly /home/danbru1211/Debug/Facebook.dll, type System.Runtime.CompilerServices.ExtensionAttribute
Can't find custom attr constructor image: /home/danbru1211/Debug/Facebook.dll mtoken: 0x0a000014
Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: An exception was thrown by the type initializer for Facebook.FacebookClient ---> System.TypeLoadException: Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'Facebook'.
--- End of inner exception stack trace ---
at Hashtag.Crawler.Plugins.Facebook.FacebookCrawler..ctor () [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
at System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) [0x00000] in <filename unknown>:0
at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x00000] in <filename unknown>:0
at System.Activator.CreateInstance (System.Type type) [0x00000] in <filename unknown>:0
at Hashtag.Crawler.CrawlerProcess.Run () [0x00000] in <filename unknown>:0
at Hashtag.Crawler.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: An exception was thrown by the type initializer for Facebook.FacebookClient ---> System.TypeLoadException: Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'Facebook'.
--- End of inner exception stack trace ---
at Hashtag.Crawler.Plugins.Facebook.FacebookCrawler..ctor () [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
at System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) [0x00000] in <filename unknown>:0
at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x00000] in <filename unknown>:0
at System.Activator.CreateInstance (System.Type type) [0x00000] in <filename unknown>:0
at Hashtag.Crawler.CrawlerProcess.Run () [0x00000] in <filename unknown>:0
at Hashtag.Crawler.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
danbru1211@www:~/Debug$ mono --version
Mono JIT compiler version 2.10.8.1 (Debian 2.10.8.1-8+deb7u1)
Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: Included Boehm (with typed GC and Parallel Mark)
danbru1211@www:~/Debug$
如何解决?我确定 facebook.dll 应该与单声道兼容。
您似乎在使用旧的 C# 编译器(Mono JIT 编译器版本 2.10.8.1)。也许更新的版本可能会解决您的问题:)
Mono.Cecil, Missing compiler required member 'System.Runtime.CompilerServices.ExtensionAttribute..ctor'
我正在尝试使用单声道在 ubuntu 服务器上启动 C# 控制台应用程序。此控制台应用程序需要访问 facebook,因此我在 visual studio 2015 年为 facebook 添加了 NuGet 包。我的 dot net 目标版本是 4.5 Full Profile。
我一实例化 FacebookClient class,我就得到这个异常:
Missing method .ctor in assembly /home/danbru1211/Debug/Facebook.dll, type System.Runtime.CompilerServices.ExtensionAttribute
Can't find custom attr constructor image: /home/danbru1211/Debug/Facebook.dll mtoken: 0x0a000014
Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: An exception was thrown by the type initializer for Facebook.FacebookClient ---> System.TypeLoadException: Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'Facebook'.
--- End of inner exception stack trace ---
at Hashtag.Crawler.Plugins.Facebook.FacebookCrawler..ctor () [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
at System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) [0x00000] in <filename unknown>:0
at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x00000] in <filename unknown>:0
at System.Activator.CreateInstance (System.Type type) [0x00000] in <filename unknown>:0
at Hashtag.Crawler.CrawlerProcess.Run () [0x00000] in <filename unknown>:0
at Hashtag.Crawler.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: An exception was thrown by the type initializer for Facebook.FacebookClient ---> System.TypeLoadException: Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'Facebook'.
--- End of inner exception stack trace ---
at Hashtag.Crawler.Plugins.Facebook.FacebookCrawler..ctor () [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
at System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) [0x00000] in <filename unknown>:0
at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x00000] in <filename unknown>:0
at System.Activator.CreateInstance (System.Type type) [0x00000] in <filename unknown>:0
at Hashtag.Crawler.CrawlerProcess.Run () [0x00000] in <filename unknown>:0
at Hashtag.Crawler.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
danbru1211@www:~/Debug$ mono --version
Mono JIT compiler version 2.10.8.1 (Debian 2.10.8.1-8+deb7u1)
Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: Included Boehm (with typed GC and Parallel Mark)
danbru1211@www:~/Debug$
如何解决?我确定 facebook.dll 应该与单声道兼容。
您似乎在使用旧的 C# 编译器(Mono JIT 编译器版本 2.10.8.1)。也许更新的版本可能会解决您的问题:)
Mono.Cecil, Missing compiler required member 'System.Runtime.CompilerServices.ExtensionAttribute..ctor'