PC Review


Reply
Thread Tools Rate Thread

Cannot determine the type of an Attribute properly.

 
 
Luke Wang
Guest
Posts: n/a
 
      30th Jul 2003
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Determine field from attribute Mihajlo Cvetanović Microsoft C# .NET 4 19th Feb 2010 12:05 PM
Howto: Determine within a custom attribute, the type it has been declared on? Kenneth Baltrinic Microsoft Dot NET Framework 2 16th Mar 2007 07:18 PM
Dynamiclly Determine Type of Parameter and Type Cast it (code insi =?Utf-8?B?TGVubg==?= Microsoft C# .NET 1 14th Dec 2005 09:24 PM
determine if TCP or UDP port is working properly? Les Caudle Microsoft Windows 2000 Networking 2 25th Aug 2004 11:37 PM
[OT] Ping: Bob Adkins -- Please properly attribute quoted text! DC Freeware 2 27th Feb 2004 01:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:25 AM.