开发者

Returning Views After Upgrading to MVC3 VS2010 and .NET 4.0

I listed all the upgraded parts as I have no idea which one might be effecting this part of the code.

The project used to be MVC1 VS2008 and .NET 3.5 but I am currently working on upgrading it to MVC3 VS2010 and .NET 4.0.

One of the many problems I've been having (but have so far been unable to fix) is that I get the error:

System.MethodAccessException: Attempt by method 'ProjectSup开发者_JAVA百科port.Web.Controllers.ChangesController2<TChange,TChangeService>.Edit(Int32, ProjectSupport.Core.Services.IProjectEntityService)' to access method 'System.Web.Mvc.Controller.View(System.String)' failed.

when I run my unit tests, but I have had no problems running the program is it is. It seems that the error is being caused when I return views by a string, but I don't know if it has the same problem when it returns views by any other method as I don't have any examples of that I can test against.

Here is a sample of the code that is causing the problem:

[AcceptVerbs(HttpVerbs.Get)]
    public ActionResult Details(int id, IAuthenticationService authenticationService)
    {
        var change = GetEntity(id);
        var person = authenticationService.AuthenticatedPerson();

        ViewData.Model = change;

        if (ChangeOwnedByPerson(change, person))
            return View("DeveloperDetails");

        return View("Details");
    }

Note that this code works fine in practice and worked fine before upgrading. Anyone have any ideas that could point me in the right direction?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