0

I have a VS2017 c# console app that I have published and when I click on Setup.exe it gives the following error:

Unhandled Exception: System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at MyprojectName.Sender.MailSender.SendNotification(String[] args)
   at MyprojectName.Program.Main(String[] args)

Here is the code from the Main method:

static void Main(string[] args)
{

    MailSender sender = ((UnityContainer)UnityConfig.GetConfiguredContainer()).Resolve<MailSender>();           
    sender.SendNotification(args);
}

The console app is expecting arguments but not sure why its raising this during the setup/Install. The console app is part of a larger solution so I right click on the console app project and select publish, set the publish path, click "From a CD-ROM or DVD-ROM", Click "The application will not check for updates" and click Finish.

It publishes successfully. I then click on the Setup.exe and it gives me the error.

In the properties of the project for Debug I have the two parameters its expecting in the Command Line Arguments. So if I debug the application it runs as expected.

77Vetter
  • 209
  • 3
  • 16
  • Please share a [mcve]. – mjwills Sep 03 '20 at 12:53
  • It would seem that `String[] args` is empty, null or has less items than expected. But that's all I can say since there is no code. What happens inside `SendNotification`? – VDWWD Sep 03 '20 at 12:57
  • This error happens when I try click the Setup.exe (that was generated from the Publish)- not actually running the console app. So I am just trying to install the app on the server (after publish) and thats when I get the error (after clicking Setup.exe) – 77Vetter Sep 03 '20 at 16:09
  • Your setup is running the app. – mjwills Sep 03 '20 at 21:27

0 Answers0