Hi, I have an attribute class defined as follows:
<AttributeUsage(AttributeTargets.Property Or
AttributeTargets.Field, Inherited:=True,
AllowMultiple:=True), Serializable()> _
Public Class DataColumnAttribute
Inherits System.Attribute
Private _TableName As String
Private _ColName As String
Private _PrimaryKey As Boolean
Private _AutoGen As Boolean
Private _Required As Boolean
Public Property TableName as string
...
End Property
...
End Class
Then I define class and mark its property as follows:
Public Class Customer
....
<DataColumnAttribute("Customer","ID",true,true,true)> _
public property ID as Integer
Get ..
Set ..
End Property
<DataColumnAttribute("Customer","Name",false,false,true)>
_
public property Name as string
Get ..
Set ..
End Property
....
End Class
Now I have another class that takes in an object marked
with the DataColumnAttribute, and generate a SQL string.
Public Class ObjectToSQL
....
The InsertSQL() function looks like following:
Public Function Insert() As String
Dim PropInfo As PropertyInfo
Dim PropAttribute As Attribute
Dim ColumnAttribute As DataColumnAttribute
....
For Each PropInfo In TableData.GetType.GetProperties
(BindingFlags.Instance Or BindingFlags.Public Or
BindingFlags.NonPublic)
For Each PropAttribute In PropInfo.GetCustomAttributes
(True)
If TypeOf PropAttribute Is DataColumnAttribute Then
...
Next PropAttribute
Next PropInfo
....
End Function
End Class
Each class is in a separate dll.
Now what happens is that this code works fine on my
machine. However, when the QA is testing the code on
their machine (also with .Net framework, and VS.Net), the
line "If TypeOf PropAttribute Is DataColumnAttribute
Then" always return false when I try to debug it.
However, if in the command window, the line "TypeOf
PropAttribute Is DataColumnAttribute" returns True. When
I put PropAttribute variable into the watch window, the
TypeID property shows that the type of the attribute is
DataColumnAttribute, however, the watch window couldn't
display the attribute's properties (TableName, ColName,
etc). In the value cell for those properties, it
displays an exception message. None of the dlls are
strongly typed or named.
Anyone has any idea why this might be occurring? Thanks.
|