Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Framework / MS / Internal / AppModel / DeploymentExceptionMapper.cs / 2 / DeploymentExceptionMapper.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // Description: DeploymentExceptionMapper class definition. // // History: // 2005/02/08 : [....] - Created // 2005/08/22 : [....] - Added boot WinFX functionality // 2007/08/01 : [....] - Added detection of System.Core.dll to infer required platform version. // Because WPF v3.5 still has WindowsBase v3.0.0.0, the original heuristic failed. // //--------------------------------------------------------------------------- using System; using System.Collections; using System.Globalization; using System.Resources; using System.Reflection; using System.Windows; using System.Deployment.Application; namespace MS.Internal { internal enum MissingDependencyType { Others = 0, WinFX = 1, CLR = 2 } internal static class DeploymentExceptionMapper { // This is the hardcoded fwlink query parameters, the only dynamic data we pass to fwlink server // is the WinFX or CLR version we parse from the ClickOnce error message. // Product ID is always 11953 which is the WinFX Runtime Components and subproduct is always bootwinfx // The winfxsetup.exe is language neutral so we always specify 0x409 for languages. const string fwlinkPrefix = "http://go.microsoft.com/fwlink?prd=11953&sbp=Bootwinfx&pver="; const string fwlinkSuffix = "&plcid=0x409&clcid=0x409&"; //----------------------------------------------------- // // Internal Methods // //----------------------------------------------------- #region Internal Methods // Check if the platform exception is due to missing WinFX or CLR dependency // Parse the exception message and find out the dependent WinFX version and create the // corresponding fwlink Uri. static internal MissingDependencyType GetWinFXRequirement(Exception e, InPlaceHostingManager hostingManager, out string version, out Uri fwlinkUri) { version = String.Empty; fwlinkUri = null; // Load the clickonce resource and use it to parse the exception message Assembly deploymentDll = Assembly.GetAssembly(hostingManager.GetType()); if (deploymentDll == null) { return MissingDependencyType.Others; } ResourceManager resourceManager = new ResourceManager("System.Deployment", deploymentDll); if (resourceManager == null) { return MissingDependencyType.Others; } String clrProductName = resourceManager.GetString("PlatformMicrosoftCommonLanguageRuntime", CultureInfo.CurrentUICulture); String versionString = resourceManager.GetString("PlatformDependentAssemblyVersion", CultureInfo.CurrentUICulture); if ((clrProductName == null) || (versionString == null)) { return MissingDependencyType.Others; } // Need to trim off the parameters in the ClickOnce strings: // "{0} Version {1}" -> "Version" // "Microsoft Common Language Runtime Version {0}" -> "Microsoft Common Language Runtime Version" clrProductName = clrProductName.Replace("{0}", ""); versionString = versionString.Replace("{0}", ""); versionString = versionString.Replace("{1}", ""); const string baseAssemblyName = "WindowsBase"; // A reference to System.Core is what makes an application target .NET v3.5. // Because WindowsBase still has v3.0.0.0, it's not the one that fails the platform requirements // test when a v3.5 app is run on the v3 runtime. (This additional check added for v3 SP1.) const string newSentinelAssemblyName = "System.Core"; // Parse the required version and trim it to major and minor only string excpMsg = e.Message; int index = excpMsg.IndexOf(versionString, StringComparison.Ordinal); if (index != -1) { // ClickOnce exception message is ErrorMessage_Platform* // from clickonce/system.deployment.txt version = String.Copy(excpMsg.Substring(index + versionString.Length)); int indexToFirstDot = version.IndexOf(".", StringComparison.Ordinal); int indexToSecondDot = version.IndexOf(".", indexToFirstDot+1, StringComparison.Ordinal); // Defense in depth here in case Avalon change the version scheme to major + minor only // and we might never see the second dot if (indexToSecondDot != -1) { version = version.Substring(0, indexToSecondDot); } if (excpMsg.IndexOf(clrProductName, StringComparison.Ordinal) != -1) { // prepend CLR to distinguish CLR version fwlink query // vs. WinFX version query. string clrVersion = String.Concat("CLR", version); return (ConstructFwlinkUrl(clrVersion, out fwlinkUri) ? MissingDependencyType.CLR : MissingDependencyType.Others); } else if (excpMsg.IndexOf(baseAssemblyName, StringComparison.Ordinal) == -1 && excpMsg.IndexOf(newSentinelAssemblyName, StringComparison.Ordinal) == -1) { version = String.Empty; } } return (ConstructFwlinkUrl(version, out fwlinkUri) ? MissingDependencyType.WinFX : MissingDependencyType.Others); } static internal void GetErrorTextFromException(Exception e, out string errorTitle, out string errorMessage) { errorTitle = String.Empty; errorMessage = String.Empty; if (e == null) { errorTitle = SR.Get(SRID.CancelledTitle); errorMessage = SR.Get(SRID.CancelledText); } else if (e is DependentPlatformMissingException) { errorTitle = SR.Get(SRID.PlatformRequirementTitle); errorMessage = e.Message; } else if (e is InvalidDeploymentException) { errorTitle = SR.Get(SRID.InvalidDeployTitle); errorMessage = SR.Get(SRID.InvalidDeployText); } else if (e is TrustNotGrantedException) { errorTitle = SR.Get(SRID.TrustNotGrantedTitle); errorMessage = SR.Get(SRID.TrustNotGrantedText); } else if (e is DeploymentDownloadException) { errorTitle = SR.Get(SRID.DownloadTitle); errorMessage = SR.Get(SRID.DownloadText); } else if (e is DeploymentException) { errorTitle = SR.Get(SRID.DeployTitle); errorMessage = SR.Get(SRID.DeployText); } else { errorTitle = SR.Get(SRID.UnknownErrorTitle); errorMessage = SR.Get(SRID.UnknownErrorText) + "\n\n" + e.Message; } } static internal bool ConstructFwlinkUrl(string version, out Uri fwlinkUri) { string fwlink = String.Empty; fwlinkUri = null; if (version != String.Empty) { fwlink = String.Copy(fwlinkPrefix); fwlink = String.Concat(fwlink, version); fwlink = String.Concat(fwlink, fwlinkSuffix); // Mitigate against proxy server caching, append today's day to the fwlink // query. This matches the fwlink query from unmanaged bootwap functionality // in IE7. DateTime today = System.DateTime.Today; fwlink = String.Concat(fwlink, today.Year.ToString()); fwlink = String.Concat(fwlink, today.Month.ToString()); fwlink = String.Concat(fwlink, today.Day.ToString()); fwlinkUri = new Uri(fwlink); return true; } return false; } #endregion } } // 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
- RoleService.cs
- FuncTypeConverter.cs
- DecryptedHeader.cs
- CodeDomSerializerBase.cs
- Grammar.cs
- WebBrowserHelper.cs
- PersonalizationAdministration.cs
- StateBag.cs
- ReadOnlyDictionary.cs
- DocumentViewerBase.cs
- XmlDictionary.cs
- KnowledgeBase.cs
- TextFormatterImp.cs
- UpnEndpointIdentityExtension.cs
- FixedSOMTableCell.cs
- ProfilePropertySettingsCollection.cs
- LazyTextWriterCreator.cs
- SaveFileDialog.cs
- TabletDevice.cs
- InternalCache.cs
- ExeConfigurationFileMap.cs
- HitTestDrawingContextWalker.cs
- DbConvert.cs
- MenuBase.cs
- ResizeGrip.cs
- FusionWrap.cs
- OdbcDataReader.cs
- AuthorizationRuleCollection.cs
- OleDbParameterCollection.cs
- DataException.cs
- Math.cs
- PasswordRecovery.cs
- InstanceStoreQueryResult.cs
- Lock.cs
- ChangeTracker.cs
- SiteMapNode.cs
- unsafenativemethodstextservices.cs
- BuildManagerHost.cs
- SwitchElementsCollection.cs
- ExceptionHandlers.cs
- SQLGuidStorage.cs
- CalendarTable.cs
- SymbolMethod.cs
- WebResponse.cs
- CopyOfAction.cs
- TableCellCollection.cs
- XPathDescendantIterator.cs
- WorkflowQueuingService.cs
- ScrollChangedEventArgs.cs
- TextureBrush.cs
- ResourceReader.cs
- GlobalizationSection.cs
- SafeFindHandle.cs
- CompileXomlTask.cs
- EntityClassGenerator.cs
- GradientStop.cs
- Config.cs
- Model3D.cs
- DbConnectionClosed.cs
- BinaryConverter.cs
- DBConcurrencyException.cs
- ResourceDescriptionAttribute.cs
- CategoryState.cs
- Line.cs
- TabOrder.cs
- UserNameSecurityToken.cs
- Bezier.cs
- CryptoApi.cs
- dataprotectionpermission.cs
- GiveFeedbackEvent.cs
- ToolStripItem.cs
- MessagePartSpecification.cs
- _ConnectStream.cs
- Rfc2898DeriveBytes.cs
- XPathChildIterator.cs
- ModifyActivitiesPropertyDescriptor.cs
- DSACryptoServiceProvider.cs
- DataGrid.cs
- StringUtil.cs
- RepeaterItemCollection.cs
- WaveHeader.cs
- ServiceModelInstallComponent.cs
- XmlAutoDetectWriter.cs
- MarkerProperties.cs
- IncrementalCompileAnalyzer.cs
- DataGridViewColumnHeaderCell.cs
- QueryOpeningEnumerator.cs
- Types.cs
- Geometry3D.cs
- XNameTypeConverter.cs
- WebBrowser.cs
- BitmapSizeOptions.cs
- WindowsTab.cs
- securitycriticaldata.cs
- KnownBoxes.cs
- LinkButton.cs
- CacheChildrenQuery.cs
- Size3D.cs
- TriggerBase.cs
- SoapFault.cs