We are working on an MVC project in VB .Net at my job. My previous MVC background is entirely in C#.
In this project, we have:
In the MainView, somewhere we have:
Now, when the VB Parser gets to this last part, it crashes. For some reason, it gives an error that the wrong type of model was passed in. The compiler correctly infers that Model.SubModel1 is of SubModel1 type, but the Parser does not.
These "SubModel" properties are all Public Overridable Property of their respective types. I understand that this is the equivalent to "public virtual myType" in C#.
This code works fine in C#, and I have done it many times before. But for some reason, VB thinks there is an error. Any ideas? And no, "just use C#" won't work because the other developers here are highly resistant to using any language other than VB.
In this project, we have:
Code:
MainModel - has a "SubModel1" property, "SubModel2", etc.
SubModel1 - a model that we want to show in a partial view that is strongly typed to it
SubModel2 - a model that we want to show in a partial view that is strongly typed to it
SubModel3 - a model that we want to show in a partial view that is strongly typed to it
MainView - strongly typed to MainModel. It contains a PartialView1, PartialView2, etc.
PartialView1 - strongly typed to SubModel1
PartialView2 - strongly typed to SubModel2
PartialView3 - strongly typed to SubModel3
In the MainView, somewhere we have:
Code:
@Html.Partial("foo", Model.SubModel1)
Now, when the VB Parser gets to this last part, it crashes. For some reason, it gives an error that the wrong type of model was passed in. The compiler correctly infers that Model.SubModel1 is of SubModel1 type, but the Parser does not.
These "SubModel" properties are all Public Overridable Property of their respective types. I understand that this is the equivalent to "public virtual myType" in C#.
This code works fine in C#, and I have done it many times before. But for some reason, VB thinks there is an error. Any ideas? And no, "just use C#" won't work because the other developers here are highly resistant to using any language other than VB.
