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?

Humayun Shabbir
  • 2,961
  • 4
  • 20
  • 33
user3165438
  • 2,631
  • 7
  • 34
  • 54

2 Answers2

1

I belive

MSScriptControl script = new ScriptControl();

should be

MSScriptControl.ScriptControl sc = new MSScriptControl.ScriptControl();
elrado
  • 4,960
  • 1
  • 17
  • 15
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); 
    
Fabian N.
  • 3,807
  • 2
  • 23
  • 46
PawanS
  • 7,033
  • 14
  • 43
  • 71