mvc的一个小问题

shumark 2014-07-17 01:52:26
问题描述:别人给我一aps.net的项目,让我看看,我也不知道应该帖那一段出来看看
里面有mvc的代码在里面,以前没有接触过
运行后出现以下几个问题
编译环境介绍:
开发方:用mvc版本未知
我自己本机的mvc的版本有2~4都有
vs2010
错误 2 在以下方法或属性之间的调用不明确:“System.Web.Mvc.T4Extensions.GetT4MVCResult(System.Web.Mvc.ActionResult)”和“System.Web.Mvc.T4Extensions.GetT4MVCResult(System.Web.Mvc.ActionResult)” E:\StraxImages+v2.0\StraxImages Source Code v2.0\app\StraxImages.WebUI\ImageController.generated.cs 30 28 StraxImages.WebUI


错误 59 在以下方法或属性之间的调用不明确:“System.Web.Mvc.T4Extensions.BeginForm(System.Web.Mvc.AjaxHelper, System.Web.Mvc.ActionResult, System.Web.Mvc.Ajax.AjaxOptions, object)”和“System.Web.Mvc.T4Extensions.BeginForm(System.Web.Mvc.AjaxHelper, System.Web.Mvc.ActionResult, System.Web.Mvc.Ajax.AjaxOptions, object)” E:\StraxImages+v2.0\StraxImages Source Code v2.0\app\StraxImages.WebUI\T4MVC.cs 108 20 StraxImages.WebUI


T4MVC.cs的代码
// <auto-generated />
// This file was generated by a T4 template.
// Don't change it directly as your change would get overwritten. Instead, make changes
// to the .tt file (i.e. the T4 template) and save it to regenerate this file.

// Make sure the compiler doesn't complain about missing Xml comments
#pragma warning disable 1591
#region T4MVC

using System;
using System.Diagnostics;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Web;
using System.Web.Hosting;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using System.Web.Mvc.Html;
using System.Web.Routing;
using T4MVC;

[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public static class MVC {
public static StraxImages.WebUI.Controllers.AnalysisHistoryController AnalysisHistory = new StraxImages.WebUI.Controllers.T4MVC_AnalysisHistoryController();
public static StraxImages.WebUI.Controllers.BaseController Base = new StraxImages.WebUI.Controllers.T4MVC_BaseController();
public static StraxImages.WebUI.Controllers.ClientController Client = new StraxImages.WebUI.Controllers.T4MVC_ClientController();
public static StraxImages.WebUI.Controllers.ErrorController Error = new StraxImages.WebUI.Controllers.T4MVC_ErrorController();
public static StraxImages.WebUI.Controllers.FilereferenceController Filereference = new StraxImages.WebUI.Controllers.T4MVC_FilereferenceController();
public static StraxImages.WebUI.Controllers.FolderController Folder = new StraxImages.WebUI.Controllers.T4MVC_FolderController();
public static StraxImages.WebUI.Controllers.HomeController Home = new StraxImages.WebUI.Controllers.T4MVC_HomeController();
public static StraxImages.WebUI.Controllers.ImageController Image = new StraxImages.WebUI.Controllers.T4MVC_ImageController();
public static StraxImages.WebUI.Controllers.NewRegistrationController NewRegistration = new StraxImages.WebUI.Controllers.T4MVC_NewRegistrationController();
public static StraxImages.WebUI.Controllers.PriceStructureController PriceStructure = new StraxImages.WebUI.Controllers.T4MVC_PriceStructureController();
public static StraxImages.WebUI.Controllers.ShareFolderListController ShareFolderList = new StraxImages.WebUI.Controllers.T4MVC_ShareFolderListController();
public static StraxImages.WebUI.Controllers.UserController User = new StraxImages.WebUI.Controllers.T4MVC_UserController();
public static T4MVC.SharedController Shared = new T4MVC.SharedController();
}

namespace T4MVC {
}


namespace System.Web.Mvc {
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public static class T4Extensions {
public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, ActionResult result) {
return htmlHelper.RouteLink(linkText, result);
}

public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, ActionResult result, object htmlAttributes) {
return ActionLink(htmlHelper, linkText, result, new RouteValueDictionary(htmlAttributes));
}

public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, ActionResult result, IDictionary<string, object> htmlAttributes) {
return htmlHelper.RouteLink(linkText, result, htmlAttributes);
}

public static MvcForm BeginForm(this HtmlHelper htmlHelper, ActionResult result) {
return htmlHelper.BeginForm(result, FormMethod.Post);
}

