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
Solved

ActiveScript Interface with C#

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

860 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