Designtime Attributes - next one...

G

Guest

VS2005 / netcf application / custom controls / custom designer (running in
..NET)

I have a custom visual controls - UI editor which I need to port from .NET
towards .NETCF (its basically both a graphical editor and an XML serializer
for separating the GUI code from the design).

Now both, VS designer and my designer need access to the control properties
attributes. I understand that with VS05 there are 2 DLLs generated - the
'regular' DLL used by the VS designer and the *asm.dll which is for the
device. In addition we have the XMTA design attributes data as XML file.

Now, in order to access design time attributes for custom controls: I
somehow don't get access to them through the DLL. I tried a lot of different
things but I can only get attributes that are inherited but not the
attributes which belong to my custom property e.g. Text1 (see debug output of
my reflection results below).

What am I missing or (I almost suspect) is the VS designer just reading the
XMTA and adding the attributes 'in parallel / through a side-door' ?

Here's my code snip: - it gets to the types but does not have any results on
custom property attributes:

foreach (Type t in mytypes)
{
Console.WriteLine("Type: " + t.Name);
PropertyInfo[] pi = t.GetProperties();

foreach (PropertyInfo p in pi)
{
Console.WriteLine("Property: " + p.Name);
Object[] myAttributes =
p.GetCustomAttributes(inheritFlag);
ShowAttributeData(CustomAttributeData.GetCustomAttributes(p));
}
}

***************
Property: Text1
No Attributes

Property: AutoSiz
[System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)0)]
[System.ComponentModel.BrowsableAttribute((Boolean)True)
[System.ComponentModel.DesignerSerializationVisibilityAttribute((System.ComponentModel.DesignerSerializationVisibility)1)]
Property: AutoSizeMode
[System.ComponentModel.BrowsableAttribute((Boolean)True)]
[System.Windows.Forms.SRCategoryAttribute("CatLayout")]
..
...
....
 
G

Guest

One thing I just verified: if I create and assign an attribute at source
level, my reflection code will find it. It will show up in the custom
attribute field of the class designer but it will not show up in the XMTA
file.

I guess I'm getting confused somewhere.

Thanks again for helping out!

tb
 
T

Tim Wilson

Now both, VS designer and my designer need access to
the control properties attributes. I understand that with
VS05 there are 2 DLLs generated - the 'regular' DLL
used by the VS designer and the *asm.dll which is for the
device. In addition we have the XMTA design attributes
data as XML file.

The control assembly, let's say ControlLibrary1.dll, is used at both runtime
and design-time. This is where the actual control definition exists. The
metadata assembly, let's say ControlLibrary1.PocketPC.asmmeta.dll, is a
"hollowed-out" version of the control assembly but with the information that
was specified in the xmta file added in the form of attributes. This
assembly is loaded by the designer to access meta information about the
control. Some of this information includes property/event descriptions,
property/event categories, property default values, etc. So the designer
uses both assemblies, ControlLibrary1.dll and
ControlLibrary1.PocketPC.asmmeta.dll, while the device only uses the control
assembly, ControlLibrary1.dll. The reason being that the Compact Framework
does not support the main attributes used to create a design-time experience
for smart device controls.
What am I missing or (I almost suspect) is the VS designer
just reading the XMTA and adding the attributes 'in
parallel / through a side-door' ?

The designer is reading the metadata assembly, *.asmmeta.dll, which was
built from the control assembly and the xmta file.

--
Tim Wilson
..NET Compact Framework MVP

tb2000 said:
VS2005 / netcf application / custom controls / custom designer (running in
.NET)

I have a custom visual controls - UI editor which I need to port from .NET
towards .NETCF (its basically both a graphical editor and an XML serializer
for separating the GUI code from the design).

Now both, VS designer and my designer need access to the control properties
attributes. I understand that with VS05 there are 2 DLLs generated - the
'regular' DLL used by the VS designer and the *asm.dll which is for the
device. In addition we have the XMTA design attributes data as XML file.

Now, in order to access design time attributes for custom controls: I
somehow don't get access to them through the DLL. I tried a lot of different
things but I can only get attributes that are inherited but not the
attributes which belong to my custom property e.g. Text1 (see debug output of
my reflection results below).

What am I missing or (I almost suspect) is the VS designer just reading the
XMTA and adding the attributes 'in parallel / through a side-door' ?

Here's my code snip: - it gets to the types but does not have any results on
custom property attributes:

foreach (Type t in mytypes)
{
Console.WriteLine("Type: " + t.Name);
PropertyInfo[] pi = t.GetProperties();

foreach (PropertyInfo p in pi)
{
Console.WriteLine("Property: " + p.Name);
Object[] myAttributes =
p.GetCustomAttributes(inheritFlag);
ShowAttributeData(CustomAttributeData.GetCustomAttributes(p));
}
}

***************
Property: Text1
No Attributes

Property: AutoSize
[System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.Edito
rBrowsableState)0)]
[System.ComponentModel.BrowsableAttribute((Boolean)True)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute((System.Comp
onentModel.DesignerSerializationVisibility)1)]
Property: AutoSizeMode
[System.ComponentModel.BrowsableAttribute((Boolean)True)]
[System.Windows.Forms.SRCategoryAttribute("CatLayout")]
.
..
...
 
