views:

1911

answers:

5

EDIT: Page language is VB

UPDATE I'm going completely crazy. Here are some screenshots, I hope somebody sees what's going on (TestClass is a simple class with ID and Name property):

So something must be going wrong when a model is applied to the Inherits="System.Web.ViewPage" attribute......

FINAL UPDATE - Please vote close: no longer relevant I somehow managed to get it working by:

  1. Re-referencing System.Web.Mvc (had it in GAC, went back to local-copy)
  2. Re-created view from Controller. Right-click controller action -> Create view... and modify from there

Hi,

for views in a MVC project the page directive has an inherits attribute:

<%@ Page Inherits="System.Web.Mvc.ViewPage" %>

It should be possible to use generics here and pass the class-type of the Model. However this is not accepted by VS2008:

<%@ Page Inherits="System.Web.Mvc.ViewPage(of IEnumerable(of MyNamespace.MyClass))" %>

I get the following validation-error (underlined in VS):
'Context' is not a member of 'ASP._views___home___index__asp'

I get the following runtime error:
BC30456: 'InitializeCulture' is not a member of 'ASP._views___home___index__asp'.

+3  A: 

Do it like this:

<%@ Page Inherits="System.Web.Mvc.ViewPage<IEnumerable<MyNamespace.MyClass>>" %>
Jon Benedicto
Sorry the page language is VB. This is C# syntax
Ropstah
it is the same syntax
Marwan Aouida
The site builds with this syntax, however at runtime: BC30205: End of statement expected.
Ropstah
A: 
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MyProject.Helpers.PaginatedList<MyProject.Models.Person>>" %>

Hope you got.

Vikas
Sorry the page language is VB. This is C# syntax
Ropstah
i can't really vote this up, but this helped me.
optician
A: 

Does anybody read anything from this?

C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE> "c:\WINDOWS\Microsoft.NET\Framework\v3.5\vbc.exe" /t:library /utf8output /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\assembly\dl3\56b70440\003d6f34_8989c901\EntitySpaces.SqlServerCeProvider.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.WorkflowServices\3.5.0.0__31bf3856ad364e35\System.WorkflowServices.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Abstractions\3.5.0.0__31bf3856ad364e35\System.Web.Abstractions.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions\3.5.0.0__31bf3856ad364e35\System.Web.Extensions.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\assembly\dl3\de7cc3b4\0097d136_8989c901\EntitySpaces.LoaderMT.DLL" /R:"C:\WINDOWS\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Runtime.Serialization\3.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\assembly\dl3\2afa6c79\006aa035_8989c901\EntitySpaces.NpgsqlProvider.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Xml.Linq\3.5.0.0__b77a5c561934e089\System.Xml.Linq.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Services\2.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\assembly\dl3\4a9a547a\006aa035_8989c901\EntitySpaces.OracleClientProvider.DLL" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\assembly\dl3\ea5276d6\0051153a_699ec901\System.Web.Mvc.DLL" /R:"C:\WINDOWS\assembly\GAC_32\System.Web\2.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\assembly\dl3\f8843c3a\0097d136_8989c901\EntitySpaces.Web.Design.DLL" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\assembly\dl3\4137948d\003d6f34_8989c901\EntitySpaces.Npgsql2Provider.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.ServiceModel\3.0.0.0__b77a5c561934e089\System.ServiceModel.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\assembly\dl3\b72019d9\003d6f34_8989c901\EntitySpaces.MySqlClientProvider.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Data.DataSetExtensions\3.5.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\App_global.asax.hiqvxvcm.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Data.Linq\3.5.0.0__b77a5c561934e089\System.Data.Linq.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\assembly\dl3\ad4567e4\006aa035_8989c901\EntitySpaces.Loader.DLL" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\assembly\dl3\b543038f\006aa035_8989c901\EntitySpaces.Core.DLL" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\assembly\dl3\701637c6\003d6f34_8989c901\EntitySpaces.VistaDBProvider.DLL" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\App_Web_vpbbzwke.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\assembly\dl3\66dcb3ba\006aa035_8989c901\EntitySpaces.Web.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Core\3.5.0.0__b77a5c561934e089\System.Core.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.ServiceModel.Web\3.5.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Routing\3.5.0.0__31bf3856ad364e35\System.Web.Routing.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\EC\1.0.0.0__2fce90138e5217ab\EC.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Mobile\2.0.0.0__b03f5f7f11d50a3a\System.Web.Mobile.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.IdentityModel\3.0.0.0__b77a5c561934e089\System.IdentityModel.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\assembly\dl3\750052d7\716d39b6_bfd3c901\VandaagLijst.DLL" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\assembly\dl3\d5308498\003d6f34_8989c901\EntitySpaces.MSAccessProvider.DLL" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\assembly\dl3\5ad7a5b5\006aa035_8989c901\EntitySpaces.SqlClientProvider.DLL" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\assembly\dl3\54566418\003d6f34_8989c901\EntitySpaces.Interfaces.DLL" /out:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\App_Web_p7uswgud.dll" /debug- /win32resource:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\p7uswgud.res" /define:_MYTYPE=\"Web\" /imports:Microsoft.VisualBasic,System,System.Collections,System.Collections.Specialized,System.Configuration,System.Text,System.Text.RegularExpressions,System.Web,System.Web.Caching,System.Web.SessionState,System.Web.Security,System.Web.Profile,System.Web.UI,System.Web.UI.WebControls,System.Web.UI.WebControls.WebParts,System.Web.UI.HtmlControls,System.Web.Mvc,System.Web.Mvc.Ajax,System.Web.Mvc.Html,System.Web.Routing,System.Linq,System.Collections.Generic,EC /warnaserror- /optionInfer+  "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\App_Web_p7uswgud.0.vb" "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\App_Web_p7uswgud.1.vb" "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\App_Web_p7uswgud.2.vb" "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\App_Web_p7uswgud.3.vb"

