2007-01-16 Marek Sieradzki <marek.sieradzki@gmail.com>
[mono.git] / mcs / class / Microsoft.Build.Engine / Microsoft.Build.BuildEngine / InternalLoggerException.cs
index 9a35337d9f6b11e04a0c13300751962126920efb..e1b3933a0c12d8bbc0b404cb11b4ebe9bd1ee249 100644 (file)
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
+#if NET_2_0
+
 using System;
 using System.Runtime.Serialization;
+using System.Security.Permissions;
 using Microsoft.Build.Framework;
 
 namespace Microsoft.Build.BuildEngine {
@@ -38,21 +41,33 @@ namespace Microsoft.Build.BuildEngine {
                string          helpKeyword;
                
                public InternalLoggerException ()
-                       : base ("Internal logger exception has occured.")
                {
+                       throw new System.InvalidOperationException (
+                               "An InternalLoggerException can only be thrown by the MSBuild engine. " +
+                               "The public constructors of this class cannot be used to create an " +
+                               "instance of the exception.");
                }
 
                public InternalLoggerException (string message)
-                       : base (message)
+                       : this ()
                {
                }
 
-               public InternalLoggerException (string message,
-                                               Exception innerException)
-                       : base (message, innerException)
+               public InternalLoggerException (string message, Exception innerException)
+                       : this ()
                {
                }
 
+               // FIXME: I made it private temporarily, later we can change it to internal (but not protected)
+               private InternalLoggerException (SerializationInfo info, StreamingContext context)
+                       : base (info, context)
+               {
+                       buildEventArgs = (BuildEventArgs) info.GetValue ("BuildEventArgs", typeof (BuildEventArgs));
+                       errorCode = info.GetString ("ErrorCode");
+                       helpKeyword = info.GetString ("HelpKeywordPrefix");
+               }
+
+               [SecurityPermission (SecurityAction.LinkDemand, SerializationFormatter = true)]
                public override void GetObjectData (SerializationInfo info,
                                                    StreamingContext context)
                {
@@ -81,3 +96,5 @@ namespace Microsoft.Build.BuildEngine {
                }
        }
 }
+
+#endif