G

Guest

Thanks, Tim!

So I at least assumed correctly that the designer is not getting the
attributes from the CL1.DLL but from CL1.asmmeta.dll. Accordingly I have to
inspect the *.asmmety.DLL if I need access to these data.
However I cann not access that DLL - is there any special API somewhere I
can use to read the property attributes from the asmmeta DLL?

********

System.Reflection.ReflectionTypeLoadException: Unable to load one or more of
the requested types. Retrieve the LoaderExceptions property for more
information.
at System.Reflection.Module.GetTypesInternal(StackCrawlMark& stackMark)
at System.Reflection.Assembly.GetTypes()
at TestFrame1.TestFrameF1.button1_Click(Object sender, EventArgs e) in
N:\ehome\TestStuff\TestFrame1\TestFrameF1.cs:line 40
at System.Reflection.Module.GetTypesInternal(StackCrawlMark& stackMark)
at System.Reflection.Assembly.GetTypes()
at TestFrame1.TestFrameF1.button1_Click(Object sender, EventArgs e) in
N:\ehome\TestStuff\TestFrame1\TestFrameF1.cs:line 40



Tim Wilson said:
Now both, VS designer and my designer need access to
the control properties attributes. I understand that with
VS05 there are 2 DLLs generated - the 'regular' DLL
used by the VS designer and the *asm.dll which is for the
device. In addition we have the XMTA design attributes
data as XML file.

The control assembly, let's say ControlLibrary1.dll, is used at both runtime
and design-time. This is where the actual control definition exists. The
metadata assembly, let's say ControlLibrary1.PocketPC.asmmeta.dll, is a
"hollowed-out" version of the control assembly but with the information that
was specified in the xmta file added in the form of attributes. This
assembly is loaded by the designer to access meta information about the
control. Some of this information includes property/event descriptions,
property/event categories, property default values, etc. So the designer
uses both assemblies, ControlLibrary1.dll and
ControlLibrary1.PocketPC.asmmeta.dll, while the device only uses the control
assembly, ControlLibrary1.dll. The reason being that the Compact Framework
does not support the main attributes used to create a design-time experience
for smart device controls.
What am I missing or (I almost suspect) is the VS designer
just reading the XMTA and adding the attributes 'in
parallel / through a side-door' ?

The designer is reading the metadata assembly, *.asmmeta.dll, which was
built from the control assembly and the xmta file.

--
Tim Wilson
..NET Compact Framework MVP

tb2000 said:
VS2005 / netcf application / custom controls / custom designer (running in
.NET)

I have a custom visual controls - UI editor which I need to port from .NET
towards .NETCF (its basically both a graphical editor and an XML serializer
for separating the GUI code from the design).

Now both, VS designer and my designer need access to the control properties
attributes. I understand that with VS05 there are 2 DLLs generated - the
'regular' DLL used by the VS designer and the *asm.dll which is for the
device. In addition we have the XMTA design attributes data as XML file.

Now, in order to access design time attributes for custom controls: I
somehow don't get access to them through the DLL. I tried a lot of different
things but I can only get attributes that are inherited but not the
attributes which belong to my custom property e.g. Text1 (see debug output of
my reflection results below).

What am I missing or (I almost suspect) is the VS designer just reading the
XMTA and adding the attributes 'in parallel / through a side-door' ?

Here's my code snip: - it gets to the types but does not have any results on
custom property attributes:

