2

I am trying to execute a script written in VBScript, in a C# class library project

using System.Web.UI;  //reference added at top

MSScriptControl script = new ScriptControl();
script.Language = "VBScript";
script.AddObject("Repository", connectToDB.GetRepository);  

I get the following compilation error:

Error CS0246: The type or namespace name 'MSScriptControl' could not be found (are you missing a using directive or an assembly reference?)

Any ideas?

2
  • are they under the same namespace? or did you add reference correctly? Commented Jul 23, 2014 at 12:19
  • @IJ, I added it correctly - just wanted to clarify that the reference was added. Any ideas? Commented Jul 24, 2014 at 7:08

2 Answers 2

1
  1. Add a COM reference of "Microsoft Script Control 1.0" to your project.
  2. using Microsoft.VisualBasic;
  3. Use this code: ​​

    MSScriptControl.ScriptControl script = new MSScriptControl.ScriptControl();
    script.Language = "VBScript";
    script.AddObject("Repository", connectToDB.GetRepository); 
    
Sign up to request clarification or add additional context in comments.

Comments

1

I belive

MSScriptControl script = new ScriptControl();

should be

MSScriptControl.ScriptControl sc = new MSScriptControl.ScriptControl();

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.