Why is this TypeConverter not working?

后端 未结 6 2050
北海茫月
北海茫月 2020-12-29 09:06

I am trying to understand why the below code is not working as expected; the TypeDescriptor is simply not picking up the custom converter from the attributes. I

6条回答
  •  清歌不尽
    2020-12-29 10:04

    The answer to this other question should be applicable here. It is a much simpler solution than subscribing to AssemblyResolve.

    In summary, the idea is to set the TypeConverter attribute using the full string name of the type converter class, rather than using typeof to provide the class name.

    In other words, instead of doing this:

    [TypeConverterAttribute(typeof(TestConverter))]
    public struct Test
    {
        ...
    }
    

    do this:

    [TypeConverterAttribute("MyTest.TestConverter")]
    public struct Test
    {
        ...
    }
    

提交回复
热议问题