Microsoft (R) Visual Basic Compiler version 9.0.30729.1 Copyright (c) Microsoft Corporation. All rights reserved.

C:\Bugging\VandaagLijst\VandaagLijst\Views\home\List.aspx(1) : error BC30456: 'Title' is not a member of 'ASP.views_home_list_aspx'.

        __ctrl.Title = ""
        ~~~~~~~~~~~~

C:\Bugging\VandaagLijst\VandaagLijst\Views\home\List.aspx(1) : error BC30456: 'InitializeCulture' is not a member of 'ASP.views_home_list_aspx'.

        Me.InitializeCulture
        ~~~~~~~~~~~~~~~~~~~~

C:\Bugging\VandaagLijst\VandaagLijst\Views\home\List.aspx(1) : error BC30456: 'MasterPageFile' is not a member of 'ASP.views_home_list_aspx'.

        __ctrl.MasterPageFile = "~/Views/Shared/Site.Master"
        ~~~~~~~~~~~~~~~~~~~~~

C:\Bugging\VandaagLijst\VandaagLijst\Views\home\List.aspx(7) : error BC30456: 'AddContentTemplate' is not a member of 'ASP.views_home_list_aspx'.

        Me.AddContentTemplate("TitleContent", New System.Web.UI.CompiledTemplateBuilder(AddressOf Me.__BuildControlContent1))
        ~~~~~~~~~~~~~~~~~~~~~

C:\Bugging\VandaagLijst\VandaagLijst\Views\home\List.aspx(11) : error BC30456: 'AddContentTemplate' is not a member of 'ASP.views_home_list_aspx'.

        Me.AddContentTemplate("MainContent", New System.Web.UI.CompiledTemplateBuilder(AddressOf Me.__BuildControlContent2))
        ~~~~~~~~~~~~~~~~~~~~~

C:\Bugging\VandaagLijst\VandaagLijst\Views\home\List.aspx(13) : error BC30451: Name 'Model' is not declared.

       For Each item In Model
                        ~~~~~

