ArduPilot / MissionPlanner

Mission Planner Ground Control Station for ArduPilot (c# .net)
http://ardupilot.org/planner/
GNU General Public License v3.0
1.68k stars 2.33k forks source link

Visual Studio design time issue #3306

Open HYZ-87 opened 3 months ago

HYZ-87 commented 3 months ago

Issue details

MethodNotFoundExceptions occur when I tried to open design pages of HUD and FlightData. image
I tried several ways to solve this, but I still couldn't figure out the reason.

After I updated the version of VS at the laptop that used to work, I finally found out the main reason that causes this situation.

The problem occurred after I updated Visual Studio. The design pages worked fine when I used version 17.8.4 until I updated it to version 17.9.2.

It's either already a potential issue of MP and got exposed due to the bug fix of IDE or it's just the IDE's problem. I can't be certain.

Since I use the community version, there's no way for me to re-install the old version. Has anyone met this issue before? Is there any workaround?

Version

1.3.80 & commit 1fb0fe26

Platform

N/A

Airframe type

N/A

Hardware type

N/A

Logs

N/A

EosBandi commented 3 months ago

It is a Visual Studio issue, 17.9 broke it. Currently no solution yet, only roll back to 17.8.x

HYZ-87 commented 3 months ago

I see. Thanks for your reply.

robertlong13 commented 1 month ago

I spent the better part of a day trying to tweak the source to bypass this problem (since I don't think Microsoft is going to fix this anytime soon). Unfortunately, I couldn't get anything to work in a way that could be merged into the repo.

I do, however, have a workaround. Whenever you need to use the designer on FlightData.cs, comment out every line that calls the GdiGraphics constructor in HUD.cs: https://github.com/ArduPilot/MissionPlanner/blob/33aa9ec70649635af77a0388d68e28057f243299/ExtLibs/Controls/HUD.cs#L274 https://github.com/ArduPilot/MissionPlanner/blob/33aa9ec70649635af77a0388d68e28057f243299/ExtLibs/Controls/HUD.cs#L1932 https://github.com/ArduPilot/MissionPlanner/blob/33aa9ec70649635af77a0388d68e28057f243299/ExtLibs/Controls/HUD.cs#L3717

Keep a stash of that change handy.

I have no idea why I can't hide these calls behind a design-mode check. It doesn't seem to work. No matter what I do, those lines attempt to call and throw exceptions, without ever hitting any nearby breakpoints when I do design-time debugging. When I comment them out, my breakpoints correctly hit, and my design-mode checks seem to work. It's baffling.

Even wrapping those in try-catch blocks didn't fix it.

EosBandi commented 1 month ago

Indeed it is very strange bug. I spent quite a time as well to get a workaround, without success. As an icing on the cake, VS 17.9.6 and .7 not only gives an error, but crashes when tries open HUD or FlightData in design mode :(