Getting TypeConverter error that makes no sense
-
20-09-2019 - |
Question
I have a TypeConverter for a TopMostNode class. It extends ExpandableObjectConverter. The TopMostNode has two properties. Setting those in the property grid results in correctly serialized code to the designer. However, if I type in text for the property, I get a "Property value is not valid" error and the details say:
Object of type 'TopMostNode' cannot be converted to type 'TopMostNode'.
I'm baffled. When I step through the type converter ConvertFrom code, it runs as expected. I don't even know were to start looking for an issue like this.
Solution
You probably have two different versions of the same assembly loaded.
OTHER TIPS
I had the same problem while developing a control for the .NET Framework 4.0 client profile, when all the design-time functionality was in a separate DLL. The problem appeared when I loaded both projects (the core control and its design-time part) as one solution into VS. However, all worked fine when I tried to use the compiled production version of my control in other projects.
The conclusion is the following: before starting to debug your TypeConverter code, try to use the compiled version of your control outside of the control development projects.
P.S. To get the design-time functionality available for my control while developing it, I placed the design-time part DLL into the PrivateAssemblies folder of VS.