单声道扬声器';t加载Facebook库(来自NuGet)

本文关键字:Facebook 加载 来自 NuGet 声道 扬声器 单声道 | 更新日期: 2023-09-27 18:23:56

我正试图使用mono在ubuntu服务器上启动一个C#控制台应用程序。这个控制台应用程序需要访问facebook,所以我在visual studio 2015中为facebook添加了NuGet包。我的dot-net目标版本是4.5完整配置文件。

一旦我实例化FacebookClient类,我就会得到这个异常:

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应该与mono兼容。

单声道扬声器';t加载Facebook库(来自NuGet)

看起来你使用的是一个旧的C#编译器(MonoJIT编译器版本2.10.8.1)。也许更新的版本可以解决你的问题:)

Mono.Cecil,缺少编译器必需的成员';System.Runtime.CompilerServices.ExtensionAttribute..ctor';