system.web.mvc.viewResult cannot be converted to i-dimensional array of system.web.mvc.viewresult

Last post 07-03-2009 8:51 AM by pumpkin_head. 1 replies.

Sort Posts:

  • system.web.mvc.viewResult cannot be converted to i-dimensional array of system.web.mvc.viewresult

    07-02-2009, 3:54 PM
    • Member
      point Member
    • pumpkin_head
    • Member since 05-16-2007, 4:27 PM
    • Posts 2

    Hello and Thanks in advance for the help!

    I'm working through the example in the "pro asp mvc framework" book (chapter 4) and have run into this error and i have no idea what it means.  I tried searching on google by there doesn't seem to be anyone else who has run into it!  I'm not sure if it's because i messed something up while translating the example from csharp to vb.net  or if i messed up setting up the repository (I know it's not the same as the book, but we work with nhibernate not linq to sql so i'm building it with that in mind.)

    The bolded line is where the error is showing up when i try to compile.

    This is the ProductsController.vb file:

    Imports domainmodel.interfaces
    Imports DomainModel.Entities
    Imports DomainModel.Repositories

    Namespace Controllers


    Public Class ProductsController
    Inherits Controller

    Private productsRepository As IProductsRepository

    Public Sub New()
    productsRepository = New fakeProductsRepository
    End Sub

    Public Function List() As ViewResult()
    Return View(productsRepository.FindAll)

    End Function

    End Class
    End Namespace


    This is the repository

    Imports DomainModel.Interfaces
    Imports DomainModel.Entities
    
    Namespace Repositories
        Public Class FakeProductsRepository
            Implements IProductsRepository
    
    
            Private m_Products() As Product = {New Product With {.Name = "Football", .Price = 25}, New Product With {.Name = "SurfBoard", .Price = 75}, New Product With {.Name = "shoes", .Price = 10}}
    
            Public Function GetById(ByVal id As Integer) As Product Implements IProductsRepository.GetById
                Return m_Products(id)
            End Function
    
            Public Function FindAll() As IList(Of Product) Implements IProductsRepository.FindAll
                Return m_Products
            End Function
    
            
        End Class
    End Namespace

    This is the Interface:
    Imports DomainModel.Entities
    
    Namespace Interfaces
        Public Interface IProductsRepository
            Function FindAll() As IList(Of product)
            Function GetById(ByVal id As Integer) As Product
        End Interface
    End Namespace

    and this is the product entity:
    Namespace Entities
        Public Class Product
            Private m_ProductID As Integer
            Private m_Name As String
            Private m_Description As String
            Private m_Price As Decimal
            Private m_Category As String


            Public Property ProductId() As Integer
                Get
                    Return m_ProductID
                End Get
                Set(ByVal value As Integer)
                    m_ProductID = value
                End Set
            End Property

            Public Property Name() As String
                Get
                    Return m_Name
                End Get
                Set(ByVal value As String)
                    m_Name = value
                End Set
            End Property

            Public Property Description() As String
                Get
                    Return m_Description
                End Get
                Set(ByVal value As String)
                    m_Description = value
                End Set
            End Property

            Public Property Price() As Decimal
                Get
                    Return m_Price
                End Get
                Set(ByVal value As Decimal)
                    m_Price = value
                End Set
            End Property

            Public Property Category() As String
                Get
                    Return m_Category
                End Get
                Set(ByVal value As String)
                    m_Category = value
                End Set
            End Property
        End Class
    End Namespace


    I think that's all the important parts.  Thanks for taking the time to try to help!


  • Re: system.web.mvc.viewResult cannot be converted to i-dimensional array of system.web.mvc.viewresult

    07-03-2009, 8:51 AM
    Answer
    • Member
      point Member
    • pumpkin_head
    • Member since 05-16-2007, 4:27 PM
    • Posts 2

    I copy and pasted the function and deleted the first one and it worked.  I guess it's just one of those weird visual studios glitches that happens some times.

    Hopefully having this here will help save time for someone in the future!

Page 1 of 1 (2 items)