Error in Form Designer after adding image to ImageList

716 views Asked by At

I have a problem. In a Visual Studio 2012 WindowsForm VC++/CLR mixed (/clr) project, after adding a small image to an image list control (ImageList) on design time, when the project is opened again later and the Form Designer opens, the following message appears:

"C++ CodeDOM parser error: Line: 387, Column: 18 --- Unknown type ''. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built."

The line is: this->components = (gcnew System::ComponentModel::Container());

I close the window with the message, reopen the desired Forms Designer, and everything appears correct. In addition, open the Designer sometimes fails or takes too long to open. The forms only fail if they appear when you load the project, but then it shows well. I worry that eventually this will cause a major fault. Lists of images are on the project from start, but unchanged in a long time, this problem now appears only after deser modified only by adding an image to the list. I returned to a previous version and then left the feature for later work. Why is this happening? This problem is holding back a lot of visual design changes.

1

There are 1 answers

0
Kushan On

In Visual Studio, there's an option under Tools -> Options -> Winforms Desinger called "Optimised Code Generation". When it's enabled (Which it seems to be by default), the designer is much flakier and throws errors like this. Changing it to false seems to fix the issue (or at least it did for me):

enter image description here