I have a generic usercontrol
FLControl<T> : UserControl, where T : Control
so that I can generate FLTextBox : FLControl<TextBox> etc. I remember being able to edit the FLControl<T> in the Designer without any problem. I hadn’t made any changes for a long time. And today, when I tried to open it, I got a designer error:
“Unable to cast object of type ‘Wisej.Web.UserControl’ to type ‘Wisej.Core.IWisejControl’.”
Has something changed? I am currently using version 1.4.95 and cannot recall which version I was using when first created the generic control.
Update: it looks like I have the same problem with non-generic usercontrols I have created earlier. Some give the error above.
It worked as you said, without step 6.
However, it keeps happening. I mean, if after a while try to open another form/usercontrol in the designer I get this kind of strange errors. So the question is, is there any way to avoid them altogether? Am I doing something fundamentally wrong?
This looks like a VS designer issue. The fact that it comes and goes tells me exactly that. Please try the following steps:
1. close all design views
2. clean the project
3. build the project
This ensures all DLLs are ready for the next time you open the project
4. close VS
5. Re-open VS and the the project
It should work. If it doesn’t, you need another step
6. rebuild again.
As you can see in the error message, it’s the same class not being to cast to itself. It’s because VS loads two copies of the same assembly. In .NET you can actually have the same class loaded more than once when the assembly is loaded from different locations. VS creates a copy of the assemblies it loads and sometimes fails to update one of the copies.
I don’t know if this is related, but today I tried to open another usercontrol in the designer and got the attached error. “baseTLP” is a TableLayoutPanel in the control, the error says the designer is trying to cast that from one type to another, fro a context “LoadNeither” to context “LoadFrom”, hope this makes some sense to you.
Thanks for your answer. It is VERY strange though, I just went to try it again so I send you the sample and it now WORKS!! It’s a pity I didn’t at least take a screenshot with the error, but the description was as in my original post. The only place I found “Wisej.Core.IWisejControl” was in the Wisej.Core.xml file in my bin folder, don’t know if this tells you something.
If I come across the error again I’ll let you know. However, I suspect that even if I send you a sample, it will work at your end….
Please login first to submit.