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
- XPathSingletonIterator.cs
- FakeModelItemImpl.cs
- ObfuscateAssemblyAttribute.cs
- MethodCallTranslator.cs
- StringFormat.cs
- CompiledQueryCacheEntry.cs
- TextWriter.cs
- PopupControlService.cs
- GetIndexBinder.cs
- RoutedEventConverter.cs
- ValidationVisibilityAttribute.cs
- Message.cs
- SkewTransform.cs
- AnyReturnReader.cs
- SQLMembershipProvider.cs
- WorkflowTransactionOptions.cs
- HGlobalSafeHandle.cs
- DefaultPropertyAttribute.cs
- DecoderBestFitFallback.cs
- Primitive.cs
- CellRelation.cs
- CommandValueSerializer.cs
- SignerInfo.cs
- ListViewDataItem.cs
- ArrayElementGridEntry.cs
- AssemblyResourceLoader.cs
- ExecutedRoutedEventArgs.cs
- Identifier.cs
- DictionarySectionHandler.cs
- FixedSOMTableCell.cs
- ProfileSettings.cs
- ConfigXmlText.cs
- BinaryCommonClasses.cs
- assemblycache.cs
- DesignOnlyAttribute.cs
- ObjectDataSourceChooseMethodsPanel.cs
- XmlTypeAttribute.cs
- HttpCapabilitiesBase.cs
- UrlPath.cs
- Container.cs
- HttpProfileGroupBase.cs
- ScriptResourceHandler.cs
- CaseInsensitiveOrdinalStringComparer.cs
- AddInToken.cs
- DbDataRecord.cs
- COM2PictureConverter.cs
- ServiceEndpointCollection.cs
- BuildProvider.cs
- DesigntimeLicenseContextSerializer.cs
- ProcessRequestArgs.cs
- InternalConfigRoot.cs
- NamespaceQuery.cs
- ShaperBuffers.cs
- MSAAEventDispatcher.cs
- SectionXmlInfo.cs
- AssemblyHash.cs
- VerticalAlignConverter.cs
- AttachedPropertyBrowsableAttribute.cs
- DownloadProgressEventArgs.cs
- OleDbRowUpdatingEvent.cs
- DesignerMetadata.cs
- Vector3DConverter.cs
- StrokeDescriptor.cs
- OdbcFactory.cs
- MethodInfo.cs
- EmbeddedMailObject.cs
- KeyboardDevice.cs
- ProfileModule.cs
- HostedBindingBehavior.cs
- DrawingAttributesDefaultValueFactory.cs
- WebPartCatalogCloseVerb.cs
- SoapProtocolReflector.cs
- MenuItemStyleCollection.cs
- XmlDataSourceView.cs
- RecognizedPhrase.cs
- X509Utils.cs
- NativeMethods.cs
- SessionStateItemCollection.cs
- CustomAttributeBuilder.cs
- ResumeStoryboard.cs
- ClientSettingsStore.cs
- RectKeyFrameCollection.cs
- AppDomainGrammarProxy.cs
- ObjectPersistData.cs
- WebPartManagerDesigner.cs
- ResponseStream.cs
- XPathCompileException.cs
- TreeViewHitTestInfo.cs
- XmlUTF8TextReader.cs
- DynamicDataResources.Designer.cs
- ConstantExpression.cs
- dbdatarecord.cs
- DataGridViewColumnTypePicker.cs
- SqlDataSourceCommandEventArgs.cs
- XamlNamespaceHelper.cs
- TimeSpanValidator.cs
- PageAdapter.cs
- SpecialFolderEnumConverter.cs
- MexHttpBindingElement.cs
- AutomationProperty.cs