IgnaceMaes / MaterialSkin

Theming .NET WinForms, C# or VB.Net, to Google's Material Design Principles.
MIT License
2.84k stars 831 forks source link

VB.net 2015 Form Type Mismatch #132

Closed GuardianMajor closed 7 years ago

GuardianMajor commented 7 years ago

Using VB 2015 (Visual Studio Enterprise 2015) running with .NET 4.5.2

It simply complains that Form1 cannot be converted to MaterialForm.

BC30311 | Value of type 'Form1' cannot be converted to 'MaterialForm'.

I would say this is a huge problem that can effectively prevent the use of the library, any thoughts?

Dutchs commented 7 years ago

Showing the code to reproduce this would be usefull. And/or what you are trying to achieve.

GuardianMajor commented 7 years ago

What code, its directly from the sample provided. What I am trying to achieve is for the code to run so I can see it working.

Dutchs commented 7 years ago

That is strange, i have been able to inherit a Form from MaterialForm without any issues using the provided sample code, with vb.net 4.5.2 (VS2015)

Just so we are on the same page: You have added a refrence to MaterialSkin and added a Form and in Form1.Designer.vb you changed: Inherits System.Windows.Forms.Form to: Inherits MaterialSkin.Controls.MaterialForm and at this point the Designer for Form1 displays a MaterialForm.

GuardianMajor commented 7 years ago

Thanks for the reply, I was surprised too as it works in C# fine but not in VB but anyhow since I hadn't done what you cited with regards to the Inherits statements, I thought that might fix it so I made the change hopeful that I can come back and report it worked.

But while in the editor it won't complain about any issues, during the compile process needed to RUN it, it comes back with this error now:

BC30928 Base class 'Form' specified for class 'Form1' cannot be different from the base class 'MaterialForm' of one of its other partial types.

So still not sure why its complaining. So I started a simple solution with bare bone code to see if I can get it run right before going any further and it results in the same error, here is the skeleton code, nothing exciting and the DLL is compiled, and referenced already

Imports MaterialSkin

Public Class Form1
    Inherits MaterialSkin.Controls.MaterialForm

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        SkinManager.AddFormToManage(Me)
        SkinManager.Theme = MaterialSkinManager.Themes.DARK
        SkinManager.ColorScheme = New ColorScheme(Primary.Orange900, Primary.DeepOrange900, Primary.BlueGrey900, Accent.LightBlue700, TextShade.BLACK)
    End Sub

End Class

Any thoughts on that? Am I still forgetting something? It has been a LONG time since I have dropped someone else's code in mine without writing it from scratch, so I might be out of practice a bit - missing something simple.

GuardianMajor commented 7 years ago

@Dutchs I am such a dumbass, I figured out where I borked it. I put the inherit in the wrong place, I put it in the code not the designer, ARGH! and now it works, thank you for your help.

Adama-Doh commented 4 years ago

@Dutchs & @GuardianMajor I really had a hard time finding where to place

Inherits MaterialSkin.Controls.MaterialForm

I think it's, probably because I'm using VB.net 2019 and I'm also totally new to this (Vb.net). All the same i carefully read through this issue and finally arrived to the solution. Thanks a lot.

For anyone hoping to understand what @GuardianMajor meant by inheritting in the wrong place, check below image

GuardianMajor commented 4 years ago

Thank you, I am sure it will help someone and I am sorry I never thought to put it there. Well done.