Search code examples
.netdelphiapp-configshellexecute

Application Configuration File Not Being Read When Application Called via ShellExecute


I have a .NET application that is launched via a Delphi program using ShellExecute. Unfortunately when launched in this manner, the application does not seem to be reading its app.config file correctly, as if the file did not exist.

I have tried testing the application in other scenarios, e.g. calling from a shortcut with the the working directory set to a different folder and it runs fine.

[Edit]The Environment.CurrentDirectory property returns the directory of the Delphi program.

Any ideas would be really appreciated.

Cheers,

James


Solution

  • Well I researched it a bit and there does not appear to be a solution that is both simple and elegant.

    The easiest way round it seems to be to call an intermediate .NET program that then runs the target application via Process.Start and passes the parameters on. Not ideal but it's simpler than the other solutions I have found so far.