1

目前,我有一个适用于 Android 和 iOS 应用程序的 Xamarin 表单项目。该应用程序在 Android 和 iOS 上都能完美运行。我也想在 Windows 中提供支持。所以我按照下面的链接将 UWP 项目添加到我的解决方案中。

https://developer.xamarin.com/guides/xamarin-forms/platform-features/windows/installation/universal/

为 UWP 添加新项目后,将使用 UWP 作为启动项目构建解决方案。但是,当我尝试在本地机器中运行应用程序时。我收到以下错误。

System.IO.FileLoadException: 'Could not load file or assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)'

我在 VS2015 和 VS2017 中都尝试过,它们都提供了相同的错误(VS2015 提供了另外两个关于 mscorlib 的错误,这在 VS2017 中没有出现)。

这是错误的堆栈跟踪。

在 System.ModuleHandle.ResolveType(RuntimeModule 模块,Int32 typeToken,IntPtr* typeInstArgs,Int32 typeInstCount,IntPtr* methodInstArgs,Int32 methodInstCount,ObjectHandleOnStack 类型)在 System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule 模块,Int32 typeToken,RuntimeTypeHandle[] typeInstantiationHandle ] methodInstantiationContext) 在 System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) 在 System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport 范围, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType、Boolean mustBeInheritable、Object[] 属性、IList derivedAttributes、RuntimeType&System.Reflection.CustomAttribute.GetCustomAttributes 中的属性类型、IRuntimeMethodInfo& ctor、Boolean& ctorHasParameters、Boolean& isVarArg) RuntimeAssembly 程序集,RuntimeType caType) 在 System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit) 在 Xamarin.Forms.Internals.Registrar.RegisterAll(Type[] attrTypes) 在 Xamarin.Forms.Forms.Init(IActivatedEventArgs launchActivatedEventArgs, IEnumerable`1 rendererAssemblies) 在 ShowCaseSample.UWP.App.OnLaunched(LaunchActivatedEventArgs e)IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) 在 System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) 在 System.Reflection.CustomAttribute.GetCustomAttributes 程序集(RuntimeAs , RuntimeType caType) 在 System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit) 在 Xamarin.Forms.Internals.Registrar.RegisterAll(Type[] attrTypes) 在 Xamarin.Forms.Forms.Init(IActivatedEventArgs launchActivatedEventArgs, IEnumerable` ShowCaseSample.UWP.App.OnLaunched(LaunchActivatedEventArgs e) 上的 1 个渲染器组件IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) 在 System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) 在 System.Reflection.CustomAttribute.GetCustomAttributes 程序集(RuntimeAs , RuntimeType caType) 在 System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit) 在 Xamarin.Forms.Internals.Registrar.RegisterAll(Type[] attrTypes) 在 Xamarin.Forms.Forms.Init(IActivatedEventArgs launchActivatedEventArgs, IEnumerable` ShowCaseSample.UWP.App.OnLaunched(LaunchActivatedEventArgs e) 上的 1 个渲染器组件Boolean& isVarArg) 在 System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) 在 System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) 在 System .Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit) at Xamarin.Forms.Internals.Registrar.RegisterAll(Type[] attrTypes) at Xamarin.Forms.Forms.Init(IActivatedEventArgs launchActivatedEventArgs, IEnumerable`1 rendererAssemblies) at ShowCaseSample。 UWP.App.OnLaunched(LaunchActivatedEventArgs e)Boolean& isVarArg) 在 System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) 在 System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) 在 System .Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit) at Xamarin.Forms.Internals.Registrar.RegisterAll(Type[] attrTypes) at Xamarin.Forms.Forms.Init(IActivatedEventArgs launchActivatedEventArgs, IEnumerable`1 rendererAssemblies) at ShowCaseSample。 UWP.App.OnLaunched(LaunchActivatedEventArgs e)在 System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) 在 System.Attribute.GetCustomAttributes(Assembly element, Type attributeType) , 布尔继承) 在 Xamarin.Forms.Internals.Registrar.RegisterAll(Type[] attrTypes) 在 Xamarin.Forms.Forms.Init(IActivatedEventArgs launchActivatedEventArgs, IEnumerable`1 rendererAssemblies) 在 ShowCaseSample.UWP.App.OnLaunched(LaunchActivatedEventArgs e)在 System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) 在 System.Attribute.GetCustomAttributes(Assembly element, Type attributeType) , 布尔继承) 在 Xamarin.Forms.Internals.Registrar.RegisterAll(Type[] attrTypes) 在 Xamarin.Forms.Forms.Init(IActivatedEventArgs launchActivatedEventArgs, IEnumerable`1 rendererAssemblies) 在 ShowCaseSample.UWP.App.OnLaunched(LaunchActivatedEventArgs e)Boolean isDecoratedTargetSecurityTransparent) 在 System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) 在 System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit) 在 Xamarin.Forms.Internals.Registrar.RegisterAll(Type[] attrTypes)在 Xamarin.Forms.Forms.Init(IActivatedEventArgs launchActivatedEventArgs, IEnumerable`1 rendererAssemblies) 在 ShowCaseSample.UWP.App.OnLaunched(LaunchActivatedEventArgs e)Boolean isDecoratedTargetSecurityTransparent) 在 System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) 在 System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit) 在 Xamarin.Forms.Internals.Registrar.RegisterAll(Type[] attrTypes)在 Xamarin.Forms.Forms.Init(IActivatedEventArgs launchActivatedEventArgs, IEnumerable`1 rendererAssemblies) 在 ShowCaseSample.UWP.App.OnLaunched(LaunchActivatedEventArgs e)在 ShowCaseSample.UWP.App.OnLaunched(LaunchActivatedEventArgs e) 处初始化(IActivatedEventArgs launchActivatedEventArgs,IEnumerable`1 rendererAssemblies)在 ShowCaseSample.UWP.App.OnLaunched(LaunchActivatedEventArgs e) 处初始化(IActivatedEventArgs launchActivatedEventArgs,IEnumerable`1 rendererAssemblies)

4

0 回答 0