TypeConverter/InstanceDescriptor failing when ASP.NET project with my user control is compiled/run
<p>I am having problem with TypeConverter/InstanceDescriptor.</p>

<p>I have a class called MyClass</p>

<pre><code>public class MyClass
{
    private ICollection&lt;Color&gt; _colors;
    public MyClass(ICollection&lt;Color&gt; colors)
    {
     _colors = colors;
    }

    public MyClass(string colors)
    {
     if("MyColors".equals(colors))
     {
     .
     .
     .
     }
    }

    .
    .
    .
}
</code></pre>

<p>MyUserControl has property MyProperty of type MyClass.</p>

<p>Now, when i drag and drop this property, and change its value so that xml code is generated.
Now, i compile and end up with this error "Object reference not set to an instance of an object"</p>

<pre><code>public static ColorGenerator FromString(object value)
{
    TypeConverter tc = TypeDescriptor.GetConverter(typeof(MyClass));
    if (tc.CanConvertFrom(typeof(string)))
     return tc.ConvertFrom(null, null, value) as MyClass;
    else return null;
}
.
.
.
if(destinationType == typeof(InstanceDescriptor))
{
    MethodInfo mi = typeof(MyTypeConverter).GetMethod("FromString", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(string) }, null);
     return new InstanceDescriptor(mi, new object[] { "MyColors" }, true);
}
.
.
.
</code></pre>

<p>If my logic is as follows, then i end up with "Unable to generate code for a value of type 'MyNamespace.MyClass'. This error occurred while trying to generate the property value for MyClass." error when compiled.</p>

<pre><code>.
.
.
if(destinationType == typeof(InstanceDescriptor))
{
            ConstructorInfo ci = typeof(MyClass).GetConstructor(new Type[] { typeof(string) });
            InstanceDescriptor descriptor = new InstanceDescriptor(ci, new object[] { "LightColors" });
            return descriptor;
}
.
.
.
</code></pre>

<p>Can anyone please explain to me what these errors mean, and why they are happening?</p>

<p>Thanks a million in advance,
Anony.</p>
