Ошибка 1001. Исключительная ситуация при инициализации установщика - PullRequest
0 голосов
/ 26 сентября 2019

Я получаю исключение System.IO.FileNotFoundException.

Не удалось загрузить файл или сборку ' file: /// C: \ Windows \ SysWOW64 \ Kumar ' или один из егозависимостей.

Система не может найти указанный файл.

при установке проекта установки.

Я протестировал проект на своей машине, и он работает нормально.

Когда я пытаюсь установить эту настройку на другой машине, я получаю вышеуказанную ошибку.

public override void Install(IDictionary stateSaver)
{

        base.Install(stateSaver);

        string targetDirectory = Context.Parameters["assemblypath"];

        string path = System.IO.Path.Combine(Directory.GetParent(targetDirectory).FullName, "Test.exe.config");

        if (String.IsNullOrEmpty(path))
        {
            throw new Exception("Config path should not be empty");
        }
        else
        {
            System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
            xDoc.Load(path);
            if (xDoc == null)
            {
                throw new Exception("Could not find config file");
            }

            XmlNode appNode = xDoc.SelectSingleNode("configuration/appSettings");
            if (appNode == null)
            {
                throw new Exception("Config file have some invalid node");
            }
            XmlNode el = appNode.SelectSingleNode("//add[@key='serviceAddress']");

            if (el == null)
            {
                throw new Exception("Config file have some invalid node");
            }

            ((XmlElement)el).SetAttribute("value", endPointUrl);
            xDoc.Save(path); // saves the web.config file
        }
}
...