[Mono-devel-list] some strangeness with CustomAttributes
Rafael Teixeira
monoman at gmail.com
Sat Aug 28 15:25:08 EDT 2004
I second Marcus. Trying to decode your paragraph:
"And it works fine printing the class name as I would have expected but
if I change the attribute name to a new Attribute identical to
AssemblyDescription (but with a different name) and add that to a new
assembly (and compile the code above with the definition of the new
attribute) - the new custom attribute is not visible, now I can't see
any difference in the code for the AssemblyDescription and the new one I
have created."
Seems that maybe you've compiled the source for your Attribute into
both programs, so they are two different types, with similar partial
names (just look at the types Fullname to see that one has the
program's assembly-name in it and the other the library's
assembly-name).
You have to use only one compiled form of the attribute, so you have
an easy solution: reference the assembly containing your compiled
attribute (either that linux-user, or some other it references), but
this will make your program dependent on that particular assembly, so
if it's inside that "linux-user" assembly, you may have to move it to
a library that both your program and your library reference (-r:...)
Hope it helps,
On Fri, 27 Aug 2004 18:50:43 -0500, Marcus <mathpup at mylinuxisp.com> wrote:
> I'm not positive that I understand the second situation fully, but it sounds
> as though you are comparing a type in an external assembly against a type in
> the current assembly, but the current assembly does not link against the
> external one. In that case, I believe that the types are going to compare
> different. Two types with the same name and structure but in separate
> assemblies will compare different if they're both loaded from disk.
>
> Again, I might be off-base as far as the situation goes.
>
>
>
>
> On Friday 27 August 2004 3:57 am, Jonathan Stowe wrote:
>
> > What is even stranger is if I do:
> >
> > using System;
> > using System.Reflection;
> >
> > public class Test
> > {
> > public static void Main()
> > {
> > Assembly a = Assembly.LoadWithPartialName("Linux.User");
> >
> > object[] o = a.GetCustomAttributes(true);
> >
> > foreach (object x in a.GetCustomAttributes(true))
> > {
> > Console.WriteLine(x.GetType());
> > }
> > }
> > }
> >
> > The type of the attribute is printed out alongside all of the other ones
> > but I am unable to do a comparison against it's type (except by
> > comparing the type name). I guess I am missing the point here or
> > something, but can someone explain what is going on?
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
--
Rafael "Monoman" Teixeira
---------------------------------------
Cognition is not a representation of an objectively existing world
but is a bringing forth of a world in the process of living.
-- Fritjof Capra, citing
Humberto Maturana and Francisco Varella's "Santiago Theory of Cognition"
More information about the Mono-devel-list
mailing list