0

I'm developing an app with my team with Xamarin in VS2017. Problem is.. one of our machine suddenly stopped building the project. Whenever i try to deploy the app in my phone. it gives an error such like below:

 Exception while loading assemblies: Java.Interop.Tools.Diagnostics.XamarinAndroidException: error XA0009: Error while loading assembly: 
C:\Users\
<username>\.nuget\packages\system.runtime.loader\4.3.0\lib\MonoAndroid10\_._ ---> System.BadImageFormatException: Format of the executable (.exe) or library (.dll) is invalid.
       at Mono.Cecil.PE.ImageReader.ReadImage()
       at Mono.Cecil.PE.ImageReader.ReadImage(Disposable`1 stream, String file_name)
       at Mono.Cecil.ModuleDefinition.ReadModule(Disposable`1 stream, String fileName, ReaderParameters parameters)
       at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters)
       at Mono.Cecil.AssemblyDefinition.ReadAssembly(String fileName, ReaderParameters parameters)
       at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.ReadAssembly(String file)
       at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Load(String fileName, Boolean forceLoad)
       --- End of inner exception stack trace ---
       at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Load(String fileName, Boolean forceLoad)
       at Xamarin.Android.Tasks.ResolveAssemblies.ResolveRuntimeAssemblyForReferenceAssembly(LockFile lockFile, DirectoryAssemblyResolver resolver, String assemblyPath)
       at Xamarin.Android.Tasks.ResolveAssemblies.Execute(DirectoryAssemblyResolver resolver)

I don't know what this 0KB file (MonoAndroid10_._) does special but it comes highlited each time i try to build the project.

When i look at the BUILD OUTPUT LOG.. It shows System.Runtime.Loader assembly is not being loaded:

 D/Mono    ( 5829): Assembly Loader probing location: 'System.Runtime.Loader'.
F/monodroid-assembly( 5829): Could not load assembly 'System.Runtime.Loader' during startup registration.
F/monodroid-assembly( 5829): This might be due to an invalid debug installation.
F/monodroid-assembly( 5829): A common cause is to 'adb install' the app directly instead of doing from the IDE.

I'm guessing the nuget package issue primarily, as recently I've updated Xamarin Android version to latest from 3.1 and it ran smoothly in other two PCS except one.

This is something I've experienced before in my PC. but eventually it got resolved anyhow.. Now, in other PC the same error is not being resolved.

P.S. I'm using Mi Note 3 to test the app.

Mayur Paghdal
  • 275
  • 1
  • 2
  • 12
  • [use old packages.config](https://github.com/xamarin/xamarin-android/issues/2076#issuecomment-415664321) in your app, not the new style to add nuget packages – magicandre1981 Nov 24 '18 at 07:36
  • can you please tell how to do tht (my current setting is selected to packages.config in tools > nuget) and i've face such issue for the first time so don't know this exactly, Thanks – Mayur Paghdal Nov 24 '18 at 09:38
  • 1
    "C:\Users\\.nuget\packages" shows you use the new one and not the packages.config. open the csproj and Remove the "PackageReference Include" entries and [install packages again](https://stackoverflow.com/q/53335453/1466046) – magicandre1981 Nov 25 '18 at 15:45
  • this helped a lot.. Thanks man! – Mayur Paghdal Nov 26 '18 at 14:37
  • so does it work when you use the old packages.config? – magicandre1981 Nov 26 '18 at 16:01

0 Answers0