-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Bug] Debugging Android application throws BadImageFormatException in VS 17.6 #15768
Comments
I get the exact same error when calling a JavaScript Interface, building for SDK level 31. |
Yesterday I started to get this error. |
workaround: which worked for me |
After that when you add new breakpoints does the issue appear again? |
No, I'm using it right now |
I renamed the top level folder of the git project in my computer, cloned again from the repository and it started to work. |
I am experiencing the same issue. Deleting bin and obj folders worked maybe for a day and the same issue appeared then. Downgrading Visual Studio to any 17.6.x version didn't help. Downgrading Xamarin.Forms didn't help (tested latest 5.0.0.2578 and 5.0.0.2545). |
Same exact issue after Upgrading VS to 17.6.3 -- Cant Debug Android - breakpoints are not hit in a shared library that were previously working & I get System.BadImageFormatException error OR I get the warning message with no error: "No Compatible Code Running On The Thread...The selected debug engine does not support any code executing on the current thread (e.g. only native runtime code is executing). You can switch to another thread to see if there is compatible code running" -- this warning message is displayed only on SOME BREAKPOINTS in the same exact class in similar functions which is so strange, and if I continue stepping in then the System.BadImageFormatException error is eventually thrown. The breakpoint name gets highlighted in BOLD font as they should in the breakpoint window when they are hit right before the error happens. Before upgrading VS to 17.6.x Debugging was fine on same project with same source code and same breakpoints. |
After alot of troubleshooting I noticed this issue was only happening on projects I had recently built/ compiled after updating VS, and Issue was NOT happening on older projects I ran without any new build -- so when I got the error in a newly built project I restored a backup of my entire solution / project folder I had made BEFORE upgrading VS and suddenly debug is working again & everything is fine. Next I deleted those restored bin and obj folders and rebuilt / re-compiled everything to generate new bin/obj and ERROR HAPPENS AGAIN! So Issue seems like it has something to do with building after upgrading VS if that makes sense. This might be why others have intermittent success deleting bin/obj, but regardless, I still cant build anything new and run debugger. Has anyone found a proper WORKAROUND??? does fresh reinstall of VS work? This issue is also happening in MAUI projects - Upgrading VS to 17.6.3 completely broke all my debugging. |
Unfortunately (in terms of a fix at least) this has nothing to do with Xamarin.Forms specifically I would think. From the information we have now it looks like this is in the tooling side of things. Please go into Visual Studio and click the Help menu > Provide Feedback and Report a Problem. That way the proper diagnostics will be collected and it will be routed to the correct team to help you further. Thanks! |
I realised this is closed, but I am curious if @danielkraut was using Sqlite and EFCore. I was having an issue with this when I was running migrations in the DbContext. When I moved that out into my bootstrapper, it resolved the debugger problem. |
@nzcoward No I was not using EFCore, although I was using Sqlite indirectly because I was using Akavache library which uses Sqlite internally. |
Am getting this on Android only, only when built on Windows. Building the same app on Mac has no issues. Microsoft Visual Studio Professional 2022 (64-bit) - Preview |
Here is the ticket on Visual Studio developer community. Feel free to upvote or attach your related issue/system logs. |
Description
After updating Visual Studio Community to 17.6, I can no longer debug Xamarin.Forms application (I tried Android only as I don't have iOS device at the moment).
Steps to Reproduce
Basic Information
Environment
Show/Hide Visual Studio info
Build log
Show/Hide Build log
Screenshots
Workaround
This issue suggests deleting bin and obj folders but it did not work for me - dotnet/android#8075
The text was updated successfully, but these errors were encountered: