0
Follow
0
View

A C# call to a JS function indicates that the runtime binding cannot be performed on a null reference

dongxie1 注册会员
2023-02-27 16:37

Probably because you didn't assign RegisterCode a value when you defined the class, So when testFunction is called, RegisterCode is null

cupild 注册会员
2023-02-27 16:37

Thank you for your answer, I test class should be recognizable as follows:
function RegisterClass()
{
var RegisterCode;
var Type;
this.testFunction = function(){
return "hello~~ " + RegisterCode;
}
function AutoReg(code)
{
return "hello~~ " + RegisterCode;
}
}
function InitProcess(InputCode)
{
var objRegister = new RegisterClass();
objRegister.RegisterCode = InputCode;
//return "null~~" + objRegister.RegisterCode; Here is the value of the member that can be printed, so the sense class recognizes
objRegister.testFunction();
//objRegister.AutoReg(InputCode); // Because it is a private method, this call will prompt you that the property or method is missing.
}

cythere 注册会员
2023-02-27 16:37
< div class = " md_content_show“数据- v - 3967 e397 = " " >


}
//类定义结束,开始调用
var objRegister = new RegisterClass();
return objRegister.testFunction(InputCode);

dmq0708 注册会员
2023-02-27 16:37

This problem may be caused by the MSScriptControl.AddCode method not recognizing classes defined in js......
suggests that you change the class definition in js to a function definition, or use other methods to load the js file, such as using the XMLHttpRequest object, such as using the class keyword in ES6.

About the Author

Question Info

Publish Time
2023-02-27 16:37
Update Time
2023-02-27 16:37

Related Question

在Python中由于wmi无法启动线程

opencv(Python)图像去阴影

在SwiftUI中使用onAppear时无限循环

关于#javascript#的问题:1.我的hbuildx的js文件在内置浏览器上console运行不出结果

nifi json转化分片失败

harmonyOS数据

为什么这些假定相同的Python字典行为不同?

Ajax报Failed to load resource: the server responded with a status of 404 (Not Found)

关于Python初学者的问题

Springboot 2.0.5和MongoDB TimeSeries