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
- DesignSurface.cs
- PropertyGridCommands.cs
- DoubleLinkList.cs
- DataColumnChangeEvent.cs
- DesignerActionPropertyItem.cs
- EventLogEntryCollection.cs
- DebugView.cs
- ProjectionRewriter.cs
- RightsManagementEncryptionTransform.cs
- StateItem.cs
- TdsValueSetter.cs
- InstanceView.cs
- Keyboard.cs
- SQLBytes.cs
- _ProxyChain.cs
- OutOfMemoryException.cs
- XmlSchemaObjectCollection.cs
- DataObjectSettingDataEventArgs.cs
- SqlRowUpdatingEvent.cs
- Unit.cs
- BitmapSource.cs
- InstanceLockLostException.cs
- ColorInterpolationModeValidation.cs
- WebPartsPersonalizationAuthorization.cs
- RegisteredScript.cs
- mansign.cs
- SlipBehavior.cs
- Screen.cs
- CodeStatement.cs
- LineServicesRun.cs
- SqlBuffer.cs
- ProfileGroupSettings.cs
- ObjectTypeMapping.cs
- XmlSchemaIdentityConstraint.cs
- NestedContainer.cs
- SpecialFolderEnumConverter.cs
- Splitter.cs
- PieceNameHelper.cs
- WebResourceAttribute.cs
- XmlSchemaParticle.cs
- CaseStatementProjectedSlot.cs
- ClassicBorderDecorator.cs
- _Rfc2616CacheValidators.cs
- SmtpReplyReader.cs
- DnsEndPoint.cs
- HtmlInputRadioButton.cs
- FontCacheUtil.cs
- ColumnMap.cs
- ReadOnlyCollection.cs
- TriggerBase.cs
- IsolatedStorageException.cs
- ListViewAutomationPeer.cs
- DbParameterCollection.cs
- SerTrace.cs
- DataGridColumnDropSeparator.cs
- FixedTextBuilder.cs
- AppDomainCompilerProxy.cs
- AudioSignalProblemOccurredEventArgs.cs
- DBDataPermissionAttribute.cs
- XmlChildEnumerator.cs
- DriveInfo.cs
- ClientApiGenerator.cs
- Update.cs
- AnonymousIdentificationSection.cs
- ResourcePart.cs
- WebPartConnectionCollection.cs
- DBAsyncResult.cs
- JournalEntryListConverter.cs
- assertwrapper.cs
- ExpressionBindingCollection.cs
- PingReply.cs
- AutomationAttributeInfo.cs
- QuestionEventArgs.cs
- TimeoutException.cs
- EncoderBestFitFallback.cs
- RelationshipDetailsRow.cs
- ListViewPagedDataSource.cs
- ModelFunctionTypeElement.cs
- Process.cs
- XmlIgnoreAttribute.cs
- ControlIdConverter.cs
- XmlSchemaComplexContent.cs
- _Win32.cs
- SourceFilter.cs
- HotSpotCollection.cs
- FormatPage.cs
- Size3DConverter.cs
- ResourceWriter.cs
- ColumnResult.cs
- ISAPIWorkerRequest.cs
- MultiSelectRootGridEntry.cs
- MonthCalendar.cs
- SyntaxCheck.cs
- DecimalAnimationUsingKeyFrames.cs
- OneOfElement.cs
- TableDetailsRow.cs
- HtmlElementEventArgs.cs
- DbProviderManifest.cs
- ServiceHostingEnvironment.cs
- SqlResolver.cs