Error.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //-----------------------------------------------------------------------------
  4. namespace System.ServiceModel.ComIntegration
  5. {
  6. using System;
  7. using System.ServiceModel.Channels;
  8. using System.ServiceModel;
  9. using System.ServiceModel.Description;
  10. using System.Globalization;
  11. using System.Runtime.Serialization;
  12. using System.Runtime.InteropServices;
  13. using System.ComponentModel;
  14. static class Error
  15. {
  16. const string FaultNamespace = System.ServiceModel.FaultException.Namespace;
  17. public static Exception ActivationAccessDenied()
  18. {
  19. return CreateFault("ComActivationAccessDenied",
  20. SR.GetString(SR.ComActivationAccessDenied));
  21. }
  22. public static Exception QFENotPresent()
  23. {
  24. return CreateFault("ServiceHostStartingServiceErrorNoQFE",
  25. SR.GetString(SR.ComPlusServiceHostStartingServiceErrorNoQFE));
  26. }
  27. public static Exception DirectoryNotFound(string directory)
  28. {
  29. return CreateFault("DirectoryNotFound",
  30. SR.GetString(SR.TempDirectoryNotFound, directory));
  31. }
  32. public static Exception CannotAccessDirectory(string directory)
  33. {
  34. return CreateFault("CannotAccessDirectory",
  35. SR.GetString(SR.CannotAccessDirectory, directory));
  36. }
  37. public static Exception ManifestCreationFailed(string file, string error)
  38. {
  39. return CreateFault("ManifestCreationFailed",
  40. SR.GetString(SR.ComIntegrationManifestCreationFailed, file, error));
  41. }
  42. public static Exception ActivationFailure()
  43. {
  44. return CreateFault("ComActivationFailure",
  45. SR.GetString(SR.ComActivationFailure));
  46. }
  47. public static Exception UnexpectedThreadingModel()
  48. {
  49. return CreateFault("UnexpectedThreadingModel",
  50. SR.GetString(SR.UnexpectedThreadingModel));
  51. }
  52. public static Exception DllHostInitializerFoundNoServices()
  53. {
  54. return CreateFault("DllHostInitializerFoundNoServices",
  55. SR.GetString(SR.ComDllHostInitializerFoundNoServices));
  56. }
  57. public static Exception ServiceMonikerSupportLoadFailed(string dllname)
  58. {
  59. return CreateFault("UnableToLoadServiceMonikerSupportDll",
  60. SR.GetString(SR.UnableToLoadDll, dllname));
  61. }
  62. public static Exception CallAccessDenied()
  63. {
  64. return CreateFault("ComAccessDenied",
  65. SR.GetString(SR.ComMessageAccessDenied));
  66. }
  67. public static Exception RequiresWindowsSecurity()
  68. {
  69. return CreateFault("ComWindowsIdentityRequired",
  70. SR.GetString(SR.ComRequiresWindowsSecurity));
  71. }
  72. public static Exception NoAsyncOperationsAllowed()
  73. {
  74. return CreateFault("NoAsyncOperationsAllowed",
  75. SR.GetString(SR.ComNoAsyncOperationsAllowed));
  76. }
  77. public static Exception DuplicateOperation()
  78. {
  79. return CreateFault("DuplicateOperation",
  80. SR.GetString(SR.ComDuplicateOperation));
  81. }
  82. public static Exception InconsistentSessionRequirements()
  83. {
  84. return CreateFault("ComInconsistentSessionRequirements",
  85. SR.GetString(SR.ComInconsistentSessionRequirements));
  86. }
  87. public static Exception TransactionMismatch()
  88. {
  89. // NOTE: The fault created here is identical to the one
  90. // created by the TransactionBehavior when
  91. // concurrent transactions are not supported.
  92. //
  93. return CreateFault("Transactions",
  94. SR.GetString(SR.SFxTransactionsNotSupported));
  95. }
  96. public static Exception ListenerInitFailed(string message)
  97. {
  98. return new ComPlusListenerInitializationException(message);
  99. }
  100. public static Exception ListenerInitFailed(string message,
  101. Exception inner)
  102. {
  103. return new ComPlusListenerInitializationException(message, inner);
  104. }
  105. static Exception CreateFault(string code, string reason)
  106. {
  107. FaultCode codeObj = FaultCode.CreateSenderFaultCode(code, FaultNamespace);
  108. FaultReason reasonObj = new FaultReason(reason, CultureInfo.CurrentCulture);
  109. return new FaultException(reasonObj, codeObj);
  110. }
  111. }
  112. [Serializable]
  113. internal class ComPlusListenerInitializationException : Exception
  114. {
  115. public ComPlusListenerInitializationException()
  116. : base()
  117. {
  118. }
  119. public ComPlusListenerInitializationException(string message)
  120. : base(message)
  121. {
  122. }
  123. public ComPlusListenerInitializationException(string message,
  124. Exception inner)
  125. : base(message, inner)
  126. {
  127. }
  128. protected ComPlusListenerInitializationException(SerializationInfo info, StreamingContext context)
  129. : base(info, context)
  130. {
  131. }
  132. }
  133. [Serializable]
  134. internal class ComPlusProxyProviderException : Exception
  135. {
  136. public ComPlusProxyProviderException(string message, Exception inner)
  137. : base(message, inner)
  138. {
  139. }
  140. }
  141. }