【问题标题】:Mono can't load Facebook library (from NuGet)Mono 无法加载 Facebook 库(来自 NuGet)
【发布时间】:2015-11-23 19:11:31
【问题描述】:

我正在尝试使用单声道在 ubuntu 服务器上启动 C# 控制台应用程序。这个控制台应用程序需要访问 facebook,所以我在 Visual Studio 2015 中添加了用于 facebook 的 NuGet 包。我的 dot net 目标版本是 4.5 Full Profile。

我一实例化 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 应该与单声道兼容。

【问题讨论】:

    标签: c# facebook mono console facebook-c#-sdk


    【解决方案1】:

    您使用的是旧的 C# 编译器(Mono JIT 编译器版本 2.10.8.1)。也许更新的版本可能会解决您的问题:)

    Mono.Cecil, Missing compiler required member 'System.Runtime.CompilerServices.ExtensionAttribute..ctor'

    【讨论】:

    • 将单声道更新到较新的版本完成了这项工作 (> V3.x)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-03
    相关资源
    最近更新 更多