Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / Configuration / GacUtil.cs / 1305376 / 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
- XPathItem.cs
- SqlDataSource.cs
- sqlpipe.cs
- HtmlInputSubmit.cs
- HttpCapabilitiesEvaluator.cs
- IndexOutOfRangeException.cs
- Module.cs
- IPeerNeighbor.cs
- TreeViewCancelEvent.cs
- UntypedNullExpression.cs
- XPathParser.cs
- InternalResources.cs
- SQLCharsStorage.cs
- TextureBrush.cs
- ComponentEditorForm.cs
- ScriptManager.cs
- StringHandle.cs
- _AutoWebProxyScriptWrapper.cs
- AutomationIdentifierGuids.cs
- NetSectionGroup.cs
- RMEnrollmentPage3.cs
- LockedHandleGlyph.cs
- StyleSheetDesigner.cs
- TemplateBaseAction.cs
- ChannelPoolSettingsElement.cs
- StatusBarDrawItemEvent.cs
- CodeDirectoryCompiler.cs
- XPathNavigator.cs
- SerialErrors.cs
- EditorPartCollection.cs
- DiscoveryDocument.cs
- EventLogPermissionAttribute.cs
- DataStreamFromComStream.cs
- EntityDataReader.cs
- BinaryFormatterWriter.cs
- OrderByQueryOptionExpression.cs
- BitmapEffectDrawingContextState.cs
- CodeVariableReferenceExpression.cs
- GridItemCollection.cs
- TreeNodeCollection.cs
- GuidelineCollection.cs
- EnumerableCollectionView.cs
- X509ChainElement.cs
- Schema.cs
- KeyedHashAlgorithm.cs
- WorkflowWebService.cs
- ProfileProvider.cs
- DbInsertCommandTree.cs
- ListBox.cs
- unsafenativemethodstextservices.cs
- FixedDocument.cs
- EdmEntityTypeAttribute.cs
- JulianCalendar.cs
- DataBinder.cs
- StdValidatorsAndConverters.cs
- XmlAnyElementAttribute.cs
- SqlOuterApplyReducer.cs
- DropTarget.cs
- StatusBarDrawItemEvent.cs
- DecoderNLS.cs
- CFGGrammar.cs
- RawStylusInputCustomData.cs
- MimeWriter.cs
- GroupBoxRenderer.cs
- MailWebEventProvider.cs
- PrincipalPermission.cs
- AllMembershipCondition.cs
- WhiteSpaceTrimStringConverter.cs
- ExpandCollapsePattern.cs
- WebControl.cs
- BamlTreeNode.cs
- AbstractSvcMapFileLoader.cs
- Pkcs7Signer.cs
- DateTimeOffset.cs
- MappedMetaModel.cs
- Column.cs
- PersonalizationProviderHelper.cs
- BitmapCodecInfoInternal.cs
- TypeCollectionPropertyEditor.cs
- PropertyTab.cs
- ActivityCodeDomSerializationManager.cs
- StorageInfo.cs
- SessionStateSection.cs
- DateTimeConverter2.cs
- MenuBindingsEditorForm.cs
- XmlDocumentViewSchema.cs
- ResXFileRef.cs
- WebServiceData.cs
- GlyphRun.cs
- ListControl.cs
- ReadOnlyDataSource.cs
- DbSetClause.cs
- LinkUtilities.cs
- SqlReferenceCollection.cs
- InkCanvas.cs
- GetRecipientRequest.cs
- SerializerDescriptor.cs
- CatalogPart.cs
- MenuItemBindingCollection.cs
- CodeMemberMethod.cs