public static MvcForm BeginForm(this HtmlHelper htmlHelper, ActionResult result, FormMethod formMethod) {
return htmlHelper.BeginForm(result, formMethod, null);
}

public static MvcForm BeginForm(this HtmlHelper htmlHelper, ActionResult result, FormMethod formMethod, object htmlAttributes) {
return BeginForm(htmlHelper, result, formMethod, new RouteValueDictionary(htmlAttributes));
}

public static MvcForm BeginForm(this HtmlHelper htmlHelper, ActionResult result, FormMethod formMethod, IDictionary<string, object> htmlAttributes) {
var callInfo = result.GetT4MVCResult();
return htmlHelper.BeginForm(callInfo.Action, callInfo.Controller, callInfo.RouteValueDictionary, formMethod, htmlAttributes);
}

public static void RenderAction(this HtmlHelper htmlHelper, ActionResult result) {
var callInfo = result.GetT4MVCResult();
htmlHelper.RenderAction(callInfo.Action, callInfo.Controller, callInfo.RouteValueDictionary);
}

public static MvcHtmlString Action(this HtmlHelper htmlHelper, ActionResult result) {
var callInfo = result.GetT4MVCResult();
return htmlHelper.Action(callInfo.Action, callInfo.Controller, callInfo.RouteValueDictionary);
}
public static string Action(this UrlHelper urlHelper, ActionResult result) {
return urlHelper.RouteUrl(result.GetRouteValueDictionary());
}

#endregion T4MVC
#pragma warning restore 1591


字数有限,代码没有贴完

...全文
209 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
shumark 2014-07-23
  • 打赏
  • 举报
回复
最终我也没有找到结论,可能是Ptrtoptr老兄说的问题。 说说我的解决方案,我把官方的mvc引用都去了,重新编译的时候竟然通过了,我也不想太折腾,主要是为了帮朋打包部署,所以就囫囵吞枣了。 因为本人对mvc的工作机制不了解,所以就不做结贴了,亟待后来人总结!
Ptrtoptr 2014-07-21
  • 打赏
  • 举报
回复
假设你的公司里有两个人的名字一模一样, 在这两个人都在场的情况下,你叫他们的名字,他们俩都会分不清你到底在叫谁. 我认为这是错误的关键
shumark 2014-07-21
  • 打赏
  • 举报
回复
基本找了一圈,
 public static <#=ActionResultInterfaceName #> GetT4MVCResult(this ActionResult result) {
            var t4MVCResult = result as <#=ActionResultInterfaceName #>;
            if (t4MVCResult == null) {
                throw new InvalidOperationException("T4MVC was called incorrectly. You may need to force it to regenerate by right clicking on T4MVC.tt and choosing Run Custom Tool");
            }
            return t4MVCResult;
        }
是不是这个返回值不确定的问题?
Ptrtoptr 2014-07-19
  • 打赏
  • 举报
回复
我的看法你看下有用没. 在以下方法或属性之间的调用不明确:“ System.Web.Mvc.T4Extensions.GetT4MVCResult(System.Web.Mvc.ActionResult)” System.Web.Mvc.T4Extensions.GetT4MVCResult(System.Web.Mvc.ActionResult)” 比较这两个不明确的调用,它们一模一样,名字空间一样,函数名一样,参数一样.如果它们存在于一个.dll文件,那肯定 无法通过编译. 如果张三写了个dll,李四也写了dll ,他们在dll做了个函数,巧合的用了同样的函数名,函数参数,名字空间. 当把他俩写的dll都引到自己的项目里,这时就会报上面的错, 解决办法, 定位到出错的方法处, 在Visual object bowser中到找到方法的完全签名,并且能看到它引用那个dll.这样的话,干掉其中一个引用.这样就好了 仅供参考
shumark 2014-07-18
  • 打赏
  • 举报
回复
还有其他的肯能没,求指点!!!!
shumark 2014-07-18
  • 打赏
  • 举报
回复


我查找了GetT4MVCResult,没有发现重名
qxyywy 2014-07-17
  • 打赏
  • 举报
回复
错误 2 在以下方法或属性之间的调用不明确:“System.Web.Mvc.T4Extensions.GetT4MVCResult(System.Web.Mvc.ActionResult)”和“System.Web.Mvc.T4Extensions.GetT4MVCResult(System.Web.Mvc.ActionResult)” E:\StraxImages+v2.0\StraxImages Source Code v2.0\app\StraxImages.WebUI\ImageController.generated.cs 30 28 StraxImages.WebUI 类似这种调用不明的 你在项目里按文件全文搜索下对应的方法名 看下是否有重复的实现就知道了

62,047

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