Hello, I'm trying to add some custom properties on UltraToolbarManager, such as 'NABiButtonTypeProp' property on the button tooltype in the UltraToolbar, and so on. It seemed to work okay at the first time, but when I opened the UI design sometime later, it showed an error message. The part of the error message is Korean, so I'll translate it. The code of 'Tools' property could not be created. Error: '[A]NABi.Framework.UIControls.ToolProvider.CustomButtonTool cannot be casted to [B]NABi.Framework.UIControls.ToolProvider.CustomButtonTool. I made my source code, following the sample code provided by Infragistics. (The sample code is in the folder 'C:\Users\Public\Documents\Infragistics\2013.2\Windows Forms\Samples\Toolbars\VB\ToolProvider Component VB' - the sample codes that comes along when installing Infragistics.) I have no idea why this happens. I'll attach my sample code here. It'll be greatly appreciated if somebody checks the code and tells me what's wrong. Thanks a lot.
Hello Jun,
I looked at your sample, and I think I know what is going on.
The custom ToolbarsManager and tools are defined in the same sample project as the where they were being used. Unfortunately, when you recompile the project, Visual Studio which has already cached the types/assembly in the designer, creates new types. These types (though they may have identical code) are not the same, so it errors out.
I was able to solve this issue, by moving these derived classes to a separate class library which the main project references. Now, it is possible to recompile the main project without recompiling the derived classes. As such, I was able to add the custom tools at design-time, and they remained on the form.
Note that if there are changes required in the derived type, you'll need to restart visual studio to clear the caching and avoid the issue you were reporting.
I've attached my version of the sample for you to test.
Let us know if you have any further issues. Thanks,
Chris
Hi. Dimitar,
Sorry. I reuploaded another sample project on post.
This sample code has a form class with a custom class.
When I modify the custom tool class and compile, the custom tools disappear from the toolbar.
Hi Jun,
Thank you for posting in our forums.
Unfortunately I am not able to run or open the forms in the attached sample since it has some references, which I don’t have access to (the NABi and FarPoint references) so I can’t say what exactly is causing the issue.
What may give us more information about why it happens is if you try to debug the exception with another instance of visual studio. In order to do that open two instances of VS. In the first one open the solution with the error. In the other one use the “Debug” -> ”Attach to process” option and attach it to the first instance of VS. Again in the second instance of VS enable it to break on all exception (see how here - https://msdn.microsoft.com/en-us/library/x85tt0dd.aspx). Then in the first instance of VS replicate the error. Hopefully the second VS instance will show us exactly where the exception is happening.
I am looking forward to hearing from you.