Solved

ActiveScript Interface with C#

Posted on 2003-11-06
5
3,309 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

636 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