Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / DEVDIV / depot / DevDiv / releases / whidbey / QFE / 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. //------------------------------------------------------------------------------ //// 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DrawTreeNodeEventArgs.cs
- MimeTypeMapper.cs
- DuplicateWaitObjectException.cs
- HtmlValidationSummaryAdapter.cs
- BinHexDecoder.cs
- WebControlAdapter.cs
- DiscardableAttribute.cs
- ProcessInfo.cs
- __ConsoleStream.cs
- UseLicense.cs
- OleDbDataAdapter.cs
- Executor.cs
- UnsafeNativeMethodsMilCoreApi.cs
- RepeatInfo.cs
- CodeVariableReferenceExpression.cs
- XmlElementAttribute.cs
- QuadraticEase.cs
- DoubleLink.cs
- MimeFormatExtensions.cs
- BackgroundFormatInfo.cs
- InfoCardMetadataExchangeClient.cs
- LinqDataSourceContextData.cs
- WebProxyScriptElement.cs
- GridProviderWrapper.cs
- ResolveCriteriaCD1.cs
- BamlCollectionHolder.cs
- PackagePart.cs
- PathTooLongException.cs
- DataGridViewCellToolTipTextNeededEventArgs.cs
- EventHandlersStore.cs
- KeyToListMap.cs
- ResXBuildProvider.cs
- WindowsRebar.cs
- EmissiveMaterial.cs
- XmlParserContext.cs
- SHA512Managed.cs
- ComponentDispatcherThread.cs
- OverrideMode.cs
- SmiEventSink.cs
- XPathNodeList.cs
- EventSinkHelperWriter.cs
- OAVariantLib.cs
- Constraint.cs
- CompilerResults.cs
- SimpleType.cs
- FixedFlowMap.cs
- JsonEnumDataContract.cs
- SingleSelectRootGridEntry.cs
- ThreadInterruptedException.cs
- ClientRuntimeConfig.cs
- ServiceDesigner.xaml.cs
- TraceUtility.cs
- XmlMembersMapping.cs
- SoapReflectionImporter.cs
- ToolStripKeyboardHandlingService.cs
- TemplateEditingFrame.cs
- Multiply.cs
- EntityCollection.cs
- RootDesignerSerializerAttribute.cs
- DeviceSpecificChoiceCollection.cs
- GridToolTip.cs
- TypeInfo.cs
- InheritanceContextHelper.cs
- WorkflowNamespace.cs
- CollectionChangeEventArgs.cs
- HtmlTableRow.cs
- FixedElement.cs
- FutureFactory.cs
- XMLUtil.cs
- HtmlInputRadioButton.cs
- ResourceDisplayNameAttribute.cs
- ClipboardData.cs
- _Events.cs
- CapabilitiesState.cs
- RTLAwareMessageBox.cs
- DataBoundControl.cs
- SharedPerformanceCounter.cs
- LocalizedNameDescriptionPair.cs
- DeferredTextReference.cs
- SecurityTraceRecordHelper.cs
- DocobjHost.cs
- ValidationErrorEventArgs.cs
- LinkTarget.cs
- RowToFieldTransformer.cs
- CodeSnippetExpression.cs
- SmtpException.cs
- SqlClientMetaDataCollectionNames.cs
- SqlDependencyUtils.cs
- DbParameterCollectionHelper.cs
- ContainerTracking.cs
- Point3DConverter.cs
- DocumentViewerAutomationPeer.cs
- ListItemParagraph.cs
- KeysConverter.cs
- MethodCallTranslator.cs
- DescendantBaseQuery.cs
- ISAPIApplicationHost.cs
- StaticResourceExtension.cs
- SoapFormatter.cs
- Overlapped.cs