c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\App_Web_p7uswgud.2.vb(42) : error BC30198: ')' expected.

    Inherits System.Web.Mvc.ViewPage(of IEnumerable(of Models.TestClass)
                                                                       ~

c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\App_Web_p7uswgud.2.vb(43) : error BC30154: Class 'views_home_list_aspx' must implement 'ReadOnly Property IsReusable() As Boolean' for interface 'System.Web.IHttpHandler'. Implementing property must have matching 'ReadOnly' or 'WriteOnly' specifiers.

    Implements System.Web.SessionState.IRequiresSessionState, System.Web.IHttpHandler
                                                              ~~~~~~~~~~~~~~~~~~~~~~~

c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\App_Web_p7uswgud.2.vb(43) : error BC30149: Class 'views_home_list_aspx' must implement 'Sub ProcessRequest(context As HttpContext)' for interface 'System.Web.IHttpHandler'.

    Implements System.Web.SessionState.IRequiresSessionState, System.Web.IHttpHandler
                                                              ~~~~~~~~~~~~~~~~~~~~~~~

c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\App_Web_p7uswgud.2.vb(55) : error BC30311: Value of type 'ASP.views_home_list_aspx' cannot be converted to 'System.Web.Mvc.ViewPage'.

        CType(Me,Global.System.Web.Mvc.ViewPage).AppRelativeVirtualPath = "~/Views/home/List.aspx"
              ~~

c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\App_Web_p7uswgud.2.vb(57) : error BC30456: 'ReadStringResource' is not a member of 'ASP.views_home_list_aspx'.

            Global.ASP.views_home_list_aspx.__stringResource = Me.ReadStringResource
                                                               ~~~~~~~~~~~~~~~~~~~~~

c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\App_Web_p7uswgud.2.vb(61) : error BC30456: 'GetWrappedFileDependencies' is not a member of 'ASP.views_home_list_aspx'.

            Global.ASP.views_home_list_aspx.__fileDependencies = Me.GetWrappedFileDependencies(dependencies)
                                                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\App_Web_p7uswgud.2.vb(68) : error BC30456: 'Context' is not a member of 'ASP.views_home_list_aspx'.

            Return CType(Me.Context.Profile,System.Web.Profile.DefaultProfile)
                         ~~~~~~~~~~

c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\App_Web_p7uswgud.2.vb(74) : error BC30456: 'Context' is not a member of 'ASP.views_home_list_aspx'.

            Return CType(Me.Context.ApplicationInstance,ASP.global_asax)
                         ~~~~~~~~~~

c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\App_Web_p7uswgud.2.vb(193) : error BC30284: sub 'FrameworkInitialize' cannot be declared 'Overrides' because it does not override a sub in a base class.

    Protected Overrides Sub FrameworkInitialize()
                            ~~~~~~~~~~~~~~~~~~~

c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\App_Web_p7uswgud.2.vb(195) : error BC30456: 'SetStringResourcePointer' is not a member of 'ASP.views_home_list_aspx'.

        Me.SetStringResourcePointer(Global.ASP.views_home_list_aspx.__stringResource, 0)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~

c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\App_Web_p7uswgud.2.vb(197) : error BC30456: 'AddWrappedFileDependencies' is not a member of 'ASP.views_home_list_aspx'.

        Me.AddWrappedFileDependencies(Global.ASP.views_home_list_aspx.__fileDependencies)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\App_Web_p7uswgud.2.vb(201) : error BC30284: function 'GetTypeHashCode' cannot be declared 'Overrides' because it does not override a function in a base class.

    Public Overrides Function GetTypeHashCode() As Integer
                              ~~~~~~~~~~~~~~~

c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\24f69041\8efa8a35\App_Web_p7uswgud.2.vb(206) : error BC30284: sub 'ProcessRequest' cannot be declared 'Overrides' because it does not override a sub in a base class.

    Public Overrides Sub ProcessRequest(ByVal context As System.Web.HttpContext)
                         ~~~~~~~~~~~~~~
Ropstah
+3  A: 

I had the same problem and it was caused by a missing reference. Or was using a repository pattern and implemented IDisposable. For them I imporated System.Data.Objects and System.Data.Objects.DataClasses as namespace and had to add System.Data.Enty as Reference and also had to add it to the list of assemblies in web.config using

<add assembly="System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

After doing so this strange error disappeared. So you might want to check your references.

Maik Koster
A: 

This might be a bug in visual studio intellisense. I have the same that inherited members are underlined in designer but I didn't got a runtime exception.

Christian13467