Showing results for 
Show  only  | Search instead for 
Did you mean: 

The start method for OneAgent is not valid in MAUI


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;
namespace MauiApp2
public partial class App : Application
public App()
MainPage = new AppShell();

then I rebuild my porject, and I got following error:

Error CS0103 The name 'Agent' does not exist in the current context 

If I change the code to:


the error will be:

Error CS0234 The type or namespace name 'Agent' does not exist in the namespace 'Dynatrace.MAUI' (are you missing an assembly reference?) 



Platform : .Net MAUI 
Target platform: Android

Framework : .NET Framework 8.0

NuGet Package : Dynatrace.OneAgent.MAUI - V1.279.1

IDE : Visual Studio Community 2022 (64-bit) - Version 17.8.3

I got the same problem when I create a new .Net MAUI App



Dynatrace Helper
Dynatrace Helper

Hi there!

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 install the package from the NuGet package management, building via Visual Studio on  Windows.

I have one question, where are you insert the start code? App.xaml.cs or other file?


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.

I just upload a video in google drive

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!




Thanks nicholas_mcwher  it works now, what I did is

1: un-check windows platform 

2: remove net8.0-maccatalyst from the TargetFrameworks in .csproj file (as there is no maccatalyst options in project propery page)



Ken Xu

Featured Posts