2

I have C# winforms project setup under Visual Studio 2015. I also have 3 differnt windows service project under same solution. I used Omu.ValueInjecter for auto mapping argument to class.

I have added installer project that is basically uses Click Once inside with all of the dependencies being added to it.

I also have used MVP pattern to achieve UI piece of installation in to this project. And separate class for handling silence installer. See below code example

Earlier when I was running silent installer I got error related to NLog dll hence I have solved that through nuget packager and including this dll under project => properties => Application Files... But now after fixing NLog library I am getting File not found error for Omu.ValueInjecter dll(file not found sort of error).

I did follow similar steps as I did for NLog but no luck.

Below is code under program.cs file

[STAThread]
public static void Main(string[] args)
{
    if(args == null || args.Length <=0){
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Installer(args) { IsSilentInstall = false });
    }
    else
        new SilentInstaller(args) { IsSilentInstall = true; };
}

SilentInstaller.cs file code as below

public class SilentInstaller
{
    public SilentInstaller(string[] args)
    {            
        var run = OnOpen;
        if (run != null) run(args);
        //run?.Invoke(args);

        var install = OnInstall;
        install?.Invoke();

        var close = OnClose;
        close?.Invoke();
    }

    public event Action<string[]> OnOpen;
    public event Action OnInstall;
    public event Action OnClose;
}

File not found error is thrown at line if(run != null) run(args); in above example. run is of type event Action OnOpen;

Same piece of code implementation works well if I run UI based installer, but got error when run silent installer.

CSharpDev
  • 370
  • 1
  • 7
  • 28

0 Answers0