1

This is very strange. I have a custom UserControl called UIControl. That user control has another custom control (derived from Label control).

This worked OK for long time. Both at design time and at run time. However, now, I needed to edit that custom UIControl but the Visual Studio 2019 shows this error message:

Visual Studio Design View

This error means that the RealTime.DigitalClock is not found. As you see in the project, that control is not part of an external assembly, but the same assembly where UIControl is.

I have compiled and recompiled thousand of times and compilations finish perfectly. Even the application runs.

Furthermore, when I build the project, those user controls appear in tool box, but when I try to place it in any form, an error telling that the component could not be added and it will be removed from the tool box is shown.

I don't really know what is happening here. I have even closed and re-open VS 2019 but no avail.

Regards Jaime

jstuardo
  • 3,901
  • 14
  • 61
  • 136
  • This is because the serialized version no longer matches the compiled version. The only way to fix it is to open the designer and delete the control, then open the resx and delete the control there, then add it back in. There are ways to control the serialization so that doesn't happen in the future, but it's too late now. – Ron Beyer Dec 31 '19 at 22:45

1 Answers1

1

According to To prevent possible data loss in windows form c#, I suggest that you can do as the following steps.

First, Please find all the RealTime.DigitalClock related code in UIControl.designer and UIControl.cs.

Second, you can delete the above code.

Third, you need to rewrite the code you just deleted.

Finally, rebuild it and check if it works for you.

Jack J Jun
  • 5,633
  • 1
  • 9
  • 27
  • I'm afraid but it did not work. The most curious thing is that this screen shows that digitalClock and digitalDate variables are not declared or never used, however, I can see both assignments in InitializeComponent method. – jstuardo Jan 06 '20 at 18:23
  • 1
    I have realized that the problem was due because my VS 2019 is 32 bits and I was compiling the project using 64 bits platform.I am wondering why the VS2019 installer installed 32 bits version.Doesn't VS 2019 exist for 64 bits platform? I am using Community Edition. – jstuardo Jan 06 '20 at 19:47
  • Yes, you are right. As usual, there is no 64-bit version of Visual Studio. For more information, you could look at [Visual Studio 64 bit?](https://stackoverflow.com/a/35948345/11507778). – Jack J Jun Jan 07 '20 at 02:06