Xamarin.Forms.Forms.Init = System.BadImageFormatException

时间:2017-10-10 19:35:55

标签: c# xamarin.forms uwp window native

我在Windows 8.1和Windows Phone 8.1上安装了一个带有Xamarin.Forms的应用程序。 现在,当我支持UWP时,它运行正常,因为我没有使用Native工具链。

Whwn我使用Native工具链我得到这个错误:

System.BadImageFormatException: 'Format of the executable (.exe) or library (.dll) is invalid.'

我打电话的时候:

Xamarin.Forms.Forms.Init(e, assembliesToInclude);

你可以看到,当我阅读本指南时,我试图加载所有的assmeblies https://developer.xamarin.com/guides/xamarin-forms/platform-features/windows/installation/universal/#Target_Invocation_Exception_when_using_Compile_with_.NET_Native_tool_chain

我在100年内一直在寻找如何解决但却没有成功的问题。 Microsoft Store不允许在没有Native工具链的情况下上传应用程序... 我已更新到最新的Xamarin.Forms(2.4.0.282)和 Microsoft.NETCore.UniversalWindowsPlatform(6.0.1)。 Visual Studio 2017

编辑: 我在异常中找到的callstack:

  

是在   System.Reflection.Runtime.General.TypeResolver.TryResolveTypeReference(ReflectionDomain   reflectionDomain,MetadataReader reader,TypeReferenceHandle   typeReferenceHandle,Exception&例外)   F:\ DD \ NDP \ fxcore \ CoreRT的\ src \ System.Private.Reflection.Core的\ src \ SYSTEM \反射\运行\一般\ TypeResolver.cs:行   209在   System.Reflection.Runtime.General.TypeResolver.TryResolve(ReflectionDomain   reflectionDomain,MetadataReader reader,Handle typeDefRefOrSpec,   TypeContext typeContext,Exception&例外)   F:\ DD \ NDP \ fxcore \ CoreRT的\ src \ System.Private.Reflection.Core的\ src \ SYSTEM \反射\运行\一般\ TypeResolver.cs:行   44点   System.Reflection.Runtime.General.MetadataReaderExtensions.TryParseConstantValue(手柄   handle,ReflectionDomain reflectionDomain,MetadataReader reader,   对象和放大器;价值)   F:\ DD \ NDP \ fxcore \ CoreRT的\ src \ System.Private.Reflection.Core的\ src \ SYSTEM \反射\运行\一般\ MetadataReaderExtensions.cs:行   359在   System.Reflection.Runtime.CustomAttributes.RuntimeNormalCustomAttributeData.ParseFixedArgument(MetadataReader   reader,FixedArgumentHandle fixedArgumentHandle,Boolean   throwIfMissingMetadata,Func'1 getTypeFromConstructor)in   F:\ DD \ NDP \ fxcore \ CoreRT \ SRC \ System.Private.Reflection.Core \ SRC \ SYSTEM \反射\运行\ CustomAttributes \ RuntimeNormalCustomAttributeData.cs:线   188点   System.Reflection.Runtime.CustomAttributes.RuntimeNormalCustomAttributeData.GetConstructorArguments(布尔   throwIfMissingMetadata)in   F:\ DD \ NDP \ fxcore \ CoreRT \ SRC \ System.Private.Reflection.Core \ SRC \ SYSTEM \反射\运行\ CustomAttributes \ RuntimeNormalCustomAttributeData.cs:线   67点   System.Reflection.Runtime.CustomAttributes.RuntimeCustomAttributeData.get_ConstructorArguments()   在   F:\ DD \ NDP \ fxcore \ CoreRT \ SRC \ System.Private.Reflection.Core \ SRC \ SYSTEM \反射\运行\ CustomAttributes \ RuntimeCustomAttributeData.cs:线   41点   Internal.Reflection.Extensions.NonPortable.CustomAttributeInstantiator.Instantiate(一个CustomAttributeData   cad)in   F:\ DD \ NDP \ fxcore \ CoreRT \ SRC \ System.Private.Reflection.Execution \ SRC \内部\反射\扩展\非便携式\ CustomAttributeInstantiator.cs:线   34点   System.Reflection.CustomAttributeExtensions.Instantiate(IEnumerable'1   cads,输入actualElementType)   F:\ DD \ NDP \ fxcore \ SRC \ System.Reflection.Extensions \ SYSTEM \反射\ CustomAttributeExtensions.cs:线   333 at   System.Reflection.CustomAttributeExtensions.GetCustomAttributes(大会   element,Type attributeType)in   F:\ DD \ NDP \ fxcore \ SRC \ System.Reflection.Extensions \ SYSTEM \反射\ CustomAttributeExtensions.cs:线   194 at Xamarin.Forms.Internals.Registrar.RegisterAll(Type []   atmaTypes)在Xamarin.Forms.Forms.Init(IActivatedEventArgs   launchActivatedEventArgs,IEnumerable`1 rendererAssemblies)

我无法解决任何失败的exe或dll,源变量设置为  的未知

编辑2: Okey,现在我创建了一个新的UWP项目,包括Xamarin.Forms和我的所有库,以及我的所有Xamarin.Forms自定义渲染器,我得到相同的exceptopm,但是当我注释掉所有:

//[assembly: ExportRenderer(typeof(SmartBoxView), typeof(SmartBoxViewRenderer))]

然后它适用于测试项目,当我回到我的真实项目并注释掉它们时,我在 Xamarin.Forms.Forms.Init 方法中得到另一个例外:

System.IO.FileNotFoundException: 'Cannot load assembly 'ClrCompression'. No metadata found for this assembly.'

0 个答案:

没有答案
相关问题