Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / 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;
}
}
}
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- BlockCollection.cs
- SingleObjectCollection.cs
- SqlClientWrapperSmiStreamChars.cs
- CapabilitiesSection.cs
- querybuilder.cs
- DataObjectFieldAttribute.cs
- PeerInvitationResponse.cs
- xml.cs
- ToolStripRenderer.cs
- ModifiableIteratorCollection.cs
- EntityProxyFactory.cs
- DesignerContextDescriptor.cs
- ConnectionPoint.cs
- CommandExpr.cs
- StoreItemCollection.Loader.cs
- PngBitmapEncoder.cs
- WorkflowServiceHostFactory.cs
- FormViewModeEventArgs.cs
- ObjectManager.cs
- MultipleViewPattern.cs
- PackageRelationship.cs
- EDesignUtil.cs
- EngineSite.cs
- MethodBuilderInstantiation.cs
- CompletionProxy.cs
- BinaryObjectWriter.cs
- PeerInvitationResponse.cs
- XmlValidatingReader.cs
- WindowsComboBox.cs
- Utility.cs
- RelatedImageListAttribute.cs
- AppDomainProtocolHandler.cs
- WorkflowHostingEndpoint.cs
- CryptoKeySecurity.cs
- ContentTextAutomationPeer.cs
- SystemResourceKey.cs
- ExpressionBuilderContext.cs
- Point.cs
- EncodingInfo.cs
- NonParentingControl.cs
- Queue.cs
- ScrollItemProviderWrapper.cs
- TypedReference.cs
- ListViewHitTestInfo.cs
- XAMLParseException.cs
- RawTextInputReport.cs
- DbParameterCollectionHelper.cs
- StaticTextPointer.cs
- WebServiceParameterData.cs
- TypedTableHandler.cs
- HandledEventArgs.cs
- Message.cs
- GraphicsPath.cs
- DuplexChannel.cs
- ConditionalDesigner.cs
- OdbcConnection.cs
- UnsafeMethods.cs
- ColorMatrix.cs
- ProfileBuildProvider.cs
- SessionEndingCancelEventArgs.cs
- ProjectionPath.cs
- WorkflowOperationFault.cs
- HostingEnvironmentWrapper.cs
- SetStoryboardSpeedRatio.cs
- BamlLocalizableResource.cs
- ExpressionNode.cs
- NativeActivityAbortContext.cs
- BrushConverter.cs
- OperationPickerDialog.cs
- DBParameter.cs
- DataGridViewCellLinkedList.cs
- TemplateField.cs
- CompilerResults.cs
- SiteMapNode.cs
- IdentitySection.cs
- PerfCounters.cs
- QueryOperationResponseOfT.cs
- FieldTemplateFactory.cs
- QilInvoke.cs
- PageFunction.cs
- BindingOperations.cs
- ConfigUtil.cs
- RequestCacheManager.cs
- ScriptServiceAttribute.cs
- MeasureData.cs
- OdbcConnectionStringbuilder.cs
- StreamingContext.cs
- HwndSubclass.cs
- StrokeNode.cs
- ReadOnlyAttribute.cs
- ValidationEventArgs.cs
- PersonalizablePropertyEntry.cs
- MultitargetingHelpers.cs
- DataTableCollection.cs
- DocumentPageTextView.cs
- SvcFileManager.cs
- FrameAutomationPeer.cs
- ByteAnimationBase.cs
- Internal.cs
- HandleCollector.cs