Solved

ActiveScript Interface with C#

Posted on 2003-11-06
5
3,171 Views
Last Modified: 2012-06-27
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
0
Comment
Question by:drojasm
  • 2
5 Comments
 
LVL 6

Expert Comment

by:purpleblob
ID: 9695173
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).
0
 

Author Comment

by:drojasm
ID: 9696495
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();
 }
0
 
LVL 6

Accepted Solution

by:
purpleblob earned 130 total points
ID: 9700368
It's one of those fun errors that Microsoft don't seem to document - although I found some info on this that says the 0x80020101 is a SCRIPT_E_REPORTED.  This error message is returned when a script engine has encountered an error and has reported it to the host via OnScriptError.  

If you put a break point in the OnScriptError method are you seeing this get called.

Sorry I haven't had time to get your code working on my machine to verify so cannot say for sure what's happening.

I don't know whether implementing the IActiveScriptSiteWindow and IActiveScriptSiteDebug might help at all (if you're not already implementing them).
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video discusses moving either the default database or any database to a new volume.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now