简体   繁体   English

Mono无法加载Facebook库(来自NuGet)

[英]Mono can't load Facebook library (from NuGet)

I am trying to start a C# console application on a ubuntu server using mono. 我正在尝试使用mono在ubuntu服务器上启动C#控制台应用程序。 This console application needs access to facebook, so I added the NuGet package for facebook in visual studio 2015. My dot net target version is 4.5 Full Profile. 此控制台应用程序需要访问Facebook,因此我在Visual Studio 2015中为Facebook添加了NuGet包。我的目标网版是4.5完整配置文件。

As soon as I instantiate the FacebookClient class, I get this exception: 实例化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$

How to fix that? 如何解决? I am sure that the facebook.dll should be compatible with mono. 我确定facebook.dll应该与mono兼容。

It looks like you are using an old C# compiler (Mono JIT compiler version 2.10.8.1). 您似乎正在使用旧的C#编译器(Mono JIT编译器版本2.10.8.1)。 Maybe a more recent version might fix your problem :) 也许更新的版本可能会解决您的问题:)

Mono.Cecil, Missing compiler required member 'System.Runtime.CompilerServices.ExtensionAttribute..ctor' Mono.Cecil,缺少编译器必需成员“ System.Runtime.CompilerServices.ExtensionAttribute..ctor”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM