System.BadImageFormatException: Could not resolve field token 0x040001ef

FrancoisMFrancoisM FRUniversity ✭✭

Hi,

I'm trying to run my xamarin forms app on android and get the below error with regards to the portable file:
System.BadImageFormatException: Could not resolve field token 0x040001ef

I'm on VS 2013, debug any cpu. I'm having that error both with xamarin android player and with a device.
Note that this error appeared after updating references. Before I had a runtime error saying CreateTableAsync (from sqlite.net.async) was missing while everything was compiling fine. I think it's related since the app crashes at the same place i.e when calling CreateTableAsync.

Tks.

François

Tagged:

Answers

  • FrancoisMFrancoisM FRUniversity ✭✭

    Note: as I had some linking errors at compile time I chose None in the Android options dropdown for the linker.

  • FrancoisMFrancoisM FRUniversity ✭✭

    Also: I unchecked Shared Runtime and I am now back with initial error:
    System.MissingMethodException: Method 'SQLiteAsyncConnection.CreateTableAsync' not found

  • FrancoisMFrancoisM FRUniversity ✭✭

    As I think everything is related, here is the error when I choose SDK Linking:

    Error 7 The "LinkAssemblies" task failed unexpectedly.
    Xamarin.Android.XamarinAndroidException: error XA2006: Reference to metadata item 'SQLite.Net.Async.SQLiteAsyncConnection/CreateTablesResult' (defined in XXXXXXX , Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') from XXXXXXX Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' could not be resolved. ---> Mono.Cecil.ResolutionException: Failed to resolve SQLite.Net.Async.SQLiteAsyncConnection/CreateTablesResult
    at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
    at MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
    at Mono.Linker.Steps.MarkStep.MarkGenericArguments(IGenericInstance instance)
    at Mono.Linker.Steps.MarkStep.GetOriginalType(TypeReference type)
    at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
    at MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
    at Mono.Linker.Steps.MarkStep.MarkField(FieldReference reference)
    at Mono.Linker.Steps.MarkStep.MarkFields(TypeDefinition type, Boolean includeStatic)
    at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
    at MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
    at Mono.Linker.Steps.MarkStep.InitializeType(TypeDefinition type)
    at Mono.Linker.Steps.MarkStep.InitializeType(TypeDefinition type)
    at Mono.Linker.Steps.MarkStep.InitializeAssembly(AssemblyDefinition assembly)
    at Mono.Linker.Steps.MarkStep.Initialize()
    at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
    at Mono.Linker.Pipeline.Process(LinkContext context)
    at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
    at Xamarin.Android.Tasks.LinkAssemblies.Execute()
    --- End of inner exception stack trace ---
    at Xamarin.Android.Diagnostic.Error(Int32 code, Exception innerException, String message, Object[] args)
    at Xamarin.Android.Tasks.LinkAssemblies.Execute()
    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
    at Microsoft.Build.BackEnd.TaskBuilder.d__20.MoveNext() XXXXXXX .Droid

  • FrancoisMFrancoisM FRUniversity ✭✭

    After reading that post:
    https://forums.xamarin.com/discussion/46150/sqlite-net-pcl-version-2-5-1-3-5-conflict-in-pcl-project-shared-by-all-the-3-platforms
    I noticed that my sqlite.net references in android where on version 3.0.5 while they were on 2.5.1 on portable and ios. I downgraded in android and it now compiles with "SDK Assemblies Only".
    However, I'm back on the first error when running:
    System.BadImageFormatException: Could not resolve field token 0x040001ef

  • BhaurajBiradarBhaurajBiradar USUniversity ✭✭

    Hi, Anyone knows on this ?

  • DanFordhamDanFordham USMember

    I got past this issue by updating the packages in my Android project.

    ProjectName -> Packages -> Update

  • BenjaminPettitBenjaminPettit USMember ✭✭

    Looks like this issue was from a bunch of missing dependencies, when I looked in the build log I had lots of lines like this:
    Could not find Google.Protobuf referenced by assembly Blah.Blah, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.

Sign In or Register to comment.