我有一个数据模型 - 由Linq2SQL类图工具创建 - 在另一个程序集(类库项目)中,我创建了另一个
这是:
public partial class Customer : INotifyPropertyChanging, INotifyPropertyChanged
{
private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
private int _ID;
private string _FirstName;
private string _LastName;
private string _Email;
private System.DateTime _DOB;
private string _PhoneNumber;
private bool _Activated;
private bool _Suspended;
//..
}
在我的Web项目中,我创建了另一个与partial相同的名称:
public partial class Customer
{
//It will have MetadataTypeAttribute for validation.
}
我正在为它们使用相同的命名空间,所以当我使用Customer对象强制键入View时,它们应该没问题:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Customer>" %>
我收到此错误:
[System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()]行 184:public class views_register_registrationformcontrol_ascx: System.Web.Mvc.ViewUserControl {
详细错误屏幕截图:http://i.imgur.com/Zrtx7.png
答案 0 :(得分:3)
问题是你不能在多个程序集中使用部分类:
检查此答案
Is it possible to have two partial classes in different assemblies represent the same class?