猿问

Xamarin 和 .NET Standard 2 库问题

我创建了一个跨平台库,它有 3 个平台特定的实现:

  • 安卓

  • IOS

  • .NET 标准 2.0

我用 Nuget 打包了库,就像跨平台库项目所做的那样。

现在,当我创建一个新的 Xamarin Forms 项目并选择 .NET Standard 作为共享代码的方式时,我引用了我的 nuget 并尝试在 android 模拟器中运行它,我得到:


/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2,2): Error: Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'SDK.NetStandard, Version=1.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?

File name: 'SDK.NetStandard.dll'

  at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference, Mono.Cecil.ReaderParameters parameters) [0x0009a] in /Users/builder/data/lanes/5945/342b2ce9/source/monodroid/external/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/DirectoryAssemblyResolver.cs:229 

  at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference) [0x00000] in /Users/builder/data/lanes/5945/342b2ce9/source/monodroid/external/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/DirectoryAssemblyResolver.cs:179 

  at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences (Java.Interop.Tools.Cecil.DirectoryAssemblyResolver resolver, System.Collections.Generic.ICollection`1[T] assemblies, Mono.Cecil.AssemblyDefinition assembly, System.Boolean topLevel) [0x0014a] in <fdfe8f54615a4e2ab24c72dc90da5c64>:0 

  at Xamarin.Android.Tasks.ResolveAssemblies.Execute (Java.Interop.Tools.Cecil.DirectoryAssemblyResolver resolver) [0x00237] in <fdfe8f54615a4e2ab24c72dc90da5c64>:0  (blank.Android)

我已经仔细检查过,并且 nuget 包中存在 SDK.NetStandard.dll。


我还通过使用 .NET Core 2 创建一个简单的控制台应用程序来测试它,并且库在那里工作。


四季花海
浏览 212回答 2
2回答
随时随地看视频慕课网APP
我要回答