Marschall.GetActiveObject() throws MK_E_UNAVAILABLE Ausnahme in C#

Den folgenden vbscript-code funktioniert prefectly fein:

Dim App 
Set App = GetObject("","QuickTest.Application")
App.Quit

Aber wenn ich es übersetzen in C# - code, wie unten:

class Program
{
    [STAThread]
    static void Main(string[] args)
    {
        object qtApp = Marshal.GetActiveObject("QuickTest.Application");
        (qtApp as QuickTest.Application).Quit();
    }
}

Bekomme ich die exception:

Eine nicht behandelte Ausnahme des Typs 'System.- Laufzeit.InteropServices.COMException' ist in mscorlib.dll

Zusätzliche Informationen: (Ausnahme von HRESULT: 0x800401E3 (MK_E_UNAVAILABLE))

Ich glaube nicht, dass das problem mit ROT, weil der vbscript-code funktioniert. Also, was ist falsch mit der C# - code?

InformationsquelleAutor der Frage TomCaps | 2011-10-12

Schreibe einen Kommentar