0

我的BC30203: Identifier expectedASP.NET MVC 4 项目出现错误。我对为什么会发生这种情况一无所知,我感到非常沮丧。我不知道错误在哪里(除了班级)。

我什至好几天都没有碰过这个页面(上次它正在工作),现在我得到了错误。清除临时文件,.NET Framework 临时文件也无济于事,重新启动,重新安装 VS。我什至没有运气从 2010 切换到 2012RC。我完全不知所措。

我已经删除了越来越多的代码,而且每当我声明一个变量时似乎都会发生这种情况。这不是我的模型或其他任何东西,因为它们 100% 有效,只是不在这一页中。

以下是部分视图的代码:

@ModelType Frontend.Models.Collection 

@Code
    ViewData("Title") = "GetFilters"
End Code

@AddSeparator("Options")
@Options

@Helper Options()   

    Dim less As String=String.Empty
    @<div class="ui-splitbutton filter">
        <a class="@less" href="#" title="Show only basic filters" rel="nofollow">Show less</a>
        <a class="" href="#" title="Show all available filters" rel="nofollow">Show more</a> 
    </div>

    @<div>
        <a class="button clear_filters filter" href="#" title="Remove all applied filters" rel="nofollow">Clear filters</a>
     </div>

End Helper

@Helper AddSeparator(text As String)                                               
    @<div class="separator">
        <span>@text</span>
    </div>
End Helper

这是我呈现页面的方式:

@Code
    Html.RenderPartial("_PartialFilters", Model)
End code

这是一个例外:

System.Web.HttpCompileException was unhandled by user code
  ErrorCode=-2147467259
  HResult=-2147467259
  Message=C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\3a7646ef\5efed268\App_Web__partialfilters.vbhtml.34d3db15.w7n2unx9.0.vb(60): error BC30203: Identifier expected.
  Source=System.Web
  SourceCode=#ExternalChecksum("C:\Users\Amy Pond\Documents\ilovetv\Code\Store\Frontend\Views\Browse\_PartialFilters.vbhtml","{ff1816ec-aa5e-4d10-87f7-6f4963833460}","EE63B19A6BCF554D9625D51B8F673B27C85CCC09")
'------------------------------------------------------------------------------
' <auto-generated>
'     This code was generated by a tool.
'     Runtime Version:4.0.30319.17626
'
'     Changes to this file may cause incorrect behavior and will be lost if
'     the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------

Option Strict Off
Option Explicit On

Imports System
Imports System.Collections.Generic
Imports System.IO
Imports System.Linq
Imports System.Net
Imports System.Web
Imports System.Web.Helpers
Imports System.Web.Mvc
Imports System.Web.Mvc.Ajax
Imports System.Web.Mvc.Html
Imports System.Web.Routing
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.WebPages

Namespace ASP

    Public Class _Page_Views_Browse__PartialFilters_vbhtml
        Inherits System.Web.Mvc.WebViewPage(Of Frontend.Models.Collection)


#ExternalSource("C:\Users\Amy Pond\Documents\ilovetv\Code\Store\Frontend\Views\Browse\_PartialFilters.vbhtml", 10)
Public Function Options() As System.Web.WebPages.HelperResult

