Run VBScript using C#

前端 未结 2 1528
隐瞒了意图╮
隐瞒了意图╮ 2021-01-15 06:26

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

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


        
相关标签:
2条回答
  • 2021-01-15 07:10

    I belive

    MSScriptControl script = new ScriptControl();
    

    should be

    MSScriptControl.ScriptControl sc = new MSScriptControl.ScriptControl();
    
    0 讨论(0)
  • 2021-01-15 07:12
    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); 
      
    0 讨论(0)
提交回复
热议问题