コード例 #1
0
 internal static AssemblyInfo QueryAssemblyInfo(System.Deployment.Application.NativeMethods.IAssemblyCache AssemblyCache, QueryAssemblyInfoFlags flags, string assemblyName)
 {
     string str = assemblyName;
     AssemblyInfo info = new AssemblyInfo();
     System.Deployment.Application.NativeMethods.AssemblyInfoInternal assemblyInfo = new System.Deployment.Application.NativeMethods.AssemblyInfoInternal();
     if ((flags & QueryAssemblyInfoFlags.GetCurrentPath) != 0)
     {
         assemblyInfo.cchBuf = 0x400;
         assemblyInfo.currentAssemblyPathBuf = Marshal.AllocHGlobal((int) (assemblyInfo.cchBuf * 2));
     }
     else
     {
         assemblyInfo.cchBuf = 0;
         assemblyInfo.currentAssemblyPathBuf = IntPtr.Zero;
     }
     try
     {
         AssemblyCache.QueryAssemblyInfo((int) flags, str, ref assemblyInfo);
     }
     catch (Exception exception)
     {
         if (ExceptionUtility.IsHardException(exception))
         {
             throw;
         }
         Logger.AddInternalState("Exception thrown : " + exception.GetType().ToString() + ":" + exception.Message);
         info = null;
     }
     if (info != null)
     {
         info.AssemblyInfoSizeInByte = assemblyInfo.cbAssemblyInfo;
         info.AssemblyFlags = (AssemblyInfoFlags) assemblyInfo.assemblyFlags;
         info.AssemblySizeInKB = assemblyInfo.assemblySizeInKB;
         if ((flags & QueryAssemblyInfoFlags.GetCurrentPath) != 0)
         {
             info.CurrentAssemblyPath = Marshal.PtrToStringUni(assemblyInfo.currentAssemblyPathBuf);
             Marshal.FreeHGlobal(assemblyInfo.currentAssemblyPathBuf);
         }
     }
     return info;
 }
コード例 #2
0
        internal static AssemblyInfo QueryAssemblyInfo(System.Deployment.Application.NativeMethods.IAssemblyCache AssemblyCache, QueryAssemblyInfoFlags flags, string assemblyName)
        {
            string       str  = assemblyName;
            AssemblyInfo info = new AssemblyInfo();

            System.Deployment.Application.NativeMethods.AssemblyInfoInternal assemblyInfo = new System.Deployment.Application.NativeMethods.AssemblyInfoInternal();
            if ((flags & QueryAssemblyInfoFlags.GetCurrentPath) != 0)
            {
                assemblyInfo.cchBuf = 0x400;
                assemblyInfo.currentAssemblyPathBuf = Marshal.AllocHGlobal((int)(assemblyInfo.cchBuf * 2));
            }
            else
            {
                assemblyInfo.cchBuf = 0;
                assemblyInfo.currentAssemblyPathBuf = IntPtr.Zero;
            }
            try
            {
                AssemblyCache.QueryAssemblyInfo((int)flags, str, ref assemblyInfo);
            }
            catch (Exception exception)
            {
                if (ExceptionUtility.IsHardException(exception))
                {
                    throw;
                }
                Logger.AddInternalState("Exception thrown : " + exception.GetType().ToString() + ":" + exception.Message);
                info = null;
            }
            if (info != null)
            {
                info.AssemblyInfoSizeInByte = assemblyInfo.cbAssemblyInfo;
                info.AssemblyFlags          = (AssemblyInfoFlags)assemblyInfo.assemblyFlags;
                info.AssemblySizeInKB       = assemblyInfo.assemblySizeInKB;
                if ((flags & QueryAssemblyInfoFlags.GetCurrentPath) != 0)
                {
                    info.CurrentAssemblyPath = Marshal.PtrToStringUni(assemblyInfo.currentAssemblyPathBuf);
                    Marshal.FreeHGlobal(assemblyInfo.currentAssemblyPathBuf);
                }
            }
            return(info);
        }