#End ExternalSource
Return New System.Web.WebPages.HelperResult(Sub (__razor_helper_writer)

#ExternalSource("C:\Users\Amy Pond\Documents\ilovetv\Code\Store\Frontend\Views\Browse\_PartialFilters.vbhtml", 10)


    Dim less As String=String.Empty

#End ExternalSource
BeginContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 202, 4, true)
WriteLiteralTo(__razor_helper_writer, "    ")
EndContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 202, 4, true)
BeginContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 207, 4, true)
WriteLiteralTo(__razor_helper_writer, "<div")
EndContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 207, 4, true)
BeginContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 211, 30, true)
WriteLiteralTo(__razor_helper_writer, " class=""ui-splitbutton filter""")
EndContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 211, 30, true)
BeginContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 241, 13, true)
WriteLiteralTo(__razor_helper_writer, ">"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"        <a")
EndContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 241, 13, true)
WriteAttributeTo(__razor_helper_writer, "class", Tuple.Create(" class=""", 254), Tuple.Create("""", 267) _, Tuple.Create(Tuple.Create("", 262), Tuple.Create(Of System.Object, System.Int32)(less _, 262), False) _)
BeginContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 268, 9, true)
WriteLiteralTo(__razor_helper_writer, " href=""#""")
EndContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 268, 9, true)
BeginContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 277, 32, true)
WriteLiteralTo(__razor_helper_writer, " title=""Show only basic filters""")
EndContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 277, 32, true)
BeginContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 309, 15, true)
WriteLiteralTo(__razor_helper_writer, " rel=""nofollow""")
EndContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 309, 15, true)
BeginContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 324, 26, true)
WriteLiteralTo(__razor_helper_writer, ">Show less</a>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"        <a")
EndContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 324, 26, true)
BeginContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 350, 9, true)
WriteLiteralTo(__razor_helper_writer, " class=""""")
EndContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 350, 9, true)
BeginContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 359, 9, true)
WriteLiteralTo(__razor_helper_writer, " href=""#""")
EndContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 359, 9, true)
BeginContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 368, 35, true)
WriteLiteralTo(__razor_helper_writer, " title=""Show all available filters""")
EndContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 368, 35, true)
BeginContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 403, 15, true)
WriteLiteralTo(__razor_helper_writer, " rel=""nofollow""")
EndContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 403, 15, true)
BeginContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 418, 29, true)
WriteLiteralTo(__razor_helper_writer, ">Show more</a> "&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"    </div>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
EndContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 418, 29, true)

#ExternalSource("C:\Users\Amy Pond\Documents\ilovetv\Code\Store\Frontend\Views\Browse\_PartialFilters.vbhtml", 17)


#End ExternalSource
BeginContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 449, 4, true)
WriteLiteralTo(__razor_helper_writer, "    ")
EndContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 449, 4, true)
BeginContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 454, 17, true)
WriteLiteralTo(__razor_helper_writer, "<div>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"        <a")
EndContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 454, 17, true)
BeginContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 471, 36, true)
WriteLiteralTo(__razor_helper_writer, " class=""button clear_filters filter""")
EndContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 471, 36, true)
BeginContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 507, 9, true)
WriteLiteralTo(__razor_helper_writer, " href=""#""")
EndContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 507, 9, true)
BeginContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 516, 35, true)
WriteLiteralTo(__razor_helper_writer, " title=""Remove all applied filters""")
EndContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 516, 35, true)
BeginContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 551, 15, true)
WriteLiteralTo(__razor_helper_writer, " rel=""nofollow""")
EndContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 551, 15, true)
BeginContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 566, 33, true)
WriteLiteralTo(__razor_helper_writer, ">Clear filters</a>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"     </div>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
EndContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 566, 33, true)

#ExternalSource("C:\Users\Amy Pond\Documents\ilovetv\Code\Store\Frontend\Views\Browse\_PartialFilters.vbhtml", 21)


#End ExternalSource
End Sub)
End Function


#ExternalSource("C:\Users\Amy Pond\Documents\ilovetv\Code\Store\Frontend\Views\Browse\_PartialFilters.vbhtml", 24)
Public Function AddSeparator(text As String) As System.Web.WebPages.HelperResult

