I'm wanting to use the MSScriptControl from C++ (Visual Studio 2012). When I call the AddObject in runtime I get a "Specified Cast Is Invalid" error.
I have this is my AssemblyInfo.cpp:
This is my BasicCommands.h:
ref class BasicCommandsClass
void SpeakPhrase(String^ phrase)
void RunScript(String^ script)
MSScriptControl::ScriptControlClass^ pScriptControl=gcnew MSScriptControl::ScriptControlClass();
pScriptControl->Language = "vbscript";
pScriptControl->AllowUI = true;
The AddObject should be adding the SpeakPhrase command so I can call it from my vbscript.
Any idea why it's not working?
Try add [ComVisibleAttribute(true)] to the class BasicCommandsClass.
MSScriptControl uses COM technology to access to the object properties and methods, so if the class is not COM visible, it cannot be used by any script.
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)