最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

xaml - Getting runtime error in Maui project when using Grid - Stack Overflow

programmeradmin4浏览0评论

We look after a mobile app that we migrated from Xamarin to Maui last year. Last build and release was in Sept 2024. Have just gone in a couple of days ago (Feb 2025) to update an image in the Maui app. The app built ok, however when I run it I get the following error:

"System.MethodAccessException: 'Method Microsoft.Maui.Graphics.NumericExtensions.Clamp(int,int,int)' is inaccessible from method Microsoft.Maui.Layouts.GridLayoutManager+GridStructure.InitializeCells()''"

No stack trace originating from my code that I can see to debug and troublshoot from.

Has anyone come across this before? I suspect that it is something to do with my environment (I am on VS 17.13.0 - which Ive upgraded to recently) or some obscure setting/configuration but so far havent found what.

I am running VS in admin mode, have tried clearing bin and obj folders.

If found that if I set the first page that loads up to instead of using a grid element in xaml to use a scrollview (or any other layout element), the app loads. Also, I have a hello world app that builds and runs fine using the element.

Maui version would have been 8 when I last built (Sept 2024), now (Feb 2025) I have 9 installed. Project is 8.0 so should still build ok.

dotnet workload list:

Installed Workload Id Manifest Version Installation Source

android 35.0.39/9.0.100 SDK 9.0.200, VS 17.13.35806.99 aspire 8.2.2/8.0.100 SDK 9.0.200, VS 17.13.35806.99 ios 18.2.9173/9.0.100 SDK 9.0.200, VS 17.13.35806.99 maccatalyst 18.2.9173/9.0.100 SDK 9.0.200, VS 17.13.35806.99 maui 9.0.14/9.0.100 SDK 9.0.200 maui-windows 9.0.14/9.0.100 SDK 9.0.200, VS 17.13.35806.99

This error happens for both Android and iOS. In iOS the line the error is thrown on is in Program.cs: UIApplication.Main(args, null, typeof(AppDelegate));

If anyone has any idea that could assist I would be hugely grateful. At the minute I am stumped

Have tried setting maui version to a specific version in .csproj (8.0.90), Have tried taking out multiple elements in xaml, but it seems only taking out the element gets around the issue. I could possibly convert all my pages to not use grids but would rather not

发布评论

评论列表(0)

  1. 暂无评论