Run VBScript using C#

前端 未结 2 1529
隐瞒了意图╮
隐瞒了意图╮ 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: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); 
      

提交回复
热议问题