Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- ReflectionPermission.cs
- SecurityHelper.cs
- CodeMemberMethod.cs
- NumericUpDownAccelerationCollection.cs
- Environment.cs
- BypassElementCollection.cs
- AttributedMetaModel.cs
- EditModeSwitchButton.cs
- Viewport3DVisual.cs
- TextDpi.cs
- ReliabilityContractAttribute.cs
- ReadOnlyDictionary.cs
- PropertyRecord.cs
- InkCanvasSelection.cs
- Accessible.cs
- Compiler.cs
- QuaternionRotation3D.cs
- CurrentTimeZone.cs
- GridView.cs
- SizeValueSerializer.cs
- GlyphRunDrawing.cs
- DispatcherHookEventArgs.cs
- WebPartConnectionCollection.cs
- TransactionScope.cs
- TileBrush.cs
- CodeGeneratorOptions.cs
- TextRangeBase.cs
- XmlSchemaSequence.cs
- AnimatedTypeHelpers.cs
- HttpStreamXmlDictionaryWriter.cs
- SoapAttributes.cs
- GridViewUpdatedEventArgs.cs
- DocumentPageHost.cs
- RangeValidator.cs
- RSAPKCS1KeyExchangeFormatter.cs
- MenuScrollingVisibilityConverter.cs
- TCEAdapterGenerator.cs
- ArgumentsParser.cs
- BitmapCacheBrush.cs
- EncoderExceptionFallback.cs
- MessageQueueCriteria.cs
- SqlGenericUtil.cs
- ViewStateModeByIdAttribute.cs
- FlatButtonAppearance.cs
- ListenerPerfCounters.cs
- SmiContext.cs
- PartialCachingControl.cs
- recordstate.cs
- TraceUtility.cs
- Rotation3D.cs
- control.ime.cs
- Calendar.cs
- Qualifier.cs
- odbcmetadatacolumnnames.cs
- ArrayListCollectionBase.cs
- DataGridToolTip.cs
- WindowsListViewItemCheckBox.cs
- CompilationSection.cs
- DispatcherSynchronizationContext.cs
- AnnotationAdorner.cs
- CompoundFileStreamReference.cs
- Material.cs
- ScalarOps.cs
- MatrixTransform3D.cs
- PathFigure.cs
- SortQuery.cs
- TcpServerChannel.cs
- EventPrivateKey.cs
- XmlDigitalSignatureProcessor.cs
- HttpDebugHandler.cs
- SAPICategories.cs
- WindowsListViewSubItem.cs
- ResolveMatchesCD1.cs
- Random.cs
- DataColumnPropertyDescriptor.cs
- EdmFunctions.cs
- Animatable.cs
- ProxyWebPartConnectionCollection.cs
- SafeMILHandleMemoryPressure.cs
- XmlSchemaCompilationSettings.cs
- ProcessHost.cs
- FixedSOMSemanticBox.cs
- ReferencedCollectionType.cs
- HostedHttpContext.cs
- ValueType.cs
- Constraint.cs
- AppLevelCompilationSectionCache.cs
- Package.cs
- XmlSchemaSimpleContent.cs
- DataGridViewColumnEventArgs.cs
- XmlSchemaAttributeGroup.cs
- WriteFileContext.cs
- NotificationContext.cs
- ImageClickEventArgs.cs
- ZoneMembershipCondition.cs
- HideDisabledControlAdapter.cs
- StandardToolWindows.cs
- ProcessHostServerConfig.cs
- ECDiffieHellman.cs
- SystemIPv6InterfaceProperties.cs