foreach (Type t in mytypes)
{
Console.WriteLine("Type: " + t.Name);
PropertyInfo[] pi = t.GetProperties();

foreach (PropertyInfo p in pi)
{
Console.WriteLine("Property: " + p.Name);
Object[] myAttributes =
p.GetCustomAttributes(inheritFlag);
ShowAttributeData(CustomAttributeData.GetCustomAttributes(p));
}
}

***************
Property: Text1
No Attributes

Property: AutoSize
[System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.Edito
rBrowsableState)0)]
[System.ComponentModel.BrowsableAttribute((Boolean)True)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute((System.Comp
onentModel.DesignerSerializationVisibility)1)]
Property: AutoSizeMode
[System.ComponentModel.BrowsableAttribute((Boolean)True)]
[System.Windows.Forms.SRCategoryAttribute("CatLayout")]
.
..
...
 
T

Tim Wilson

Are you attempting to access the asmmeta assembly on the desktop or the
device?

--
Tim Wilson
..NET Compact Framework MVP

tb2000 said:
Thanks, Tim!

So I at least assumed correctly that the designer is not getting the
attributes from the CL1.DLL but from CL1.asmmeta.dll. Accordingly I have to
inspect the *.asmmety.DLL if I need access to these data.
However I cann not access that DLL - is there any special API somewhere I
can use to read the property attributes from the asmmeta DLL?

********

System.Reflection.ReflectionTypeLoadException: Unable to load one or more of
the requested types. Retrieve the LoaderExceptions property for more
information.
at System.Reflection.Module.GetTypesInternal(StackCrawlMark& stackMark)
at System.Reflection.Assembly.GetTypes()
at TestFrame1.TestFrameF1.button1_Click(Object sender, EventArgs e) in
N:\ehome\TestStuff\TestFrame1\TestFrameF1.cs:line 40
at System.Reflection.Module.GetTypesInternal(StackCrawlMark& stackMark)
at System.Reflection.Assembly.GetTypes()
at TestFrame1.TestFrameF1.button1_Click(Object sender, EventArgs e) in
N:\ehome\TestStuff\TestFrame1\TestFrameF1.cs:line 40



Tim Wilson said:
Now both, VS designer and my designer need access to
the control properties attributes. I understand that with
VS05 there are 2 DLLs generated - the 'regular' DLL
used by the VS designer and the *asm.dll which is for the
device. In addition we have the XMTA design attributes
data as XML file.

The control assembly, let's say ControlLibrary1.dll, is used at both runtime
and design-time. This is where the actual control definition exists. The
metadata assembly, let's say ControlLibrary1.PocketPC.asmmeta.dll, is a
"hollowed-out" version of the control assembly but with the information that
was specified in the xmta file added in the form of attributes. This
assembly is loaded by the designer to access meta information about the
control. Some of this information includes property/event descriptions,
property/event categories, property default values, etc. So the designer
uses both assemblies, ControlLibrary1.dll and
ControlLibrary1.PocketPC.asmmeta.dll, while the device only uses the control
assembly, ControlLibrary1.dll. The reason being that the Compact Framework
does not support the main attributes used to create a design-time experience
for smart device controls.
What am I missing or (I almost suspect) is the VS designer
just reading the XMTA and adding the attributes 'in
parallel / through a side-door' ?

The designer is reading the metadata assembly, *.asmmeta.dll, which was
built from the control assembly and the xmta file.

--
Tim Wilson
..NET Compact Framework MVP

tb2000 said:
VS2005 / netcf application / custom controls / custom designer (running in
.NET)

I have a custom visual controls - UI editor which I need to port from ..NET
towards .NETCF (its basically both a graphical editor and an XML serializer
for separating the GUI code from the design).

Now both, VS designer and my designer need access to the control properties
attributes. I understand that with VS05 there are 2 DLLs generated - the
'regular' DLL used by the VS designer and the *asm.dll which is for the
device. In addition we have the XMTA design attributes data as XML file.

Now, in order to access design time attributes for custom controls: I
somehow don't get access to them through the DLL. I tried a lot of different
things but I can only get attributes that are inherited but not the
attributes which belong to my custom property e.g. Text1 (see debug
output
of
my reflection results below).

What am I missing or (I almost suspect) is the VS designer just
reading
the
XMTA and adding the attributes 'in parallel / through a side-door' ?

Here's my code snip: - it gets to the types but does not have any
results
on
custom property attributes:

