我的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.xioduct6,Version=0.0.0.0,Culture=neutral,PublicKeyToken=null"加载类型"Sitaad.Models"
我该怎么办?
尝试从配置设置中删除App_Code
。在Web.Config
中,它应该看起来像这样:
<httpModules>
<add name="LanguageSettingModule" type="LanguageModule" />
</httpModules>