silverlight-4 com-interop无法调用非委托类型

时间:2012-09-14 00:33:33

标签: silverlight-4.0 com-interop wsh

此silverlight代码抛出错误“无法调用非委托类型”

        var WshShell = AutomationFactory.CreateObject("WScript.Shell");
        var WshSysEnv = WshShell.Environment("SYSTEM");
        var foo = WshSysEnv("APPDATA");

如何获取环境变量?


编辑:
@ paulsm4 - 这适用于silverlight ......

        var WshShell = AutomationFactory.CreateObject("WScript.Shell");
        var appData = WshShell.ExpandEnvironmentStrings("%APPDATA%");
        MessageBox.Show(appData);

1 个答案:

答案 0 :(得分:1)

假设WSH,这样的事情怎么样:

Set wshShell = CreateObject( "WScript.Shell" )
WScript.Echo wshShell.ExpandEnvironmentStrings( "%APPDATA%" )
wshShell = Nothing