0

I get this message after creating a new iOS project:

UIApplication.Main(args, null, "AppDelegate");

CS0618: 'UIApplication.Main(string[]?, string?, string?)' is obsolete: 'Use the overload with 'Type' instead of 'String' parameters for type safety.'

What should I do with this line of code? Can I delete it?

Program.cs:

using Foundation;
using UIKit;

namespace MyProject
{
[Register("AppDelegate")]
class Program : UIApplicationDelegate
{
    private static Game1 game;

    internal static void RunGame()
    {
        game = new Game1();
        game.Run();
    }

    static void Main(string[] args)
    {
        UIApplication.Main(args, null, "AppDelegate");
    }

    public override void FinishedLaunching(UIApplication app)
    {
        RunGame();
    }
}
}
harry_mitch
  • 77
  • 1
  • 8
  • the error message tells you **exactly** what to do to fix this – Jason Dec 08 '21 at 15:17
  • I changed it but then I get another error message: Error CS0246: The type or namespace name 'AppDelegate' could not be found (are you missing a using directive or an assembly reference?) – harry_mitch Dec 08 '21 at 19:01
  • do you have a using statement that references the namespace your AppDelegate is in? This is fairly basic C# debugging – Jason Dec 08 '21 at 19:31
  • I know that there is missing a using statement in Program.cs but I don't know which using statement that I should use. I can not find a using statement that solves the problem. – harry_mitch Dec 08 '21 at 19:46
  • Can I change it from UIApplication.Main(args, null, "AppDelegate"); to UIApplication.Main(args, null, typeof(MyProject.Program));? – harry_mitch Dec 09 '21 at 11:01
  • I tried to create a new xamarin project and modify UIApplication.Main(args, null, typeof(AppDelegate)); and there was no error. So I suggest you can try to create a new project to try. – Wen xu Li Dec 10 '21 at 09:42

0 Answers0