problem in a web project, a different thread owns it.

Nov 22, 2013 at 4:26 PM
I am working with Visual Studio Web Developer 2010 Express and getting this error.


System.InvalidOperationException was unhandled by user code
HResult=-2146233079
Message=The calling thread cannot access this object because a different thread owns it.
Source=WindowsBase
StackTrace:
   at System.Windows.Threading.Dispatcher.VerifyAccess()
   at Microsoft.ClearScript.Windows.WindowsScriptEngine.VerifyAccess() in c:\misc\ClearScript2012\ClearScript\Windows\WindowsScriptEngine.cs:line 169
   at Microsoft.ClearScript.Windows.WindowsScriptEngine.ScriptInvoke(Action action) in c:\misc\ClearScript2012\ClearScript\Windows\WindowsScriptEngine.cs:line 490
   at Microsoft.ClearScript.Windows.WindowsScriptEngine.Execute(String documentName, String code, Boolean evaluate, Boolean discard) in c:\misc\ClearScript2012\ClearScript\Windows\WindowsScriptEngine.cs:line 413
   at Microsoft.ClearScript.ScriptEngine.Execute(String documentName, Boolean discard, String code) in c:\misc\ClearScript2012\ClearScript\ScriptEngine.cs:line 483
   at Microsoft.ClearScript.Windows.VBScriptEngine.ExecuteCommand(String command) in c:\misc\ClearScript2012\ClearScript\Windows\VBScriptEngine.cs:line 261
   at MaxRecall.CORE.ZScripting.PrintScriptRun(Int32 Index) in c:\MRC#\CORE\CORE\Scripting.cs:line 1022
   at MaxRecall.CORE.ZGraphics.ZDocPrinter.Run2() in c:\MRC#\CORE\CORE\Graphics.cs:line 362
   at MaxRecall.CORE.ZGraphics.ZDocPrinter.Run() in c:\MRC#\CORE\CORE\Graphics.cs:line 346
   at MaxRecall.Query4A.make_doc_pdf() in c:\MRC#\QUERY\QUERY.cs:line 2108
   at mr4._Default.MRQ() in C:\MRC#\MR4WEB\MR4\mrq.aspx.cs:line 867
   at ASP.mrq_aspx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in c:\MRC#\MR4WEB\MR4\mrq.aspx:line 4
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
   at System.Web.UI.Page.Render(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:
Nov 22, 2013 at 5:50 PM
Edited Nov 22, 2013 at 5:58 PM
I think I figured it and it had nothing to do with clearscript.

Sigh. celebration premature. if the session times out i get the same error.
Coordinator
Nov 22, 2013 at 6:27 PM
Glad to hear that you figured it out, but yeah, Windows script engines are tricky to use on the server because each instance can only be called on the thread on which it was created. Good luck!