I’m trying to migrate my old Xamarin Form App to .Net MAUI application.
According to the document for .Net MAUI, I installed Dynatrace.OneAgent.MAUI package, add the config file into my project, and input the code into App.xaml.cs file after “InitializeComponent();”
using Dynatrace.MAUI;<br>namespace MauiApp2<br>{<br> public partial class App : Application<br> {<br> public App()<br> {<br> InitializeComponent();<br> <font size="4" color="#FF0000">Agent.Instance.Start();</font><br> MainPage = new AppShell();<br> }<br> }<br>Agent.Instance.Start();
then I rebuild my porject, and I got following error:
<font size="3">Error CS0103 The name 'Agent' does not exist in the current context </font>
<font size="4" color="#000000">Error CS0234 The type or namespace name 'Agent' does not exist in the namespace 'Dynatrace.MAUI' (are you missing an assembly reference?) </font>
Thanks for reaching out. Based on your tests with a new MAUI app using .NET 8, I was able to add our MAUI package and use the same steps that you did to build and start the app with the agent loading properly when the app starts. How are you installing the package? Are you building via Visual Studio or using msbuild? Windows or Mac?
I got the error when input Agent.Instance.Start(); in App.xaml.cs, but it works fine when I input the in MainApplication.cs file, as the place to input the code has not been mentioned in the document.
Thanks very much for the video of the issue. It made things a lot easier to understand!
I was originally testing on a Mac so the situation was a little different on my end. I installed Visual Studio on a windows VM so that I could get a better understanding of the issue you are facing. It looks like you have “Windows” selected as the platform to test with (or context I suppose) which is not supported with our NuGet package. To get this to work properly, you have to click the drop down menu near the top left (see images) and select android. This should resolve the issue you are facing.
If you run into any problems with the instructions that I provided, please let me know!