foreach (Type t in mytypes)
{
Console.WriteLine("Type: " + t.Name);
PropertyInfo[] pi = t.GetProperties();

foreach (PropertyInfo p in pi)
{
Console.WriteLine("Property: " + p.Name);
Object[] myAttributes =
p.GetCustomAttributes(inheritFlag);
ShowAttributeData(CustomAttributeData.GetCustomAttributes(p));
}
}

***************
Property: Text1
No Attributes

Property: AutoSize
[System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.Edito
rBrowsableState)0)]
[System.ComponentModel.BrowsableAttribute((Boolean)True)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute((System.Comp
onentModel.DesignerSerializationVisibility)1)]
Property: AutoSizeMode
[System.ComponentModel.BrowsableAttribute((Boolean)True)]
[System.Windows.Forms.SRCategoryAttribute("CatLayout")]
.
..
...
 
G

Guest

On the desktop.

My app needs access to the control props attributes, similar to the VS
designer.

My control lib is basically handled by the external UI editor which fully
serializes the result, including a group of custom controls which have some
custom properties AND some designer / VS type (the usual suspects, Category,
Browseable and so on) attributes. My custom attribs I can get from the main
..dll but I need the designer attributes as well.

Interestingly the Assembly.LoadFile() still seems to be ok but then upon
a.GetTypes() I don't get the types but an exception ;-)

'TestFrame1.vshost.exe' (Managed): Loaded
'N:\ehome\TestStuff\CF_TestControl1\bin\Debug\CF_TestControl1.PocketPC.asmmeta.dll', No symbols loaded.
Loader Exception Could not load file or assembly
'System.Windows.Forms.PocketPC.asmmeta, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=969db8053d3322ac' or one of its dependencies. Das System kann
die angegebene Datei nicht finden.
Unable to access DLL
A first chance exception of type
'System.Reflection.ReflectionTypeLoadException' occurred in mscorlib.dll



Tim Wilson said:
Are you attempting to access the asmmeta assembly on the desktop or the
device?

--
Tim Wilson
..NET Compact Framework MVP

tb2000 said:
Thanks, Tim!

So I at least assumed correctly that the designer is not getting the
attributes from the CL1.DLL but from CL1.asmmeta.dll. Accordingly I have to
inspect the *.asmmety.DLL if I need access to these data.
However I cann not access that DLL - is there any special API somewhere I
can use to read the property attributes from the asmmeta DLL?

********

System.Reflection.ReflectionTypeLoadException: Unable to load one or more of
the requested types. Retrieve the LoaderExceptions property for more
information.
at System.Reflection.Module.GetTypesInternal(StackCrawlMark& stackMark)
at System.Reflection.Assembly.GetTypes()
at TestFrame1.TestFrameF1.button1_Click(Object sender, EventArgs e) in
N:\ehome\TestStuff\TestFrame1\TestFrameF1.cs:line 40
at System.Reflection.Module.GetTypesInternal(StackCrawlMark& stackMark)
at System.Reflection.Assembly.GetTypes()
at TestFrame1.TestFrameF1.button1_Click(Object sender, EventArgs e) in
N:\ehome\TestStuff\TestFrame1\TestFrameF1.cs:line 40



Tim Wilson said:
Now both, VS designer and my designer need access to
the control properties attributes. I understand that with
VS05 there are 2 DLLs generated - the 'regular' DLL
used by the VS designer and the *asm.dll which is for the
device. In addition we have the XMTA design attributes
data as XML file.

The control assembly, let's say ControlLibrary1.dll, is used at both runtime
and design-time. This is where the actual control definition exists. The
metadata assembly, let's say ControlLibrary1.PocketPC.asmmeta.dll, is a
"hollowed-out" version of the control assembly but with the information that
was specified in the xmta file added in the form of attributes. This
assembly is loaded by the designer to access meta information about the
control. Some of this information includes property/event descriptions,
property/event categories, property default values, etc. So the designer
uses both assemblies, ControlLibrary1.dll and
ControlLibrary1.PocketPC.asmmeta.dll, while the device only uses the control
assembly, ControlLibrary1.dll. The reason being that the Compact Framework
does not support the main attributes used to create a design-time experience
for smart device controls.

What am I missing or (I almost suspect) is the VS designer
just reading the XMTA and adding the attributes 'in
parallel / through a side-door' ?

The designer is reading the metadata assembly, *.asmmeta.dll, which was
built from the control assembly and the xmta file.

--
Tim Wilson
..NET Compact Framework MVP

VS2005 / netcf application / custom controls / custom designer (running in
.NET)

