Home > Enterprise >  Microsoft.Toolkit.Forms.UI.Controls Could not find Windows Runtime type 'Microsoft.Toolkit.Win3
Microsoft.Toolkit.Forms.UI.Controls Could not find Windows Runtime type 'Microsoft.Toolkit.Win3

Time:02-17

I have created a new "Windows Forms App":

enter image description here

enter image description here

Now I install the Microsoft.Toolkit.Forms.UI.Controls from NuGet.

enter image description here

It requires these dependencies:

enter image description here

After clicking "I accept", the next thing that happens is that an error message "Failed to lauch the design tools server process." is shown:

enter image description here

I select the Form1 designer in the tabs, and the ToolBox now shows the new tools:

enter image description here

However, the designer is gone, and when I try to bring it up again, the message "This item does not support previewing." appears each time I click Form1.vb -> View Designer:

enter image description here

enter image description here

I have repeated the process several times.

When I switch from Debug x86 to Debug AnyCPU, I can open up the designer again.

However, when I then try to drag one of the tools onto the form, an error occurs:

"Failed to create component 'InkCanvas'. The error message follows: 'Microsoft.DotnetNet.DesignTools.Client.DesignToolsServerException: Could not find Windows Runtime type 'Microsoft.Toolkit.Win32.UI.XamlHost.IXamlMetadataContainer'.

enter image description here

I am stuck.

CodePudding user response:

It works if I instantiate the control by code instead of dragging it from the ToolBox.

So perhaps a compatiblity problem with WinForms designer?

Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        Dim f As New Microsoft.Toolkit.Forms.UI.Controls.InkCanvas
        With f
            .Size = New Size(400, 100)
            .Location = New Point(20, 20)
        End With

        AddHandler f.TextChanged, AddressOf Ink_Changed
        Me.Controls.Add(f)

    End Sub

    Friend Sub Ink_Changed(sender As Object, e As EventArgs)
        'Write code here.
    End Sub
End Class
  • Related