Xamarin组件无法解析程序集

5
我正在尝试构建一个Xamarin组件。 我已经从绑定项目创建了SomeLibrary.dll。 使用此SomeLibrary.dll和组件模板(https://components.xamarin.com/guidelines),我生成了SomeLibrary-1.0.xam组件。
我执行了以下命令将SomeLibrary组件安装到Xamarin Studio(这样我就可以在提交到商店之前测试组件): mono xamarin-component.exe install /Users/somedeveloper/Desktop/XamarinComponent/component-template-master/SomeLibrary-1.0.xam (建议来自http://forums.xamarin.com/discussion/5640/test-component-packaging)
现在,我正在尝试测试我的SomeLibrary组件。我创建了一个全新的项目,将该组件添加到我的项目中,编写了几行使用SomeLibrary api的代码,并在构建和运行时得到以下错误。 我很迷茫和困惑,有任何想法和建议都可以提出。^^。
我从错误信息中看到的主要问题是:

错误 MT2002: 无法解析程序集: 'SomeLibrary, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'

看起来是在抱怨某种PublicKeyToken。这是什么?我是否需要为我的SomeLibrary组件生成一个PublicKeyToken?如果需要,如何生成PublicKeyToken。

感谢并欣赏任何帮助、建议或评论!^_^!

完整错误日志

Building: SomeLibraryComponent (Debug|iPhone)

Detecting signing identity...
Provisioning Profile: XXXXXXXXXXXXXXXXXXXXXXXXXXXX
Signing Identity: "iPhone Developer: XXXXXXXXXX (ALKJLKJSLDKJFLJ)"
App ID: "SDLFJLKSDJF.SomeLibrarycomponent"
Performing main compilation...
/Library/Frameworks/Mono.framework/Versions/3.2.3/bin/mcs /noconfig "/r:/Developer/MonoTouch/usr/lib/mono/2.1/mscorlib.dll" -nostdlib     "/out:/Users/somedeveloper/projects/SomeLibraryComponent/SomeLibraryComponent/bin/iPhone/Debug/SomeLibraryComponent.exe" "/r:/Developer/MonoTouch/usr/lib/mono/2.1/System.dll" "/r:/Developer/MonoTouch/usr/lib/mono/2.1/System.Xml.dll" "/r:/Developer/MonoTouch/usr/lib/mono/2.1/System.Core.dll" "/r:/Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll" "/r:/Users/somedeveloper/projects/SomeLibraryComponent/Components/SomeLibrary-1.0/lib/ios/SomeLibrary.iOS.dll" "/r:/Developer/MonoTouch/usr/lib/mono/2.1/System.Core.dll" /nologo /warn:4 /debug:full /optimize- /codepage:utf8 "/define:DEBUG;__MOBILE__;__IOS__"  /t:exe "/Users/somedeveloper/projects/SomeLibraryComponent/SomeLibraryComponent/Main.cs" "/Users/somedeveloper/projects/SomeLibraryComponent/SomeLibraryComponent/AppDelegate.cs" "/Users/somedeveloper/projects/SomeLibraryComponent/SomeLibraryComponent/SomeLibraryComponentViewController.cs" "/Users/somedeveloper/projects/SomeLibraryComponent/SomeLibraryComponent/SomeLibraryComponentViewController.designer.cs"
Compilation succeeded - 1 warning(s)

/Users/somedeveloper/projects/SomeLibraryComponent/SomeLibraryComponent/SomeLibraryComponentViewController.cs(48,24): warning CS0672: Member `SomeLibraryComponent.SomeLibraryComponentViewController.ShouldAutorotateToInterfaceOrientation(MonoTouch.UIKit.UIInterfaceOrientation)' overrides obsolete member `MonoTouch.UIKit.UIViewController.ShouldAutorotateToInterfaceOrientation(MonoTouch.UIKit.UIInterfaceOrientation)'. Add the Obsolete attribute to `SomeLibraryComponent.SomeLibraryComponentViewController.ShouldAutorotateToInterfaceOrientation(MonoTouch.UIKit.UIInterfaceOrientation)'
/Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll (Location of the symbol related to previous warning)


Build complete -- 0 errors, 1 warning

Compiling to native code
/Developer/MonoTouch/usr/bin/mtouch -sdkroot "/Applications/Xcode.app/Contents/Developer" --cache "/Users/somedeveloper/projects/SomeLibraryComponent/SomeLibraryComponent/obj/iPhone/Debug/mtouch-cache" --nomanifest --nosign -dev "/Users/somedeveloper/projects/SomeLibraryComponent/SomeLibraryComponent/bin/iPhone/Debug/SomeLibraryComponent.app" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.Xml.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.Core.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll" -r "/Users/somedeveloper/projects/SomeLibraryComponent/Components/SomeLibrary-1.0/lib/ios/SomeLibrary.iOS.dll" -debug -sdk "6.1" -targetver "6.0" --abi=armv7 "-v" "-v" "-v" "--compiler:clang++" "/Users/somedeveloper/projects/SomeLibraryComponent/SomeLibraryComponent/bin/iPhone/Debug/SomeLibraryComponent.exe"
Xamarin.iOS 7.0.1.4 (4cfca2f) Business Edition using framework:     /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk
Linking assembly     /Users/somedeveloper/projects/SomeLibraryComponent/SomeLibraryComponent/bin/iPhone/Debug/SomeLibraryComponent.exe into     /Users/somedeveloper/projects/SomeLibraryComponent/SomeLibraryComponent/obj/iPhone/Debug/mtouch-cache/PreBuild
error MT2002: Failed to resolve assembly: 'SomeLibrary, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
Failed to resolve assembly: 'SomeLibrary, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
  at MonoTouch.Tuner.Linker.Process (MonoTouch.Tuner.LinkerOptions options, Mono.Linker.LinkContext& context, System.Collections.Generic.List`1& assemblies) [0x00000] in <filename unknown>:0
  at MTouch.LinkAssemblies (System.String main, System.Collections.Generic.List`1& assemblies, System.String output_dir, Mono.Linker.LinkContext& link_context) [0x00000] in <filename unknown>:0
  at MonoTouch.Application.ManagedLink () [0x00000] in <filename unknown>:0
  at MonoTouch.Application.ProcessAssemblies () [0x00000] in <filename unknown>:0
  at MonoTouch.Application.BuildApp () [0x00000] in <filename unknown>:0
  at MonoTouch.Application.Build () [0x00000] in <filename unknown>:0
  at MTouch.Main2 (System.String[] args) [0x00000] in <filename unknown>:0
  at MTouch.Main (System.String[] args) [0x00000] in <filename unknown>:0 
3个回答

7

这和公钥(令牌)无关。

从您日志的第一部分看,您的.dll文件名为"SomeLibrary.iOS.dll"。然而,错误消息正在寻找"SomeLibrary",而不是"SomeLibrary.iOS"。

文件名和内部程序集名称之间必须存在不匹配。


3
我复制一个项目并将项目文件名从Foundation.Mobile更改为Mobile时遇到了困难。我一直收到“组件未能解析程序集”的错误提示。答案是在项目属性中更改实际的程序集名称。enter image description here

2

卸载 "SomeLibrary" 包并通过 Nuget 包管理器重新安装即可。

我遇到了同样的错误(Failed to resolve assembly: 'SomeLibrary, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'),而在我的情况下,这就是解决方案。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接