Solved

ActiveScript Interface with C#

Posted on 2003-11-06
5
3,201 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

920 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

16 Experts available now in Live!

Get 1:1 Help Now