Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / clr / src / BCL / System / IO / FileLoadException.cs / 1 / FileLoadException.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: FileLoadException ** ** ** Purpose: Exception for failure to load a file that was successfully found. ** ** ===========================================================*/ using System; using System.Globalization; using System.Runtime.Serialization; using System.Runtime.CompilerServices; using System.Security.Permissions; using SecurityException = System.Security.SecurityException; namespace System.IO { [Serializable] [System.Runtime.InteropServices.ComVisible(true)] public class FileLoadException : IOException { private String _fileName; // the name of the file we could not load. private String _fusionLog; // fusion log (when applicable) public FileLoadException() : base(Environment.GetResourceString("IO.FileLoad")) { SetErrorCode(__HResults.COR_E_FILELOAD); } public FileLoadException(String message) : base(message) { SetErrorCode(__HResults.COR_E_FILELOAD); } public FileLoadException(String message, Exception inner) : base(message, inner) { SetErrorCode(__HResults.COR_E_FILELOAD); } public FileLoadException(String message, String fileName) : base(message) { SetErrorCode(__HResults.COR_E_FILELOAD); _fileName = fileName; } public FileLoadException(String message, String fileName, Exception inner) : base(message, inner) { SetErrorCode(__HResults.COR_E_FILELOAD); _fileName = fileName; } public override String Message { get { SetMessageField(); return _message; } } private void SetMessageField() { if (_message == null) _message = FormatFileLoadExceptionMessage(_fileName, HResult); } public String FileName { get { return _fileName; } } public override String ToString() { String s = GetType().FullName + ": " + Message; if (_fileName != null && _fileName.Length != 0) s += Environment.NewLine + String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("IO.FileName_Name"), _fileName); if (InnerException != null) s = s + " ---> " + InnerException.ToString(); if (StackTrace != null) s += Environment.NewLine + StackTrace; try { if(FusionLog!=null) { if (s==null) s=" "; s+=Environment.NewLine; s+=Environment.NewLine; s+=FusionLog; } } catch(SecurityException) { } return s; } protected FileLoadException(SerializationInfo info, StreamingContext context) : base (info, context) { // Base class constructor will check info != null. _fileName = info.GetString("FileLoad_FileName"); try { _fusionLog = info.GetString("FileLoad_FusionLog"); } catch { _fusionLog = null; } } private FileLoadException(String fileName, String fusionLog,int hResult) : base(null) { SetErrorCode(hResult); _fileName = fileName; _fusionLog=fusionLog; SetMessageField(); } public String FusionLog { [SecurityPermissionAttribute( SecurityAction.Demand, Flags = SecurityPermissionFlag.ControlEvidence | SecurityPermissionFlag.ControlPolicy)] get { return _fusionLog; } } [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.SerializationFormatter)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { // Serialize data for our base classes. base will verify info != null. base.GetObjectData(info, context); // Serialize data for this class info.AddValue("FileLoad_FileName", _fileName, typeof(String)); try { info.AddValue("FileLoad_FusionLog", FusionLog, typeof(String)); } catch (SecurityException) { } } internal static String FormatFileLoadExceptionMessage(String fileName, int hResult) { return String.Format(CultureInfo.CurrentCulture, GetFileLoadExceptionMessage(hResult), fileName, GetMessageForHR(hResult)); } [MethodImplAttribute(MethodImplOptions.InternalCall)] private static extern String GetFileLoadExceptionMessage(int hResult); [MethodImplAttribute(MethodImplOptions.InternalCall)] private static extern String GetMessageForHR(int hresult); } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: FileLoadException ** ** ** Purpose: Exception for failure to load a file that was successfully found. ** ** ===========================================================*/ using System; using System.Globalization; using System.Runtime.Serialization; using System.Runtime.CompilerServices; using System.Security.Permissions; using SecurityException = System.Security.SecurityException; namespace System.IO { [Serializable] [System.Runtime.InteropServices.ComVisible(true)] public class FileLoadException : IOException { private String _fileName; // the name of the file we could not load. private String _fusionLog; // fusion log (when applicable) public FileLoadException() : base(Environment.GetResourceString("IO.FileLoad")) { SetErrorCode(__HResults.COR_E_FILELOAD); } public FileLoadException(String message) : base(message) { SetErrorCode(__HResults.COR_E_FILELOAD); } public FileLoadException(String message, Exception inner) : base(message, inner) { SetErrorCode(__HResults.COR_E_FILELOAD); } public FileLoadException(String message, String fileName) : base(message) { SetErrorCode(__HResults.COR_E_FILELOAD); _fileName = fileName; } public FileLoadException(String message, String fileName, Exception inner) : base(message, inner) { SetErrorCode(__HResults.COR_E_FILELOAD); _fileName = fileName; } public override String Message { get { SetMessageField(); return _message; } } private void SetMessageField() { if (_message == null) _message = FormatFileLoadExceptionMessage(_fileName, HResult); } public String FileName { get { return _fileName; } } public override String ToString() { String s = GetType().FullName + ": " + Message; if (_fileName != null && _fileName.Length != 0) s += Environment.NewLine + String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("IO.FileName_Name"), _fileName); if (InnerException != null) s = s + " ---> " + InnerException.ToString(); if (StackTrace != null) s += Environment.NewLine + StackTrace; try { if(FusionLog!=null) { if (s==null) s=" "; s+=Environment.NewLine; s+=Environment.NewLine; s+=FusionLog; } } catch(SecurityException) { } return s; } protected FileLoadException(SerializationInfo info, StreamingContext context) : base (info, context) { // Base class constructor will check info != null. _fileName = info.GetString("FileLoad_FileName"); try { _fusionLog = info.GetString("FileLoad_FusionLog"); } catch { _fusionLog = null; } } private FileLoadException(String fileName, String fusionLog,int hResult) : base(null) { SetErrorCode(hResult); _fileName = fileName; _fusionLog=fusionLog; SetMessageField(); } public String FusionLog { [SecurityPermissionAttribute( SecurityAction.Demand, Flags = SecurityPermissionFlag.ControlEvidence | SecurityPermissionFlag.ControlPolicy)] get { return _fusionLog; } } [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.SerializationFormatter)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { // Serialize data for our base classes. base will verify info != null. base.GetObjectData(info, context); // Serialize data for this class info.AddValue("FileLoad_FileName", _fileName, typeof(String)); try { info.AddValue("FileLoad_FusionLog", FusionLog, typeof(String)); } catch (SecurityException) { } } internal static String FormatFileLoadExceptionMessage(String fileName, int hResult) { return String.Format(CultureInfo.CurrentCulture, GetFileLoadExceptionMessage(hResult), fileName, GetMessageForHR(hResult)); } [MethodImplAttribute(MethodImplOptions.InternalCall)] private static extern String GetFileLoadExceptionMessage(int hResult); [MethodImplAttribute(MethodImplOptions.InternalCall)] private static extern String GetMessageForHR(int hresult); } } // 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
- HtmlInputImage.cs
- DataRowComparer.cs
- SystemIcons.cs
- EncodingStreamWrapper.cs
- DataGridPagerStyle.cs
- ProxyHwnd.cs
- Context.cs
- COM2TypeInfoProcessor.cs
- BuilderElements.cs
- thaishape.cs
- InheritanceAttribute.cs
- RepeaterItemCollection.cs
- BindStream.cs
- IISMapPath.cs
- UnaryExpressionHelper.cs
- TextEditorSelection.cs
- TextBoxView.cs
- ToolStripPanelCell.cs
- RequestSecurityTokenResponse.cs
- DiscoveryDocumentSerializer.cs
- NameSpaceEvent.cs
- CompositeDispatchFormatter.cs
- ByteAnimationBase.cs
- SqlDataSourceAdvancedOptionsForm.cs
- CallbackValidatorAttribute.cs
- WhitespaceRule.cs
- MetabaseSettingsIis7.cs
- DynamicValidatorEventArgs.cs
- StringValueSerializer.cs
- MetadataHelper.cs
- BackStopAuthenticationModule.cs
- AsymmetricKeyExchangeFormatter.cs
- Int64AnimationBase.cs
- DecimalStorage.cs
- PriorityBinding.cs
- OutputScopeManager.cs
- GridViewHeaderRowPresenter.cs
- HashJoinQueryOperatorEnumerator.cs
- OdbcDataAdapter.cs
- SequentialActivityDesigner.cs
- CachedPathData.cs
- ExceptionTrace.cs
- CodeValidator.cs
- securitycriticaldataClass.cs
- PropertyMetadata.cs
- ISAPIApplicationHost.cs
- SqlFacetAttribute.cs
- TextAnchor.cs
- WebPartCatalogCloseVerb.cs
- PostBackOptions.cs
- SByte.cs
- IDataContractSurrogate.cs
- COAUTHIDENTITY.cs
- TextBoxBase.cs
- XmlNullResolver.cs
- CodeBlockBuilder.cs
- XPathPatternBuilder.cs
- InterleavedZipPartStream.cs
- ZipIORawDataFileBlock.cs
- RtfFormatStack.cs
- DataServiceRequest.cs
- Object.cs
- CodeExporter.cs
- WsdlWriter.cs
- ObjectStateManager.cs
- ISAPIApplicationHost.cs
- TableLayout.cs
- IconBitmapDecoder.cs
- QilTypeChecker.cs
- Translator.cs
- ToolboxItemAttribute.cs
- AssociationTypeEmitter.cs
- StrictModeSecurityHeaderElementInferenceEngine.cs
- odbcmetadatacollectionnames.cs
- metadatamappinghashervisitor.cs
- ParameterReplacerVisitor.cs
- ProgressBarBrushConverter.cs
- TableLayoutPanel.cs
- ProxyHelper.cs
- SchemaNamespaceManager.cs
- XPathSelectionIterator.cs
- DecoratedNameAttribute.cs
- ListView.cs
- InputProviderSite.cs
- HttpListenerTimeoutManager.cs
- RepeaterItemEventArgs.cs
- ObjectViewFactory.cs
- AutomationEvent.cs
- EpmContentSerializerBase.cs
- BuildProvidersCompiler.cs
- OleDbCommandBuilder.cs
- SymbolPair.cs
- wmiprovider.cs
- SchemaObjectWriter.cs
- VisualProxy.cs
- CanonicalizationDriver.cs
- DrawingContext.cs
- ConnectionPoint.cs
- SmtpLoginAuthenticationModule.cs
- TypeLoadException.cs