Exemple #1
0
    public int QueryAssemblyInfo(uint dwFlags, [MarshalAs(UnmanagedType.LPWStr)] string pszAssemblyName, ref AssemblyName.ASSEMBLY_INFO pAsmInfo)
    {
        pAsmInfo = new AssemblyName.ASSEMBLY_INFO();
        pAsmInfo.cbAssemblyInfo = 1;                    // just needs to be nonzero for our purposes

        // All they need here is pszCurrentAssemblyPathBuf to be filled out.
        // pszAssemblyName is the strong name (as returned from MonoAssemblyName.GetDisplayName),
        // like "System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
        //
        // Mono stores them in monoDir\lib\mono\gac\ASSEMBLY_NAME\VERSION__PUBLICKEYTOKEN\ASSEMBLY_NAME.dll
        //
        // .. so this strong name  : "System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
        // .. would be located here: monoDir\lib\mono\gac\System.Core\4.0.0.0__b77a5c561934e089\System.Core.dll
        string [] parts = pszAssemblyName.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries);

        string sAssemblyName   = parts[0];
        string sVersion        = parts[1].Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries)[1];
        string sPublicKeyToken = parts[3].Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries)[1];

        string sGACDir = MonoGACHelpers.GetGACDir();

        sGACDir = Path.Combine(sGACDir, sAssemblyName);
        sGACDir = Path.Combine(sGACDir, sVersion + "__" + sPublicKeyToken);

        pAsmInfo.pszCurrentAssemblyPathBuf = Path.Combine(sGACDir, sAssemblyName + ".dll");

        Debug.Assert(false);
        return(0);
    }
Exemple #2
0
    public MonoAssemblyEnum()
    {
        string binDir = MonoGACHelpers.GetGACDir();

        binDir = Path.GetDirectoryName(binDir);
        binDir = Path.GetDirectoryName(binDir);
        binDir = Path.GetDirectoryName(binDir);

        // Run gacutil to get the list.
        ProcessStartInfo info = new ProcessStartInfo();

        info.UseShellExecute        = false;
        info.RedirectStandardOutput = true;

        if ((int)Environment.OSVersion.Platform == 4 || (int)Environment.OSVersion.Platform == 128)
        {
            // Running under Unix.
            info.FileName  = "gacutil";
            info.Arguments = "-l";
        }
        else
        {
            // Running under Windows.
            info.FileName  = "cmd.exe";
            info.Arguments = "/C \"" + Path.Combine(Path.Combine(binDir, "bin"), "gacutil.bat") + "\" -l";
        }

        Process p       = Process.Start(info);
        string  sOutput = p.StandardOutput.ReadToEnd();

        p.Close();

        string [] lines = sOutput.Split(new char[] { '\n' });
        m_Names = new MonoAssemblyName[lines.Length - 3];
        for (int i = 1; i < lines.Length - 2; i++)
        {
            string    sLine           = lines[i].Replace("\r", "");
            string [] parts           = sLine.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
            string    sAssemblyName   = parts[0];
            string    sVersion        = parts[1].Split(new char[] { '=' })[1];
            string    sCulture        = parts[2].Split(new char[] { '=' })[1];
            string    sPublicKeyToken = parts[3].Split(new char[] { '=' })[1];

            m_Names[i - 1] = new MonoAssemblyName(sAssemblyName, sVersion, sCulture, sPublicKeyToken, sLine);
        }

        m_nCurrentName = 0;
    }