Friday, August 8, 2008

Custom TypeDescriptionProvider not being processed by Visual Studio Designer

While working with custom TypeDescriptionProvider's and setting TypeDescriptionProviderAttribute's on my classes, I found that my custom meta data was not being processed by the Visual Studio Datasources Window.

A single project had been created that contained both a Windows Form and my custom class files. This was just simply a test or "proof of concept" application so I just threw everything into one project. When I used the Data Sources window to add my class, Visual Studio was only showing the "real" properties of the class. This was in spite of the fact that I had decorated my class with the TypeDescriptionProviderAttribute pointing to my custom TypeDescriptionProvider that provided an extended list of properties. I knew the custom TypeDescriptionProvider was working correctly because I could create my data bindings in code.

I went to split up my single project into two differnt solutions so that I could debug the Visual Studio designer calls. I put the Window Form in one solution and my custom class and custom TypeDescriptionProvider in another solution. When I went to add my custom class to the Data Sources window of the Form solution, it came up correctly this time! Also, I tested the same with having one solution with two projects, and it still worked. So there must be a limitation or issue with having a TypeDescriptionProvider and attempting for the IDE to use it in the same project.

Conclusion, if you expect the Visual Studio IDE to process you Custom TypeDescriptionProvider, make sure those classes are in a separate project.

No comments: