Emulator/VS and phone work much different

Lloyd Sheen 1,476 Reputation points
2023-04-29T18:06:37.6+00:00

I just had a very strange problem. I had a view which worked with no problem in the emulator and in the phone while debugging using Visual Studio.

The phone app would just quit so I had to create a new set of things to display what was happening as getting info from either the phone or emulator is not easy.

The ultimate problem was that in the view there was a use of the IsNotEqualConverter from http://schemas.microsoft.com/dotnet/2022/maui/toolkit. I made a mistake and did not copy the resources so there was a problem. I fixed that but found out that VS and emulator / phone deal with this problem in very different ways.

I tried with the converters commented out and while executing from VS it ran with no problem. The set of things I created was basically a text file that was written to for each line in the method that was setting up the ItemsSource of a collectionview. Now when it ran the "trace" showed no problems and certainly not that the converter was not found. Seems that VS is doing something that just running the app would not do. When I just run the app from my phone I can see the error raised in a try/catch and is written to the trace file.

This means to me that using VS to run and using just the phone to run have very different ways of dealing with things. If I comment out the converters and run using the phone , when I try to get the ItemsSource it fails with the cannot find the converter problem and just stops. When I run in VS , VS seems to find the converter in some way or not even try to use it as it cannot be found (not sure about this).

Now the one thing that may be the problem is the popup using the community toolkit. I would be too much work to try this without using the toolkit but that is a possibility. Another problem I found with the toolkit is that elements in the content of the popup are not available in the properties window when you click one of them. All the elements show the popup but not the child element. I would put this in support for the toolkit but none of the pages I have been to show me where to do this.

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,232 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Lloyd Sheen 1,476 Reputation points
    2023-05-12T15:06:38.53+00:00

    I found the problem. I am using BindableProperties for the first time and need to add the propertychanged method so that I can respond to the changes. When I hover over the method name I can use VS to create the method. In the method depending on what VS does I get a throw of an error. I just added the bindables and ran a test thru VS that had no problems. When I tried to execute it just from the phone or emulator it just stopped. Seems that when running thru VS , VS captures the throw and deals with it which the phone/emulator does not is the problem.

    Is there a setting in VS that will cause the throw of nothing as code is not complete to be not only captured and seemingly ignored can be captured so the debugging is handled better?

    0 comments No comments