#End ExternalSource
Return New System.Web.WebPages.HelperResult(Sub (__razor_helper_writer)

#ExternalSource("C:\Users\Amy Pond\Documents\ilovetv\Code\Store\Frontend\Views\Browse\_PartialFilters.vbhtml", 24)


#End ExternalSource
BeginContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 727, 4, true)
WriteLiteralTo(__razor_helper_writer, "    ")
EndContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 727, 4, true)
BeginContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 732, 4, true)
WriteLiteralTo(__razor_helper_writer, "<div")
EndContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 732, 4, true)
BeginContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 736, 18, true)
WriteLiteralTo(__razor_helper_writer, " class=""separator""")
EndContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 736, 18, true)
BeginContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 754, 17, true)
WriteLiteralTo(__razor_helper_writer, ">"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"        <span>")
EndContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 754, 17, true)
BeginContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 772, 4, false)

#ExternalSource("C:\Users\Amy Pond\Documents\ilovetv\Code\Store\Frontend\Views\Browse\_PartialFilters.vbhtml", 26)
WriteTo(__razor_helper_writer, text)

#End ExternalSource
EndContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 772, 4, false)
BeginContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 776, 21, true)
WriteLiteralTo(__razor_helper_writer, "</span>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"    </div>"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
EndContext(__razor_helper_writer, "~/Views/Browse/_PartialFilters.vbhtml", 776, 21, true)

#ExternalSource("C:\Users\Amy Pond\Documents\ilovetv\Code\Store\Frontend\Views\Browse\_PartialFilters.vbhtml", 28)

#End ExternalSource
End Sub)
End Function


        Public Sub New()
            MyBase.New
        End Sub

        Protected ReadOnly Property ApplicationInstance() As ASP.global_asax
            Get
                Return CType(Context.ApplicationInstance,ASP.global_asax)
            End Get
        End Property

        Public Overrides Sub Execute()
BeginContext("~/Views/Browse/_PartialFilters.vbhtml", 40, 2, true)

WriteLiteral(""&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))

EndContext("~/Views/Browse/_PartialFilters.vbhtml", 40, 2, true)


            #ExternalSource("C:\Users\Amy Pond\Documents\ilovetv\Code\Store\Frontend\Views\Browse\_PartialFilters.vbhtml",3)

    ViewData("Title") = "GetFilters"


            #End ExternalSource
BeginContext("~/Views/Browse/_PartialFilters.vbhtml", 95, 4, true)

WriteLiteral(""&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))

EndContext("~/Views/Browse/_PartialFilters.vbhtml", 95, 4, true)

BeginContext("~/Views/Browse/_PartialFilters.vbhtml", 100, 23, false)


            #ExternalSource("C:\Users\Amy Pond\Documents\ilovetv\Code\Store\Frontend\Views\Browse\_PartialFilters.vbhtml",7)
Write(AddSeparator("Options"))


            #End ExternalSource
EndContext("~/Views/Browse/_PartialFilters.vbhtml", 100, 23, false)

BeginContext("~/Views/Browse/_PartialFilters.vbhtml", 123, 2, true)

WriteLiteral(""&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))

EndContext("~/Views/Browse/_PartialFilters.vbhtml", 123, 2, true)

BeginContext("~/Views/Browse/_PartialFilters.vbhtml", 126, 7, false)


            #ExternalSource("C:\Users\Amy Pond\Documents\ilovetv\Code\Store\Frontend\Views\Browse\_PartialFilters.vbhtml",8)
Write(Options)


            #End ExternalSource
EndContext("~/Views/Browse/_PartialFilters.vbhtml", 126, 7, false)

BeginContext("~/Views/Browse/_PartialFilters.vbhtml", 133, 4, true)

WriteLiteral(""&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))

EndContext("~/Views/Browse/_PartialFilters.vbhtml", 133, 4, true)

BeginContext("~/Views/Browse/_PartialFilters.vbhtml", 638, 4, true)

WriteLiteral(""&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))

EndContext("~/Views/Browse/_PartialFilters.vbhtml", 638, 4, true)

        End Sub
    End Class
