<div style="font-weight: normal;"><div>Hi, </div>
<div>&nbsp;</div>
<div>I have written a DLR hosting application, create ScriptRuntime in another AppDomain, DLR throw exception when execute code. the detail code like follow:</div>
<div>&nbsp;</div>
<div>public class ScriptProxy : MarshalByRefObject, IScriptProxy<br>{<br>&nbsp; &nbsp; private ScriptEngine m_ScriptEngine;<br>&nbsp; &nbsp; private ScriptRuntime m_ScriptRuntime;</div>
<div>&nbsp; &nbsp; public ScriptProxy()<br>&nbsp; &nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; ScriptRuntimeSetup runtimeSetup = new ScriptRuntimeSetup(true);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; m_ScriptRuntime = ScriptRuntime.Create(runtimeSetup);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; m_ScriptRuntime.GlobalOptions.DebugMode = true;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; m_ScriptRuntime.GlobalOptions.DynamicStackTraceSupport = true;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; //Default script engine<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; m_ScriptEngine = m_ScriptRuntime.GetEngine("python");<br>&nbsp; &nbsp; }<br>}<br><br>//=======Client code as follow =====================<br></div>
<div>private void Initialize()<br>{<br>&nbsp; &nbsp; Evidence evidence = AppDomain.CurrentDomain.Evidence;<br>&nbsp; &nbsp; AppDomainSetup appSetup = new AppDomainSetup();<br>&nbsp; &nbsp; appSetup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;<br>&nbsp; &nbsp; m_ScriptAppDomain = AppDomain.CreateDomain("ScriptProxy", evidence, appSetup);</div>
<div>&nbsp; &nbsp; m_ScriptAppDomain.Load("ScriptProxy");<br>&nbsp; &nbsp; m_RemoteScript = (IScriptProxy)m_ScriptAppDomain.CreateInstanceAndUnwrap("ScriptProxy", "ZuHong.TestMore.Scripting.ScriptProxy");<br>}<br><br></div>
<div>m_RemoteScript.ExecuteCode(txtScriptSource.Text);</div>
<div>&nbsp;</div>
<div>==========================================</div>
<div>DLR throw exception when execute code: SourceUnit not marked as <span class="identifier">SerializableAttribute.</span></div>
<div>&nbsp;</div>
<div><img src="cid:A349BAF3@D9780F25.5588DC47"></div>
<div style="font-size: 12px; color: rgb(144, 144, 144); font-family: Arial Narrow;">------------------</div>
<div>
<div>Andy Tao[陶祖洪]</div>
<div>祖洪测试自动化 <a href="http://www.zuhong.cn/">http://www.zuhong.cn</a></div>
<div>天是圆的,地是方的,凡事都要有个规矩!</div></div></div>