gpt4 book ai didi

asp.net-mvc - ASP.Net MVC 错误 - 错误的 IL 格式

转载 作者:行者123 更新时间:2023-12-04 07:11:50 25 4
gpt4 key购买 nike

我正在关注 ASP.Net MVC "TaskList" example video并单击在 Visual Studio 中运行(大约 14:00 分钟进入视频),我在浏览器中收到以下错误消息:

Server Error in '/' Application.

Bad IL format.
Description: An unhandled exception occurred during the execution of the
current webrequest. Please review the stack trace for more information
about the error andwhere it originated in the code.

Exception Details: System.BadImageFormatException: Bad IL format.

Source Error:

Line 12: ' (2) URL with parameters
Line 13: ' (3) Parameter defaults
Line 14: routes.MapRoute( _
Line 15: "Default", _
Line 16: "{controller}/{action}/{id}", _


Source File: C:\Users\...\TaskList\TaskList\Global.asax.vb Line: 14

Stack Trace:

[BadImageFormatException: Bad IL format.]
VB$AnonymousType_0`3..ctor(T0 controller, T1 action, T2 id) +0
TaskList.MvcApplication.RegisterRoutes(RouteCollection routes) in
C:\Users\...\TaskList\TaskList\Global.asax.vb:14
TaskList.MvcApplication.Application_Start() in
C:\Users\...\TaskList\TaskList\Global.asax.vb:23


Version Information:
Microsoft .NET Framework Version:2.0.50727.1434;
ASP.NET Version:2.0.50727.1434

我已经仔细检查了我输入的代码,我错过了什么?

谢谢!

版本:
  • ASP.Net MVC 测试版(2008 年 10 月 16 日)
  • Visual Studio 2008 (9.0.21022.8 RTM)
  • Vista Ultimate SP1
  • IIS 7.0.6000.16386
  • 最佳答案

    哦!

    发现问题,在HomeController.vb :

    Public Class HomeController
    Inherits System.Web.Mvc.Controller

    ' Display a list of tasks
    Function Index()
    Return View()
    End Function

    ' Dislpay a form for creating a new task
    Function Create() As ActionResult
    Return View()
    End Function

    ' Adding a new task to the database
    Function CreateNew(ByVal task As String) As ActionResult
    ' add the new task to the database
    Return RedirectToAction("Index")
    End Function

    ' Mark a task as complete
    Function Complete()
    ' database logic
    Return RedirectToAction("Index")
    End Function

    End Class
    Function Complete()缺少返回类型,它应该是:
        ' Mark a task as complete
    Function Complete() As ActionResult
    ' database logic
    Return RedirectToAction("Index")
    End Function

    感谢您的建议,我想下次我需要三重检查我的代码!

    (虽然如果编译器指向我的代码会很好,而不是 Global.asax.vb ,这让我认为这是一个配置问题)

    关于asp.net-mvc - ASP.Net MVC 错误 - 错误的 IL 格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/215719/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com