Nathan Baker
2007-02-09 17:56:16 UTC
Hello,
I have created a scripting environment in C# using Active Scripting. I
have the following code:
_script = new ScriptHost();
JScript jsengine = new JScript();
IActiveScriptParse asp = jsengine as IActiveScriptParse;
IActiveScript ias = jsengine as IActiveScript;
asp.InitNew();
ias.SetScriptSite(_script);
stdole.EXCEPINFO einfo;
ias.AddNamedItem("test", SCRIPTITEM_ISVISIBLE |
SCRIPTITEM_GLOBALMEMBERS);
asp.ParseScriptText("test.DoIt();");
ias.Close();
The implementation of test.DoIt() simply displays a message box:
public class TestClass {
public void DoIt() {
MessageBox.Show("I live!");
}
}
The GetItemInfo method of _script is as follows:
public void GetItemInfo(string pstrName, uint dwReturnMask, out object
ppiunkItem, IntPtr ppti)
{
ppiunkitem = null;
ppti = IntPtr.Zero;
if (pstrName == "test") {
ppiunkItem = new TestClass();
if(ppti != IntPtr.Zero) {
Marshal.WriteIntPtr(ppti,
Marshal.GetITypeInfoForType(ppiunkItem.GetType()));
}
}
}
Rather than displaying a message box (as expected), the call to
asp.ParseScriptText does nothing. Why is this?
Thanks,
Nathan
I have created a scripting environment in C# using Active Scripting. I
have the following code:
_script = new ScriptHost();
JScript jsengine = new JScript();
IActiveScriptParse asp = jsengine as IActiveScriptParse;
IActiveScript ias = jsengine as IActiveScript;
asp.InitNew();
ias.SetScriptSite(_script);
stdole.EXCEPINFO einfo;
ias.AddNamedItem("test", SCRIPTITEM_ISVISIBLE |
SCRIPTITEM_GLOBALMEMBERS);
asp.ParseScriptText("test.DoIt();");
ias.Close();
The implementation of test.DoIt() simply displays a message box:
public class TestClass {
public void DoIt() {
MessageBox.Show("I live!");
}
}
The GetItemInfo method of _script is as follows:
public void GetItemInfo(string pstrName, uint dwReturnMask, out object
ppiunkItem, IntPtr ppti)
{
ppiunkitem = null;
ppti = IntPtr.Zero;
if (pstrName == "test") {
ppiunkItem = new TestClass();
if(ppti != IntPtr.Zero) {
Marshal.WriteIntPtr(ppti,
Marshal.GetITypeInfoForType(ppiunkItem.GetType()));
}
}
}
Rather than displaying a message box (as expected), the call to
asp.ParseScriptText does nothing. Why is this?
Thanks,
Nathan