I have a custom visual controls - UI editor which I need to port from ..NET
towards .NETCF (its basically both a graphical editor and an XML
serializer
for separating the GUI code from the design).

Now both, VS designer and my designer need access to the control
properties
attributes. I understand that with VS05 there are 2 DLLs generated - the
'regular' DLL used by the VS designer and the *asm.dll which is for the
device. In addition we have the XMTA design attributes data as XML file.

Now, in order to access design time attributes for custom controls: I
somehow don't get access to them through the DLL. I tried a lot of
different
things but I can only get attributes that are inherited but not the
attributes which belong to my custom property e.g. Text1 (see debug output
of
my reflection results below).

What am I missing or (I almost suspect) is the VS designer just reading
the
XMTA and adding the attributes 'in parallel / through a side-door' ?

Here's my code snip: - it gets to the types but does not have any results
on
custom property attributes:

foreach (Type t in mytypes)
{
Console.WriteLine("Type: " + t.Name);
PropertyInfo[] pi = t.GetProperties();

foreach (PropertyInfo p in pi)
{
Console.WriteLine("Property: " + p.Name);
Object[] myAttributes =
p.GetCustomAttributes(inheritFlag);
ShowAttributeData(CustomAttributeData.GetCustomAttributes(p));
}
}

***************
Property: Text1
No Attributes

Property: AutoSize

[System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.Edito
rBrowsableState)0)]
[System.ComponentModel.BrowsableAttribute((Boolean)True)]

[System.ComponentModel.DesignerSerializationVisibilityAttribute((System.Comp
onentModel.DesignerSerializationVisibility)1)]
Property: AutoSizeMode
[System.ComponentModel.BrowsableAttribute((Boolean)True)]
[System.Windows.Forms.SRCategoryAttribute("CatLayout")]
.
..
...
 
T

Tim Wilson

The easiest way to resolve this is to add the metadata assembly
(*.asmmeta.dll) to the "designer metadata" directory. For CF 2.0, this
directory would be the following...

[VS 2005 Install
Dir]\SmartDevices\SDK\CompactFramework\2.0\v2.0\WindowsCE\DesignerMetadata\

This should allow the dependency to the
System.Windows.Forms.PocketPC.asmmeta.dll assembly to be found.

--
Tim Wilson
..NET Compact Framework MVP

tb2000 said:
On the desktop.

My app needs access to the control props attributes, similar to the VS
designer.

My control lib is basically handled by the external UI editor which fully
serializes the result, including a group of custom controls which have some
custom properties AND some designer / VS type (the usual suspects, Category,
Browseable and so on) attributes. My custom attribs I can get from the main
.dll but I need the designer attributes as well.

Interestingly the Assembly.LoadFile() still seems to be ok but then upon
a.GetTypes() I don't get the types but an exception ;-)

'TestFrame1.vshost.exe' (Managed): Loaded
'N:\ehome\TestStuff\CF_TestControl1\bin\Debug\CF_TestControl1.PocketPC.asmme
ta.dll', No symbols loaded.
Loader Exception Could not load file or assembly
'System.Windows.Forms.PocketPC.asmmeta, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=969db8053d3322ac' or one of its dependencies. Das System kann
die angegebene Datei nicht finden.
Unable to access DLL
A first chance exception of type
'System.Reflection.ReflectionTypeLoadException' occurred in mscorlib.dll



Tim Wilson said:
Are you attempting to access the asmmeta assembly on the desktop or the
device?

--
Tim Wilson
..NET Compact Framework MVP

tb2000 said:
Thanks, Tim!

So I at least assumed correctly that the designer is not getting the
attributes from the CL1.DLL but from CL1.asmmeta.dll. Accordingly I
have
to
inspect the *.asmmety.DLL if I need access to these data.
However I cann not access that DLL - is there any special API somewhere I
can use to read the property attributes from the asmmeta DLL?

********

System.Reflection.ReflectionTypeLoadException: Unable to load one or
more
of
the requested types. Retrieve the LoaderExceptions property for more
information.
at System.Reflection.Module.GetTypesInternal(StackCrawlMark& stackMark)
at System.Reflection.Assembly.GetTypes()
at TestFrame1.TestFrameF1.button1_Click(Object sender, EventArgs e) in
N:\ehome\TestStuff\TestFrame1\TestFrameF1.cs:line 40
at System.Reflection.Module.GetTypesInternal(StackCrawlMark& stackMark)
at System.Reflection.Assembly.GetTypes()
at TestFrame1.TestFrameF1.button1_Click(Object sender, EventArgs e) in
N:\ehome\TestStuff\TestFrame1\TestFrameF1.cs:line 40



