首先,我为我的 stackoverflow 问题尝试了一个较短版本的代码,但这不会导致我的编译器错误。另外,我不能使用 AspnetCompiler 而不是 MsBuild,因为我正在构建一个包含多个网站和类库的解决方案。我的构建服务器设置已经存在多年,我从来没有遇到过这样的问题。我有一个与 C# 一起广泛使用的 VB.Net 库,在该库中我有以下内容:
Public Class PropertyParticipants
Public Property Participants As List(Of Participant)
Private _propertyId As Integer
Public Sub New(propertyId As Integer)
Participants = New List(Of Participant)()
_propertyId = propertyId
LoadParticipants()
End Sub
End Class
Public Class Participant
Public Property Role As ParticipantRole
Public Property Type As ParticipantType
Public Property FirstName As String
Public Property LastName As String
Public Property Password As String
Public Property LoginId As String
Public Property Initials As String
Public Property UserId As Integer
Public ReadOnly Property FullName() As String
Get
Return Me.FirstName & " " & Me.LastName
End Get
End Property
Public Enum ParticipantRole
Primary
Party
Pending
End Enum
Public Enum ParticipantType
Seller
Buyer
End Enum
End Class
然后在我后面的 c# 代码中,我有以下内容
PropertyParticipants propPart = new PropertyParticipants(PropertyId);
foreach (Participant part in propPart.Participants.Where(p => p.Role != Participant.ParticipantRole.Pending))
{
int userId = part.UserId; //this is fine
string loginId = part.LoginId; //compiler error
}
错误 CS1061:“Participant”不包含“LoginId”的定义,并且找不到接受“Participant”类型的第一个参数的扩展方法“LoginId”(您是否缺少 using 指令或程序集引用?)