none
Scripting facility RRS feed

  • Question

  • I have a VB6 program that uses the MSScriptControl to allow user exits to our package. Is there a similar facility in .NET / VS2012?

    Mike

    • Moved by Amanda Zhu Monday, February 11, 2013 6:13 AM
    Friday, February 8, 2013 7:38 PM

Answers

  • Not sure how to set STA in this scenario. In any event, I think I have a workaround. First I created a COM module that encapsulates the MSScriptControl. In it, I created classes for each of the objects I wanted to add to the script engine. Instead of accessing the ADDOBJECT method of that MSSCriptControl directly which accepts a parameter of type OBJECT, I created methods for each of the objects I want to add which referenced a specific object of that type rather than just the generic OBJECT type. So the calling program instantiates the objects, then calls the individual method for that object which then uses the ADDOBJECT method of the MSSCriptControl  and it all works then.

    Mike

    Tuesday, February 12, 2013 11:15 PM

All replies

  • Hello MihaIvan,

    Thank you for your post.

    Based on your description, I feel that your issue is more related to CLR. I am afraid that the issue is out of support of VS General Question forum which mainly discusses WPF & SL designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System and Visual Studio Editor.

    I have consulted a .NET expert. As he said there is no such control to allow user exits to the package in .NET. You need to reference COM control.

    I will move this thread to Common Language Runtime Internals and Architecture forum for better response.

    Best regards,


    Amanda Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.



    • Edited by Amanda Zhu Monday, February 11, 2013 6:12 AM
    Monday, February 11, 2013 3:29 AM
  • There is no way your statement makes any sense whatsoever. I asked if there was a scripting facility available in the current  VS / .NET. It has nothing to do with VB6. I am not trying to program in VB6. I am trying to develop a VB program in VS2012. The only reference to VB6 is to illustrate the type of scripting facility I am looking for and to state why I need it. I do not feel this is off topic for a VS forum.

    Mike

    Monday, February 11, 2013 3:45 AM
  • Hi Mike,

    I agree with Amanda:

    there is no such control to allow user exits to the package in .NET. You need to reference COM control.

    Thanks.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, February 11, 2013 11:22 AM
    Moderator
  • It's the same control.  It should be in your Toolbox.
    Monday, February 11, 2013 6:10 PM
  • I can put an OCX control into the tool box? It is not there now and I don't see how I can add it. The only way I can get it into the program is by adding it as a reference. At that point, I run into problems that if I mention them, will get me cast out of the discussion because it is not the topic for the current forum. But in any event, the old one will not work in .NET because I pass objects for the script to access rather than discreet strings / integers etc. But .NET chokes on the objects and gives me an error: Specified cast is invalid. Thus the need for something that provides the capability of MSScriptControl in .NET where objects can be passed without getting the error.

    Mike

    Monday, February 11, 2013 8:16 PM
  • It's listed as "ScriptControlObject" on the COM tab.  I had no problem adding it to the Toolbox and a Form.  I can't help you with its use though as I have never used it.  You might find applicable threads in the forum archives.
    Monday, February 11, 2013 8:36 PM
  • An invalid cast exception translates to E_NOINTERFACE in COM, if you indeed have correct code, you probably initialized your thread using the wrong thread apartment. The script control, like basically every other ActiveX, requires STA.

    Also this control is out of support. You can invoke IActiveScript directly if you encounter any problem.



    Visual C++ MVP




    Tuesday, February 12, 2013 2:03 AM
  • Not sure how to set STA in this scenario. In any event, I think I have a workaround. First I created a COM module that encapsulates the MSScriptControl. In it, I created classes for each of the objects I wanted to add to the script engine. Instead of accessing the ADDOBJECT method of that MSSCriptControl directly which accepts a parameter of type OBJECT, I created methods for each of the objects I want to add which referenced a specific object of that type rather than just the generic OBJECT type. So the calling program instantiates the objects, then calls the individual method for that object which then uses the ADDOBJECT method of the MSSCriptControl  and it all works then.

    Mike

    Tuesday, February 12, 2013 11:15 PM
  • If you indeed have the control working with a wrapper, then your thread apartment is fine, and the problem is probably on the COM visibility of your original object. 


    Visual C++ MVP

    Tuesday, February 12, 2013 11:50 PM