:

Now both, VS designer and my designer need access to
the control properties attributes. I understand that with
VS05 there are 2 DLLs generated - the 'regular' DLL
used by the VS designer and the *asm.dll which is for the
device. In addition we have the XMTA design attributes
data as XML file.

The control assembly, let's say ControlLibrary1.dll, is used at both runtime
and design-time. This is where the actual control definition exists. The
metadata assembly, let's say ControlLibrary1.PocketPC.asmmeta.dll, is a
"hollowed-out" version of the control assembly but with the
information
that
was specified in the xmta file added in the form of attributes. This
assembly is loaded by the designer to access meta information about the
control. Some of this information includes property/event descriptions,
property/event categories, property default values, etc. So the designer
uses both assemblies, ControlLibrary1.dll and
ControlLibrary1.PocketPC.asmmeta.dll, while the device only uses the control
assembly, ControlLibrary1.dll. The reason being that the Compact Framework
does not support the main attributes used to create a design-time experience
for smart device controls.

What am I missing or (I almost suspect) is the VS designer
just reading the XMTA and adding the attributes 'in
parallel / through a side-door' ?

The designer is reading the metadata assembly, *.asmmeta.dll, which was
built from the control assembly and the xmta file.

--
Tim Wilson
..NET Compact Framework MVP

VS2005 / netcf application / custom controls / custom designer (running in
.NET)

I have a custom visual controls - UI editor which I need to port
from
..NET
towards .NETCF (its basically both a graphical editor and an XML
serializer
for separating the GUI code from the design).

Now both, VS designer and my designer need access to the control
properties
attributes. I understand that with VS05 there are 2 DLLs
generated -
the
'regular' DLL used by the VS designer and the *asm.dll which is
for
the
device. In addition we have the XMTA design attributes data as XML file.

Now, in order to access design time attributes for custom controls: I
somehow don't get access to them through the DLL. I tried a lot of
different
things but I can only get attributes that are inherited but not the
attributes which belong to my custom property e.g. Text1 (see
debug
output
of
my reflection results below).

What am I missing or (I almost suspect) is the VS designer just reading
the
XMTA and adding the attributes 'in parallel / through a side-door' ?

Here's my code snip: - it gets to the types but does not have any results
on
custom property attributes:

foreach (Type t in mytypes)
{
Console.WriteLine("Type: " + t.Name);
PropertyInfo[] pi = t.GetProperties();

foreach (PropertyInfo p in pi)
{
Console.WriteLine("Property: " + p.Name);
Object[] myAttributes =
p.GetCustomAttributes(inheritFlag);
ShowAttributeData(CustomAttributeData.GetCustomAttributes(p));
}
}

***************
Property: Text1
No Attributes

Property: AutoSize
[System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.Edito
rBrowsableState)0)]
[System.ComponentModel.BrowsableAttribute((Boolean)True)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute((System.Comp
onentModel.DesignerSerializationVisibility)1)]
Property: AutoSizeMode
[System.ComponentModel.BrowsableAttribute((Boolean)True)]
[System.Windows.Forms.SRCategoryAttribute("CatLayout")]
.
..
...
 
G

Guest

Could I get a little more background? It would be great if I can just keep
the metadate where they are and resolve the problem by code. What's it about
with the dll you indicated: System.Windows.Forms.PocketPC.asmmeta.dll. I can
browse it - there seems a lot of duplicate types in it from
System.Windows.Form namespace - but I could not find any more details.

Thanks
Theo

Tim Wilson said:
The easiest way to resolve this is to add the metadata assembly
(*.asmmeta.dll) to the "designer metadata" directory. For CF 2.0, this
directory would be the following...

[VS 2005 Install
Dir]\SmartDevices\SDK\CompactFramework\2.0\v2.0\WindowsCE\DesignerMetadata\

This should allow the dependency to the
System.Windows.Forms.PocketPC.asmmeta.dll assembly to be found.

--
Tim Wilson
..NET Compact Framework MVP

tb2000 said:
On the desktop.

My app needs access to the control props attributes, similar to the VS
designer.

