Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在C中使用VBScript获取对象#_C#_Asp.net_Vbscript - Fatal编程技术网

C# 在C中使用VBScript获取对象#

C# 在C中使用VBScript获取对象#,c#,asp.net,vbscript,C#,Asp.net,Vbscript,我正在运行一个第三方应用程序,它在其中运行网页。第三方应用程序包括位于服务器上的dll。基本上,我正在尝试替换当前与C#代码一起使用的VB脚本 以下vbscript在网页中运行,并包含一个可以更改页面并完美工作的函数 'VB Script Set AgentDisp = GetObject("","AgentDisp.AgentDispatcher") AgentDisp.ChangePage PageName, False 现在,当我在C#中尝试同样的方法时,通过向这个dll添加一个引用并在

我正在运行一个第三方应用程序,它在其中运行网页。第三方应用程序包括位于服务器上的dll。基本上,我正在尝试替换当前与C#代码一起使用的VB脚本

以下vbscript在网页中运行,并包含一个可以更改页面并完美工作的函数

'VB Script
Set AgentDisp = GetObject("","AgentDisp.AgentDispatcher")
AgentDisp.ChangePage PageName, False
现在,当我在C#中尝试同样的方法时,通过向这个dll添加一个引用并在页面加载时运行以下代码,什么都没有发生

// C#
var a = new AgentDisp.AgentDispatcher();
a.ChangePage("faq.aspx", false);
这是否与dll的位置或实例有关

我不知道C#但您的代码似乎与CreateObject相同,只是早期绑定。您需要使用getobjectequiv

GetObject可用于运行实例或数据文件

GetObject([pathname] [, class])

When this code is executed, the application associated with the specified
pathname is started and the object in the specified file is activated. If
pathname is a zero-length string (""), GetObject returns a new object
instance of the specified type. If the pathname argument is omitted,
GetObject returns a currently active object of the specified type. If no
object of the specified type exists, an error occurs.

VBScript还使用后期绑定(即IDispatch)。您正在使用早期绑定。不过没关系

因此,这两个示例都在创建对象的新实例。如果省略路径名,则会设置一个活动类。如果路径名为空,则会创建一个新文档。GetObject也在vb.net中,与vbscript完全相同。我不知道这些C#docs是正面还是反面。我甚至看不出有什么功能。因此,将GetObject放在项目的vb模块中。