Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

Posted

are your buttons public???

 

I love the MSScript Control!!!

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.

Posted
Additional information: Schnittstelle nicht unterstützt

 

in English: No such Interface supported

Man. . . Exceptions in German look extremely angry!!!

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.

Posted
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.

Posted

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

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.

Posted

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?

  • 11 months later...
Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...