5

我正在尝试构建一个 xamarin 组件。我从 Binding 项目创建了 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 的代码,并在构建和运行时出现以下错误。我在这里迷茫和困惑,任何想法,建议都会很棒。^^。

我从错误中看到的主要内容是:

error MT2002: Failed to resolve assembly: '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 
4

3 回答 3

6

它与公钥(令牌)无关。

从日志的第一部分来看,您的 .dll 似乎被命名为“SomeLibrary.iOS.dll”。但是,错误消息正在寻找“SomeLibrary”,而不是“SomeLibrary.iOS”。

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

于 2013-10-04T19:39:04.253 回答
3

我通过复制一个项目并将项目文件从Foundation.Mobile重命名为Mobile被困在这里。我不断收到“组件无法解析程序集”。答案是更改项目属性中的实际程序集名称。在此处输入图像描述

于 2017-09-14T13:06:39.317 回答
1

卸载包“ SomeLibrary”并通过 Nuget 包管理器再次安装。

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

于 2021-05-13T13:34:27.853 回答