【发布时间】:2016-07-26 18:03:59
【问题描述】:
我的 app_code 文件夹中有一个 Helper 函数
public static MvcHtmlString DisplayNameFor(string table, string FieldName)
{
string Name = "";
//Type tt = new FilesList().GetType();
//var Property = tt.GetProperty(FieldName);
Type tt = Type.GetType(table, true);
var Property = Activator.CreateInstance(tt.FullName,"FilesList").GetType().GetProperty(FieldName);
var attr = Attribute.GetCustomAttribute(Property, typeof(TurboDisplayAttribute));
if (attr.GetType() == typeof(TurboDisplayAttribute))
{
Name = ((TurboDisplayAttribute)attr).Name;
}
G gg = new G();
gg.SetDbContext(new ApplicationDbContext());
Name = gg.T(Name);
return new MvcHtmlString(Name);
}
但是当我在我的视图中使用这个助手时:
@Helpers.DisplayNameFor("Sitaad.Models", "Order")
它显示错误:无法从程序集“App_Code.xiomuct6, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null”中加载类型“Sitaad.Models”。
我该怎么办?
【问题讨论】:
标签: c# asp.net-mvc entity-framework model