Usercontrol bug when exposing a class derived from a generic list -
11-28-2006
, 10:02 AM
This bug can be replicated by doing the following:
1) Create a new smart device application in visual studio 2005
2) Replace class1.cs with code below
3) Add a new user control
4) Replace usercontrol1.cs with code below
5) Build application
6) The error shown below occurs when attempting to drop the control on
a Form
It occurs when exposing a class from a usercontrol which inherits from
a generic list. I can workaround this problem by either changing the
code the property definition in the usercontrol to return a
List<Class2> or OuterClass2. This behaves as expected when creating a
Windows application using the full framework.
---------------------------- Class1.cs -------------------------------
using System.Collections.Generic;
namespace DeviceApplication1
{
public class OuterClass2
{
public Class1 Class2;
}
public class Class1 : List<Class2>
{
}
public class Class2
{
}
}
---------------------- Usercontrol1.cs ---------------------------
using System.Windows.Forms;
namespace DeviceApplication1
{
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}
public Class2 Test
{
get { return null; }
set { }
}
}
}
-------------Error-----------------------
Failed to create component 'UserControl1'. The error message follows:
'System.IO.FileLoadException: The given assembly name or codebase was
invalid. (Exception from HRESULT: 0x80131047)
at System.Reflection.AssemblyName.nInit(Assembly& assembly, Boolean
forIntrospection, Boolean raiseResolveEvent)
at System.Reflection.AssemblyName.nInit()
at System.Reflection.AssemblyName..ctor(String assemblyName)
at
Microsoft.CompactFramework.Design.DeviceTypeResolu tionService.GetDeviceType(String
typeName, Boolean throwOnError, Boolean ignoreCase)
at
Microsoft.CompactFramework.Design.DeviceTypeResolu tionService.GetDeviceType(Type
type, Boolean throwOnError, Boolean ignoreCase)
at
Microsoft.CompactFramework.Build.MetadataService.G etTypeAttributes(Type
desktopType)
at
Microsoft.CompactFramework.Design.DeviceCustomType Descriptor.CreateDeviceMetaProperty(PropertyDescri ptor
desktopProperty)
at
Microsoft.CompactFramework.Design.DeviceCustomType Descriptor.GetProperties(Attribute[]
attributes)
at
Microsoft.CompactFramework.Design.DeviceCustomType Descriptor.GetPr...' |