سؤال

Below, the method i' ve created is working for registering. But i get: "regasm : warning ra0000 : no types were unregistered" for unregistering.

    private static void ExecuteRegAsm(string comObjectPath, string typeLibraryName, string regAsmPathToExecute, string regAsmParameter = null)
    {
        var startInfo = new ProcessStartInfo
        {
            CreateNoWindow = false,
            UseShellExecute = false,
            FileName = regAsmPathToExecute,
            WindowStyle = ProcessWindowStyle.Hidden
        };

        switch (regAsmParameter)
        {
            case  null:
                startInfo.Arguments = comObjectPath + " /tlb:" + typeLibraryName + " /Codebase";
                break;
            case "/u":
            case "-u":
                startInfo.Arguments = "/u " + comObjectPath;
                break;
        }

        using (var exeProcess = Process.Start(startInfo))
        {
            if (exeProcess != null) exeProcess.WaitForExit();
        }
    }

How to solve this issue?

هل كانت مفيدة؟

المحلول

I' ve solved this issue by adding /tlb: attribute and the type library name of the object as value to the code. Below method is working:

    private static void ExecuteRegAsm(string comObjectPath, string typeLibraryName, string regAsmPathToExecute, string regAsmParameter = null)
    {
        var startInfo = new ProcessStartInfo
        {
            CreateNoWindow = false,
            UseShellExecute = false,
            FileName = regAsmPathToExecute,
            WindowStyle = ProcessWindowStyle.Hidden
        };

        switch (regAsmParameter)
        {
            case  null:
                startInfo.Arguments = comObjectPath + " /tlb:" + typeLibraryName + " /Codebase";
                break;
            case "/u":
            case "-u":
                startInfo.Arguments = comObjectPath + " /tlb:" + typeLibraryName + " /u";
                break;
        }

        using (var exeProcess = Process.Start(startInfo))
        {
            if (exeProcess != null)
            {
                exeProcess.WaitForExit();
            }
        }
    }
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top