Type.AssemblyTypeName . having problems getting to my custom attribute

fguihen

Junior Contributor
Joined
Nov 10, 2003
Messages
248
Location
Eire
i have an assembly loaded into my app. im trying to get at the attributes of this assembly so i have this code :
Code:
foreach(Type OT in objDll.GetTypes()) 
{
AssemblyTypeName[] custInfo = (AssemblyTypeName[])OT.GetCustomAttributes(false);
}
the problem is that i cant cast the return of "getCustomAttributes to an AssemblyTypeName array. i can get the return values when i use this:
Code:
foreach(Type OT in objDll.GetTypes()) 
{
Object [] custInfo = (AssemblyTypeName[])OT.GetCustomAttributes(false);
}
the problem is that when i try this:
Code:
foreach( Object o in custInfo)
{
AssemblyTypeName atn = (AssemblyTypeName)o;
atn.mycustomAttribute........
}

i get an error here trying to cast the object to an AssemblyTypeName. what should i do? i can see my custom attribute and its value when i hover over the array and look at its contents , but i cant get to it.

Just so youl know, assemblyTypeName is my own attribute that i created.

i keep getting the error

"unable to cast object of type "EmpManagment.AssemblyTypeName" to type "EmpManagment.AssemblyTypeName"
 
Last edited:
found a solution. the Attribute and the class implementing the attribute were in the same namespace. once i put the attribute into a different namespace all worked. cant for the life of me think why it would have to be in a different namespace. could this be a bug?? if anyone can come up with an explination for why this is the case it would be great.
 
Back
Top