Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / xsp / System / Web / Configuration / GacUtil.cs / 1 / GacUtil.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Configuration { using System.Web.Configuration; using System.Runtime.InteropServices; using System.Security.Permissions; /* class for installing ASP.BrowserCapabilitiesFactory into gac */ internal sealed class GacUtil : IGac { [SecurityPermission(SecurityAction.Demand, UnmanagedCode = true)] public void GacInstall(string assemblyPath) { #if !FEATURE_PAL IAssemblyCache ac = null; int hr = NativeMethods.CreateAssemblyCache(out ac, 0); if (0 == hr) hr = ac.InstallAssembly(0, assemblyPath, IntPtr.Zero); #else // !FEATURE_PAL int hr = -1; try { Process gacutilprocess = new System.Diagnostics.Process(); if (gacutilprocess != null) { gacutilprocess.StartInfo.CreateNoWindow = true; #if PLATFORM_UNIX gacutilprocess.StartInfo.FileName = "gacutil"; #else gacutilprocess.StartInfo.FileName = "gacutil.exe"; #endif gacutilprocess.StartInfo.UseShellExecute = false; gacutilprocess.StartInfo.Arguments = "/i " + assemblyPath; gacutilprocess.Start(); while (!gacutilprocess.HasExited) { Thread.Sleep(250); } hr = gacutilprocess.ExitCode; } } catch (Exception) { hr = -1; } #endif // FEATURE_PAL if (0 != hr) { throw new Exception(SR.GetString(SR.Failed_gac_install)); } } [SecurityPermission(SecurityAction.Demand, UnmanagedCode = true)] public bool GacUnInstall(string assemblyName) { IAssemblyCache ac = null; uint position = 0; int hr = NativeMethods.CreateAssemblyCache(out ac, 0); if (0 == hr) { hr = ac.UninstallAssembly(0, assemblyName, IntPtr.Zero, out position); if (position == 3 /*IASSEMBLYCACHE_UNINSTALL_DISPOSITION_ALREADY_UNINSTALLED*/) { return false; } } if (0 != hr) { throw new Exception(SR.GetString(SR.Failed_gac_uninstall)); } return true; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Configuration { using System.Web.Configuration; using System.Runtime.InteropServices; using System.Security.Permissions; /* class for installing ASP.BrowserCapabilitiesFactory into gac */ internal sealed class GacUtil : IGac { [SecurityPermission(SecurityAction.Demand, UnmanagedCode = true)] public void GacInstall(string assemblyPath) { #if !FEATURE_PAL IAssemblyCache ac = null; int hr = NativeMethods.CreateAssemblyCache(out ac, 0); if (0 == hr) hr = ac.InstallAssembly(0, assemblyPath, IntPtr.Zero); #else // !FEATURE_PAL int hr = -1; try { Process gacutilprocess = new System.Diagnostics.Process(); if (gacutilprocess != null) { gacutilprocess.StartInfo.CreateNoWindow = true; #if PLATFORM_UNIX gacutilprocess.StartInfo.FileName = "gacutil"; #else gacutilprocess.StartInfo.FileName = "gacutil.exe"; #endif gacutilprocess.StartInfo.UseShellExecute = false; gacutilprocess.StartInfo.Arguments = "/i " + assemblyPath; gacutilprocess.Start(); while (!gacutilprocess.HasExited) { Thread.Sleep(250); } hr = gacutilprocess.ExitCode; } } catch (Exception) { hr = -1; } #endif // FEATURE_PAL if (0 != hr) { throw new Exception(SR.GetString(SR.Failed_gac_install)); } } [SecurityPermission(SecurityAction.Demand, UnmanagedCode = true)] public bool GacUnInstall(string assemblyName) { IAssemblyCache ac = null; uint position = 0; int hr = NativeMethods.CreateAssemblyCache(out ac, 0); if (0 == hr) { hr = ac.UninstallAssembly(0, assemblyName, IntPtr.Zero, out position); if (position == 3 /*IASSEMBLYCACHE_UNINSTALL_DISPOSITION_ALREADY_UNINSTALLED*/) { return false; } } if (0 != hr) { throw new Exception(SR.GetString(SR.Failed_gac_uninstall)); } return true; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- LicenseProviderAttribute.cs
- IndexedEnumerable.cs
- validationstate.cs
- FileSecurity.cs
- _LocalDataStoreMgr.cs
- ControlTemplate.cs
- FormViewUpdatedEventArgs.cs
- DataSourceHelper.cs
- ModelVisual3D.cs
- ValuePatternIdentifiers.cs
- XmlCompatibilityReader.cs
- Link.cs
- DataGridViewCellValidatingEventArgs.cs
- CharacterMetrics.cs
- ByteStorage.cs
- Menu.cs
- PerformanceCounter.cs
- PreservationFileWriter.cs
- DataSourceProvider.cs
- DataGridDefaultColumnWidthTypeConverter.cs
- SecurityBindingElement.cs
- HttpErrorTraceRecord.cs
- IODescriptionAttribute.cs
- StylusCaptureWithinProperty.cs
- ScriptBehaviorDescriptor.cs
- WebBrowserBase.cs
- RuntimeConfigLKG.cs
- MatrixTransform3D.cs
- SBCSCodePageEncoding.cs
- GradientStop.cs
- Slider.cs
- SymmetricAlgorithm.cs
- DelegatedStream.cs
- DataFormats.cs
- KeyPullup.cs
- IDispatchConstantAttribute.cs
- DynamicAttribute.cs
- ToolZone.cs
- DecimalAnimationUsingKeyFrames.cs
- SqlError.cs
- InheritedPropertyChangedEventArgs.cs
- SByteConverter.cs
- Icon.cs
- SqlInternalConnectionSmi.cs
- DescendentsWalkerBase.cs
- DataGridViewColumnStateChangedEventArgs.cs
- TextTreeUndoUnit.cs
- ProcessingInstructionAction.cs
- QueryCursorEventArgs.cs
- StringFreezingAttribute.cs
- CssStyleCollection.cs
- Types.cs
- EncodingInfo.cs
- CustomWebEventKey.cs
- ProviderMetadata.cs
- ConnectionConsumerAttribute.cs
- SecurityRuntime.cs
- OdbcRowUpdatingEvent.cs
- webclient.cs
- BaseResourcesBuildProvider.cs
- UpdateTracker.cs
- PathGeometry.cs
- BamlVersionHeader.cs
- MemberPathMap.cs
- SqlInternalConnectionSmi.cs
- SqlMethodAttribute.cs
- MachineKeySection.cs
- Propagator.JoinPropagator.cs
- ValidationSummary.cs
- CustomErrorsSection.cs
- CompareValidator.cs
- ColumnMapVisitor.cs
- DockPattern.cs
- KoreanLunisolarCalendar.cs
- SqlServer2KCompatibilityCheck.cs
- ReflectionTypeLoadException.cs
- HtmlInputPassword.cs
- SqlProcedureAttribute.cs
- SecondaryViewProvider.cs
- IssuedTokenClientBehaviorsElement.cs
- C14NUtil.cs
- ItemCheckEvent.cs
- WindowsProgressbar.cs
- RequestBringIntoViewEventArgs.cs
- SymmetricCryptoHandle.cs
- ConstNode.cs
- WebServiceErrorEvent.cs
- FormsAuthenticationEventArgs.cs
- DoubleCollection.cs
- XmlSchemaGroupRef.cs
- SByte.cs
- HttpResponse.cs
- ListenerAdapter.cs
- TextBoxLine.cs
- ImageKeyConverter.cs
- ActivationWorker.cs
- ListSortDescription.cs
- HMACSHA512.cs
- ReachSerializationUtils.cs
- XmlDataLoader.cs