MSScriptControl "指定的转换无效" 异常
MSScriptControl "指定的转换无效" 错误
MSScriptControl "指定的转换无效" 错误,但我根本看不出来 是什么转换什么时会出现转换无效,花了一整个下午也找不出原因,在此求教各位。
代码如下:
上面的this.sc.AddObject("obj", this, false)里的"this"导致 “指定的转换无效“ 的错误。
AddObject参数类型为 AddObject(string name,object Object,bool AddMembers )
“this“ 不可以转换成object类型吗?
求解
------解决思路----------------------
mssrcipt没用过,不清楚,你试试
this.sc.AddObject("obj",(object) this, false); ?
MSScriptControl "指定的转换无效" 错误,但我根本看不出来 是什么转换什么时会出现转换无效,花了一整个下午也找不出原因,在此求教各位。
代码如下:
using System;
using MSScriptControl;
public class MssCTest
{
public string _pwd;
public string _type;
private string _url;
private ScriptControl sc;
public Test(string url, string type, string pwd)
{
this._type = type;
this._pwd = pwd;
this._url= url;
this.sc = new ScriptControlClass();
this.sc.Language = "javascript";
this.sc.AddObject("obj", this, false);//这里的"this"导致 “指定的转换无效“ 的错误
string code = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "abc.js");
this.sc.AddCode(code);
}
....
}
上面的this.sc.AddObject("obj", this, false)里的"this"导致 “指定的转换无效“ 的错误。
AddObject参数类型为 AddObject(string name,object Object,bool AddMembers )
“this“ 不可以转换成object类型吗?
求解
------解决思路----------------------
mssrcipt没用过,不清楚,你试试
this.sc.AddObject("obj",(object) this, false); ?