C# Assembly Info Динамическое изменение

Я закончил сборщик APP с помощью Codedom, теперь я хочу реализовать функцию изменения информации о сборке перед компиляцией. Поэтому, когда клиент открывает.exe-файл (кодированный файл не скомпилирован), он получает 5-6 текстовых полей, а затем, когда пользователь заполняет их и щелкает информацию о сборке из этих блоков, используется для заполнения информации о сборке в AssemblyInfo.cs файла I' м компиляции.

Вот пример того, что я пытался использовать: Форма:

 using (ResourceWriter w = new ResourceWriter("res.resources"))
        {
            w.AddResource("AssemblyTitle", AssemblyTitle.Text);
            w.AddResource("AssemblyDescription", AssemblyDescription.Text);
            w.AddResource("AssemblyCompany", AssemblyCompany.Text);
            w.AddResource("AssemblyProduct", AssemblyProduct.Text);
            w.AddResource("AssemblyCopyright", AssemblyCopyright.Text);
            w.AddResource("AssemblyVersion", AssemblyVersion.Text);
            w.AddResource("FileName", FileName.Text);
            w.Generate();
        }
        if (CodeDom.Compile(FileName.Text + ".exe", new[] { source1, source2, source3, source4}, null, "res.resources"))
        {
            File.Delete("res.resources");
            MessageBox.Show("Done");

        }
    }

AssemblyInfo.cs:

private static void Main()
    {
        ResourceManager resourceManager = new ResourceManager("res", Assembly.GetExecutingAssembly());
        string Title = resourceManager.GetString("AssemblyTitle");
        string Description = resourceManager.GetString("AssemblyDescription");
        string Company = resourceManager.GetString("AssemblyCompany");
        string Product = resourceManager.GetString("AssemblyProduct");
        string Copyright = resourceManager.GetString("AssemblyCopyright");
        string Version = resourceManager.GetString("AssemblyVersion");


        [assembly: AssemblyTitle(Title)]
        [assembly: AssemblyDescription(Description)]
        [assembly: AssemblyConfiguration("")]
        [assembly: AssemblyCompany(Company)]
        [assembly: AssemblyProduct(Product)]
        [assembly: AssemblyCopyright(Copyright)]
        [assembly: AssemblyTrademark("")]
        [assembly: AssemblyCulture("")]


        [assembly: AssemblyVersion(Version)]
        [assembly: AssemblyFileVersion("0.74")]
    }

Если у кого-то есть идеи, как это сделать, пожалуйста, напишите

РЕДАКТИРОВАТЬ: Debug:

Error: Expected class, delegate, enum, interface, or struct
6
Error: Expected class, delegate, enum, interface, or struct
8
Error: Assembly and module attributes must precede all other elements defined in a file except        using clauses and extern alias declarations
17
Error: Assembly and module attributes must precede all other elements defined in a file except using clauses and extern alias declarations
18
Error: Assembly and module attributes must precede all other elements defined in a file except using clauses and extern alias declarations
19
Error: Assembly and module attributes must precede all other elements defined in a file except   using clauses and extern alias declarations
20
Error: Assembly and module attributes must precede all other elements defined in a file except using clauses and extern alias declarations
21
Error: Assembly and module attributes must precede all other elements defined in a file except using clauses and extern alias declarations
22
Error: Assembly and module attributes must precede all other elements defined in a file except using clauses and extern alias declarations
23
Error: Assembly and module attributes must precede all other elements defined in a file except using clauses and extern alias declarations
24
Error: Assembly and module attributes must precede all other elements defined in a file except using clauses and extern alias declarations
26
Error: Assembly and module attributes must precede all other elements defined in a file except using clauses and extern alias declarations
29
Error: Assembly and module attributes must precede all other elements defined in a file except using clauses and extern alias declarations
31
Error: Assembly and module attributes must precede all other elements defined in a file except using clauses and extern alias declarations
32
Error: Type or namespace definition, or end-of-file expected
33

0 ответов

Другие вопросы по тегам