开发者

JScript runtime error: 'System' is undefined"

I have JScript method that is :

function init() {
     var userid = System.Environment.getEnvironmentVariable("USERNAME");
     setUserName(userid);
    }

When I debug it , at first line of the init funct开发者_如何学Pythonion, I'll get "javascript Microsoft JScript runtime error: 'System' is undefined".

I'd be thankful if some one let me know how can I solve it.


You're using code specific to Windows Sidebar/Desktop Gadgets. The host for Windows Desktop Gadgets provides the System namespace for access to computer properties that are not normally available to Javascript.

Gadgets can be coded in Javascript which is most likely how you picked up that source code. Using this namespace outside of a Windows Desktop Gadget (ie in a web page or shell script) wouldn't work because it is provided by the host (sidebar.exe).

See http://msdn.microsoft.com/en-us/library/ms723688(VS.85).aspx.


One note here to anyone trying to resolve the same error in typescript: when using module type "System" in an ASP.NET project, you may encounter the very same error. Change "compilerOptions": { "module": "System" } in the tsconfig.json to any other module type. When set to system, the first line in all .js files will include a reference to System.register() which cant be found, hence this error.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