0

I'm using Inno Setup to create the setup file for my C# application! If the user choose C:\Program Files\ as installation folder the tool can't start with exception

'System.NullReferenceException'

at Main

static class Program
{        
    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new View.MainGUI()); // EXCEPTION IN THIS LINE
    }
}

Remarks:

  • installation works fine with PrivilegesRequired=admin in [Setup]
  • default folder for installation C:\UserData\ (no issues)
  • Windows 7 32bit

Any hints why the application crashes here?

Thx

leon22
  • 5,280
  • 19
  • 62
  • 100
  • Are you using a 64bit machine? You may need to install under `C:/Program Files (86x)/` – dav_i Nov 13 '13 at 12:51
  • Sorry, I forgot to mention: 32bit version of Windows 7 – leon22 Nov 13 '13 at 12:55
  • Does the same error happen if the user explicitly chooses "Run as Administrator"? – Roger Rowland Nov 13 '13 at 12:58
  • Probably a UAC issue; "Inno Setup installers require Admin Privileges by default " - http://stackoverflow.com/a/14499544/1073107 – dash Nov 13 '13 at 13:04
  • Wait. Is this about starting the application from Inno Setup ? If so, do you run the setup with administrator privileges ? If answers to both questions are yes, please post your `[Run]` section entry script code for this application, or just add the `runasoriginaluser` flag to that entry, if you know how. – TLama Nov 13 '13 at 13:17
  • If PrivilegesRequired=admin is set in Inno Setup script you can start the setup only as admin! Starting the application means after setup process finished run the exe of my tool! – leon22 Nov 13 '13 at 13:29
  • 1
    Please be less vague. Which line raises the exception? What is the call stack of the exception? – Raymond Chen Nov 13 '13 at 14:35
  • This is an application fault, you should use normal debugging techniques to find out what your application is failing on. It's nothing to do with Inno itself, but most likely due to your misconceptions. – Deanna Nov 13 '13 at 15:03
  • @Deanna Why should this be an application fault if I have no issues with default installation directory?! – leon22 Nov 13 '13 at 18:46
  • 1
    @leon22 Space in the path, unable to write to installation folder, failure to open something for writing, hard coded paths, etc. It's impossible for anyone to say with the information you've given so far. There is nothing in the code you've shown that can, itself, cause the error you've reported. It's most likely something that runs from the message pump directly (remoting?) or will be inside the `MainGUI`'s constructor (and called code). Oh, and what is `c:\UserData\`? It's not a standard folder on any system, and absolutely the wrong place to use as the default installation path. – Deanna Nov 13 '13 at 20:00
  • 1
    Another thing that could go wrong is simply failing to install all the files required by your application. – Miral Nov 14 '13 at 07:12
  • As a test, you can copy the file(s) from the "broken" location to another "good" location and see what it does. This can even be done on your development machine to rule out Inno Setup entirely. – Deanna Nov 14 '13 at 12:16
  • @Deanna C:\UserData is a default path @ our company! If I copy all files to e.g. C:\UserData after installation the application starts normally! Any hints? Thx – leon22 Nov 15 '13 at 07:44
  • @leon22 I'm glad it's for internal use only. That path should never be used in a general release application. As for the error itself, have you tried the plethora of other suggestions that have been made like actually debugging your own application? As you've found, it's nothing to do with Inno, but instead is file system location dependant. – Deanna Nov 15 '13 at 09:54

1 Answers1

0

It was an access problem after installation to a folder that requires Admin rights (c:\Program Files)

Solution: Changed the write location of my log files to %appdata%

leon22
  • 5,280
  • 19
  • 62
  • 100