My control lib is basically handled by the external UI editor which fully
serializes the result, including a group of custom controls which have some
custom properties AND some designer / VS type (the usual suspects, Category,
Browseable and so on) attributes. My custom attribs I can get from the main
.dll but I need the designer attributes as well.

Interestingly the Assembly.LoadFile() still seems to be ok but then upon
a.GetTypes() I don't get the types but an exception ;-)

'TestFrame1.vshost.exe' (Managed): Loaded
'N:\ehome\TestStuff\CF_TestControl1\bin\Debug\CF_TestControl1.PocketPC.asmme
ta.dll', No symbols loaded.
Loader Exception Could not load file or assembly
'System.Windows.Forms.PocketPC.asmmeta, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=969db8053d3322ac' or one of its dependencies. Das System kann
die angegebene Datei nicht finden.
Unable to access DLL
A first chance exception of type
'System.Reflection.ReflectionTypeLoadException' occurred in mscorlib.dll



Tim Wilson said:
Are you attempting to access the asmmeta assembly on the desktop or the
device?

--
Tim Wilson
..NET Compact Framework MVP

Thanks, Tim!

So I at least assumed correctly that the designer is not getting the
attributes from the CL1.DLL but from CL1.asmmeta.dll. Accordingly I have
to
inspect the *.asmmety.DLL if I need access to these data.
However I cann not access that DLL - is there any special API somewhere I
can use to read the property attributes from the asmmeta DLL?

********

System.Reflection.ReflectionTypeLoadException: Unable to load one or more
of
the requested types. Retrieve the LoaderExceptions property for more
information.
at System.Reflection.Module.GetTypesInternal(StackCrawlMark& stackMark)
at System.Reflection.Assembly.GetTypes()
at TestFrame1.TestFrameF1.button1_Click(Object sender, EventArgs e) in
N:\ehome\TestStuff\TestFrame1\TestFrameF1.cs:line 40
at System.Reflection.Module.GetTypesInternal(StackCrawlMark& stackMark)
at System.Reflection.Assembly.GetTypes()
at TestFrame1.TestFrameF1.button1_Click(Object sender, EventArgs e) in
N:\ehome\TestStuff\TestFrame1\TestFrameF1.cs:line 40



:

Now both, VS designer and my designer need access to
the control properties attributes. I understand that with
VS05 there are 2 DLLs generated - the 'regular' DLL
used by the VS designer and the *asm.dll which is for the
device. In addition we have the XMTA design attributes
data as XML file.

The control assembly, let's say ControlLibrary1.dll, is used at both
runtime
and design-time. This is where the actual control definition exists. The
metadata assembly, let's say ControlLibrary1.PocketPC.asmmeta.dll, is a
"hollowed-out" version of the control assembly but with the information
that
was specified in the xmta file added in the form of attributes. This
assembly is loaded by the designer to access meta information about the
control. Some of this information includes property/event descriptions,
property/event categories, property default values, etc. So the designer
uses both assemblies, ControlLibrary1.dll and
ControlLibrary1.PocketPC.asmmeta.dll, while the device only uses the
control
assembly, ControlLibrary1.dll. The reason being that the Compact
Framework
does not support the main attributes used to create a design-time
experience
for smart device controls.

What am I missing or (I almost suspect) is the VS designer
just reading the XMTA and adding the attributes 'in
parallel / through a side-door' ?

The designer is reading the metadata assembly, *.asmmeta.dll, which was
built from the control assembly and the xmta file.

--
Tim Wilson
..NET Compact Framework MVP

VS2005 / netcf application / custom controls / custom designer
(running in
.NET)

I have a custom visual controls - UI editor which I need to port from
..NET
towards .NETCF (its basically both a graphical editor and an XML
serializer
for separating the GUI code from the design).

Now both, VS designer and my designer need access to the control
properties
attributes. I understand that with VS05 there are 2 DLLs generated -
the
'regular' DLL used by the VS designer and the *asm.dll which is for
the
device. In addition we have the XMTA design attributes data as XML
file.

Now, in order to access design time attributes for custom controls: I
somehow don't get access to them through the DLL. I tried a lot of
different
things but I can only get attributes that are inherited but not the
attributes which belong to my custom property e.g. Text1 (see debug
output
of
my reflection results below).

What am I missing or (I almost suspect) is the VS designer just
reading
the
XMTA and adding the attributes 'in parallel / through a side-door' ?

Here's my code snip: - it gets to the types but does not have any
results
on
custom property attributes:

