From ba63dab225f783d55b7654a15d8031b04cc0a777 Mon Sep 17 00:00:00 2001 From: Andrew Skiba Date: Mon, 3 Jul 2006 15:35:14 +0000 Subject: [PATCH] Throw application-specific exception instead of type-cast svn path=/trunk/mcs/; revision=62231 --- .../System.Web/Test/mainsoft/NunitWeb/NunitWeb/MyHost.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/MyHost.cs b/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/MyHost.cs index 1c9bde4734074..df0e53745b081 100644 --- a/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/MyHost.cs +++ b/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/MyHost.cs @@ -66,7 +66,9 @@ private static HttpWorkerRequest GetMyWorkerRequest () private static MyData GetMyData (HttpWorkerRequest wr) { - IForeignData fd = (IForeignData) wr; + IForeignData fd = wr as IForeignData; + if (fd == null) + throw new ArgumentException ("Invalid worker request. Probable reason is using WebTest.Invoke from a real web application"); MyData d = (MyData) fd[typeof (MyHost)]; if (d == null) { d = new MyData ();