MadMaxMSCN Posted October 21, 2004 Posted October 21, 2004 Hi everybody, I have to use MSScriptControl in my Application. First I added the reference to MSScriptControl, of course. Then I created some objects and a ScriptControl. When I try to add the objects to the ScriptControl I get an Exception. Dim script As New MSScriptControl.ScriptControl In Button_Click: dim oTest As New Object dim btnTest As New Button script.AddObject("form", Me, True) 'this works script.AddObject("object", oTest, False) 'works, too script.AddObject("button", btnTest, False) 'Exception script.AddObject("otherButton", Me.Button1, False) 'Exception Why do I get this Exception: An unhandled exception of type 'System.InvalidCastException' occurred in WindowsApplication2.exe Additional information: Schnittstelle nicht unterstützt in English: No such Interface supported What's wrong? Quote
Joe Mamma Posted October 24, 2004 Posted October 24, 2004 are your buttons public??? I love the MSScript Control!!! Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
Joe Mamma Posted October 24, 2004 Posted October 24, 2004 Additional information: Schnittstelle nicht unterstützt in English: No such Interface supported Man. . . Exceptions in German look extremely angry!!! Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
MadMaxMSCN Posted October 25, 2004 Author Posted October 25, 2004 Man. . . Exceptions in German look extremely angry!!! German translation is bad, English texts are more better, often you know what's wrong when you read the English exception text but you have no idea when reading the German. In Spanish it's: "Interfaz no compatible" (looks strange for a German) It doesn't matter if my objects are private, public in form1 or public in button_click. The problem is always the same. Quote
Joe Mamma Posted October 25, 2004 Posted October 25, 2004 you have a form - Form1 it has a Public Property MainButton that returns a reference to a button on the form you add it to the ScriptContro via dim frm as New Form1 sc.AddObject("TheForm", Form1, true) in the script can you reference Form.btnTest ? i.e. dim caption caption = Form.btnTest.Text Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
MadMaxMSCN Posted October 25, 2004 Author Posted October 25, 2004 The Code shown in my post ist only for testing. In my project it's much more difficult: My task is to upgrade an old vb6-app to vb.net. I have a form: Form1. On Form1 there's a user control: ucCustomForm. ScriptControl is private in ucCustomForm. The user can make some controls at runtime. These Controls are saved in a public property in ucCustomForm. In vb6 the ScriptControl got (AddObject()) this property, a public object from a module and the ucCustomForm object itself. The application has to be converted to vb.net without changing the scripts because there are very much of them. Is this possible? Quote
Hykke Posted October 21, 2005 Posted October 21, 2005 Solutions to common Scriptcontrol problems in VB.NET I've just converted an application from VB to VB.NET. This application used the scriptcontrol a lot. In my experience there were the following problems after the upgrade: 1. Everything the scripts can access must be made public, or you will get the "No such Interface supported" error. 2. The scriptcontrol seems to have problems accessing overloaded procedures. This includes collections or dictionaries, where you can use both the col("key") syntax as well as the col(7) syntax. This second problem can be solved by replacing the "public col as Collection" declaration with the following piece of code: Private objCol As New Collection Public Function col(Optional ByVal IndexOrKey As Object = Nothing) As Object If IndexOrKey Is Nothing Then Return objCol Else Return objCol(IndexOrKey) End If End Function Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.