Meta-data on assemblies for CF...

A

Antao Almada

Hi,

I've created an assembly for CF that uses custom attributes.

I've also created an application, for "regular" framework, that uses
reflection to iterate through the classes of an assembly.

When using this application, on a PC, loading the CF assembly,
everything works fine, except for the custom attributes reading. The
method FieldInfo.GetCustomAttributes() always returns an empty array...

Can someone explain what's wrong?

Thanks in advance,
Antat

____________________________
Antao Almada
http://www.ydreams.com/

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
A

Antao Almada

I've been looking all over the web and the newsgroups, and still can't
find an answer for the problem.

I've looked into my CF assembly using Lutz Roeder's .NET Reflector and
the metadata is there...

I've looked into the source code of
OpenNETCF.Xml.Serialization.XmlSerializer and they use
GetCustomAttributes without problems...

Could it be that the "regular" method looks for the metadata in a
different place than the CF method? But it works fine on the Refletor,
with an identical scenario... ;-(

The reason I'm doing this is because I want to dinamically generate
another assembly, based on the classes and custom attributes of the
original assembly. Because CF does not support CodeDom, I'm doing this
on a "regular" framework application.

Do you have any suggestions?

Thanks...

Antao
____________________________
Antao Almada
http://www.ydreams.com/
 
A

Antao Almada

Solved!...

Found out that the problem were assembly "collisions". I had all the
assemblies in the same folder as the executable and classes were
implemented in two assemblies, one for CF, another for non-CF, creating
these "collisions".

The application is now loading the assemblies from a separate folder and
I'm handling the AppDomain.AssemblyResolver event to load them.

Sorry if I took your time...

Antao
____________________________
Antao Almada
http://www.ydreams.com/
 
J

Jonathan Pierce

Antao Almada said:
I've been looking all over the web and the newsgroups, and still can't
find an answer for the problem.

Could it be that the "regular" method looks for the metadata in a
different place than the CF method? But it works fine on the Refletor,
with an identical scenario... ;-(

The reason I'm doing this is because I want to dinamically generate
another assembly, based on the classes and custom attributes of the
original assembly. Because CF does not support CodeDom, I'm doing this
on a "regular" framework application.

Do you have any suggestions?

Antao,

In the 1.1 version of the .NET Framework, custom attributes in the
assembly and other metadata are not available via reflection. You will
either need to wait for 2.0, or directly read the metadata from the
PEFile using the unmanaged MetaData API. Read \Microsoft Visual Studio
..NET 2003\SDK\v1.1\Tool Developers Guide\docs\Metadata Unmanaged
API.doc for details.

You may also find our Decompiler.NET product useful which will produce
and output C# source code from the compiled assembly including the
custom attribute values that you are looking for. Our implementation
reads this info and other metadata not available through reflection
directly from the PE file to support COM Interop, etc. You can
download a free trial version from our web site at
http://www.junglecreatures.com/

Jonathan Pierce
President
Jungle Creatures, Inc.
http://www.junglecreatures.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top