End Namespace

  WebEventCode=0
  StackTrace:
       at System.Web.Compilation.AssemblyBuilder.Compile()
       at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
       at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)
       at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
       at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
       at System.Web.Compilation.BuildManager.GetObjectFactory(String virtualPath, Boolean throwIfNotFound)
       at System.Web.Mvc.BuildManagerWrapper.System.Web.Mvc.IBuildManager.FileExists(String virtualPath)
       at System.Web.Mvc.BuildManagerViewEngine.FileExists(ControllerContext controllerContext, String virtualPath)
       at System.Web.Mvc.VirtualPathProviderViewEngine.<>c__DisplayClass4.<GetPathFromGeneralName>b__0(String path)
       at System.Web.WebPages.DefaultDisplayMode.GetDisplayInfo(HttpContextBase httpContext, String virtualPath, Func`2 virtualPathExists)
       at System.Web.WebPages.DisplayModeProvider.<>c__DisplayClassb.<GetDisplayInfoForVirtualPath>b__8(IDisplayMode mode)
       at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
       at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
       at System.Web.WebPages.DisplayModeProvider.GetDisplayInfoForVirtualPath(String virtualPath, HttpContextBase httpContext, Func`2 virtualPathExists, IDisplayMode currentDisplayMode, Boolean requireConsistentDisplayMode)
       at System.Web.WebPages.DisplayModeProvider.GetDisplayInfoForVirtualPath(String virtualPath, HttpContextBase httpContext, Func`2 virtualPathExists, IDisplayMode currentDisplayMode)
       at System.Web.Mvc.VirtualPathProviderViewEngine.GetPathFromGeneralName(ControllerContext controllerContext, List`1 locations, String name, String controllerName, String areaName, String cacheKey, String[]& searchedLocations)
       at System.Web.Mvc.VirtualPathProviderViewEngine.GetPath(ControllerContext controllerContext, String[] locations, String[] areaLocations, String locationsPropertyName, String name, String controllerName, String cacheKeyPrefix, Boolean useCache, String[]& searchedLocations)
       at System.Web.Mvc.VirtualPathProviderViewEngine.FindPartialView(ControllerContext controllerContext, String partialViewName, Boolean useCache)
       at System.Web.Mvc.ViewEngineCollection.<>c__DisplayClass8.<FindPartialView>b__7(IViewEngine e)
       at System.Web.Mvc.ViewEngineCollection.Find(Func`2 lookup, Boolean trackSearchedPaths)
       at System.Web.Mvc.ViewEngineCollection.Find(Func`2 cacheLocator, Func`2 locator)
       at System.Web.Mvc.ViewEngineCollection.FindPartialView(ControllerContext controllerContext, String partialViewName)
       at System.Web.Mvc.HtmlHelper.FindPartialView(ViewContext viewContext, String partialViewName, ViewEngineCollection viewEngineCollection)
       at System.Web.Mvc.HtmlHelper.RenderPartialInternal(String partialViewName, ViewDataDictionary viewData, Object model, TextWriter writer, ViewEngineCollection viewEngineCollection)
       at System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper htmlHelper, String partialViewName, Object model)
       at ASP._Page_Views_Browse_Index_vbhtml.Execute() in C:\Users\Amy Pond\Documents\ilovetv\Code\Store\Frontend\Views\Browse\Index.vbhtml:line 16
       at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
       at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
       at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
       at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance)
       at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer)
       at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
       at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17()
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
  InnerException: 
4

2 回答 2

2

当我有一个没有此行的简单页面时,我遇到了同样的问题,因为我不想要站点管理员。当我把它放进去时,它是好的。

<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
于 2012-08-02T05:44:06.483 回答
0

对于发生这种情况且无法解决的其他任何人...

对我来说,在部分页面中,我创建了很多下拉菜单和其他控件。我为此制作了一个助手,并将大部分代码移至 @Function 助手并使用 TagBuilder。

我不认为这是一个便宜的解决方法 - 太多了。我仍然不知道根本原因。

于 2012-07-26T05:07:56.460 回答