foreach (Type t in mytypes)
{
Console.WriteLine("Type: " + t.Name);
PropertyInfo[] pi = t.GetProperties();

foreach (PropertyInfo p in pi)
{
Console.WriteLine("Property: " + p.Name);
Object[] myAttributes =
p.GetCustomAttributes(inheritFlag);
ShowAttributeData(CustomAttributeData.GetCustomAttributes(p));
}
}

***************
Property: Text1
No Attributes

Property: AutoSize


[System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.Edito
rBrowsableState)0)]
[System.ComponentModel.BrowsableAttribute((Boolean)True)]


[System.ComponentModel.DesignerSerializationVisibilityAttribute((System.Comp
onentModel.DesignerSerializationVisibility)1)]
Property: AutoSizeMode
[System.ComponentModel.BrowsableAttribute((Boolean)True)]
[System.Windows.Forms.SRCategoryAttribute("CatLayout")]
.
..
...
 
G

Guest

Tim,
in addition I did what you suggested and regardless if I pick the asmmety
file from the bin/debug or the VS-tree I still get the same exception
?
Theo
 
G

Guest

One more of my today's research results:

You probably know the reflector tool
http://www.aisto.com/roeder/dotnet/

When I load the asmmeta I get a disassembly of the type in question and this
shows my metadata / the designer related attributes. The readme says:
"Reflector uses a code model library for reading assembly files into memory
and no longer relies on the .NET Reflection API. "

Anyhow - at least we know the data must be in the file - question is how to
access it?
 
T

Tim Wilson

One way that you can handle dependency load failure is to hook the
AssemblyResolve event of the CurrentDomain.

AppDomain.CurrentDomain.AssemblyResolve += new
ResolveEventHandler(CurrentDomain_AssemblyResolve);

....

private static Assembly CurrentDomain_AssemblyResolve(object sender,
ResolveEventArgs args)
{
AssemblyName asmName = new AssemblyName(args.Name);

if (asmName.Name.EndsWith("asmmeta"))
{
try
{
string installRoot = null;

using (RegistryKey key =
Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\.NETCompactFramework\v
2.0.0.0\InstallRoot"))
{
installRoot = (string)key.GetValue(null);
}

return Assembly.LoadFrom(installRoot + @"WindowsCE\DesignerMetadata\"
+ asmName.Name + ".dll");
}
catch { }
}
return null;
}

This code determines if the assembly that failed to load ends with the text
"asmmeta". Within the context of your application I would assume that this
would indicate a failure to load a design-time metadata assembly dependency.
With this assumption, and the assumption that you're targeting CF 2.0, the
location of the designer metadata assemblies is constructed. The dependency
assembly is then loaded, and thus resolved.

To handle retrieving the attributes you can do something similar to the code
below.

private void button1_Click(object sender, EventArgs e)
{
if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
{
Assembly asm = Assembly.LoadFrom(this.openFileDialog1.FileName);

this.treeView1.BeginUpdate();
this.treeView1.Nodes.Clear();

foreach (Type tp in asm.GetTypes())
{
TreeNode typeNode = new TreeNode(tp.Name);

foreach (PropertyInfo propInfo in tp.GetProperties())
{
TreeNode propNode = new TreeNode(propInfo.Name);

foreach (object attr in propInfo.GetCustomAttributes(false))
{
string str = attr.ToString();

int index = str.LastIndexOf('.');
if ((index > -1) && (index < (str.Length - 1)))
{
str = str.Substring(index + 1);
}
str += ": ";

if (attr is CategoryAttribute)
{
str += ((CategoryAttribute)attr).Category;
}
else if (attr is DefaultValueAttribute)
{
object defValue = ((DefaultValueAttribute)attr).Value ?? "null";
str += defValue.ToString();
}
else if (attr is DescriptionAttribute)
{
str += ((DescriptionAttribute)attr).Description;
}
else
{
str += "Unknown";
}

propNode.Nodes.Add(new TreeNode(str));
}

typeNode.Nodes.Add(propNode);
}

this.treeView1.Nodes.Add(typeNode);
}

this.treeView1.EndUpdate();
}
}

This code uses an OpenFileDialog to prompt for the custom control metadata
assembly (ControlLibrary1.PocketPC.asmmeta.dll). It then iterates over the
types and displays the properties and their attributes in a TreeView.
 
T

Tim Wilson

You probably know the reflector tool
Yes. IMO, this is an extremely valuable tool to have as a developer.
 
Top