2

For serialization/deserialization purposes I'd like set a TypeConverter for a type located in an external, compiled assembly.

I stumbled over this question but the provided solution does not seem to be working for me: Add TypeConverter attribute to enum in runtime

TypeDescriptor.AddAttributes(typeof(ExternalType),
new TypeConverterAttribute(typeof(ExternalTypeTypeConverter)));

Calling

TypeDescriptor.GetAttributes(typeof(ExternalType));

returns the attribute as expected, but calling

TypeDescriptor.GetConverter(typeof(ExternalType));

does not return the previously added converter but just the TypeConverter base class.

1 Answer 1

1

After some experimenting it turns out that the solution was already correct but was not working due to my run configuration. When using the "normal" entry point everything works fine (I was using the static debug hook of the latest ReSharper release, see http://blog.jetbrains.com/dotnet/2015/08/28/run-configurations-debug-any-static-method-in-visual-studio-and-more/)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.