Link to home
Start Free TrialLog in
Avatar of drojasm
drojasm

asked on

ActiveScript Interface with C#

I have taken some code from an article that allows me to use Acitve Script debugging in .NET
i could instanciate the interfaces like i show in the next code line
            
vbScriptHost engine = new vbScriptHost();
IActiveScriptParse32 iap = engine as IActiveScriptParse32;
iap.InitNew();
IActiveScript ias = engine as IActiveScript;
ias.SetScriptSite( this );

object o1 = null;
stdole.EXCEPINFO info;

the problem starts when i call the function ParseScriptText like this
iap.ParseScriptText("5 + 5", null, null, null, 0, 0, 0x00000002|0x00000020, out o1, out info);

it throws an exception saying sometimes that the method is not implemented or in other times it gives me an error
in hexadecimal format

does any one could wonder what may be the problem
thanks
Avatar of purpleblob
purpleblob

Can you supply the hex error number as this is likely to be the COM error from the Active Scripting engine ?

Alternatively to your use of Active Scripting you could try the MSScript ActiveX which encapsulates the Site and hosting code or Vsa (the .NET alternative to the old scripting engine).
Avatar of drojasm

ASKER

Well, i did use the MSScript Activex, but i need to create a debugger for the vbscript editor that i'm developing. So i need to know if that control allows me to do debugging or if it doesn't so i think i have to use the Interfaces directly, so i need to make the previous code to run. the error that it gives me is
"The method or operation is not implemented." when i have "5 + 5" in the script text.  and also i'm using jscript
if i switch to vbscript it returns me the next error
"Exception from HRESULT: 0x80020101."

Here is the class that i'm using for getting that exceptions working

[
Guid("B54F3741-5B07-11CF-A4B0-00AA004A55E8"), ComImport
]
class vbScriptHost
{
}

this is the class that holds and execute the parsing code
public class ScriptHost : IActiveScriptSite
{
  .....Here goes the other interfaces methods
  public void Run(string p_Script)
 {
 try
 {
 vbScriptHost engine = new vbScriptHost();
 IActiveScriptParse32 iap = engine as IActiveScriptParse32;
 iap.InitNew();
 IActiveScript ias = engine as IActiveScript;
 ias.SetScriptSite( this );
 object o1 = null;
 stdole.EXCEPINFO info;
 iap.ParseScriptText(p_Script, null, null, null, 0, 0, 0x00000002|0x00000020, out o1, out info);
 MessageBox.Show( o1.ToString() );
 }
 catch(Exception e )
 {
     MessageBox.Show( e.Message  );
 }
    Console.ReadLine();
 }
ASKER CERTIFIED SOLUTION
Avatar of purpleblob
purpleblob

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial