Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a large solution, say 60-ish projects. One of the project is a library that contains controls.

One of the controls it contains is a textbox class derived from TextBox, e.g.,

C#
using System;
using System.Windows.Forms;

// MySpecialTextBox.cs in a MyClassLibrary project.  The form I am trying
// to design is in the main EXE's project, and the main EXE's project has a project
// reference to MyClassLibrary which is also a member of the solution.
namespace MyNamespace
{
    public class MySpecialTextBox : TextBox 
    {
        // ...
    }
}


When I open the form on which I've placed an instance of this control in the past (when the Designer was somehow working), I now receive the error message screen "To prevent possible data loss before loading the designer, the following errors must be resolved:"

"Could not find the type 'MyNamespace.MySpecialTextBox.' Please make sure that the assembly that contains the type is referenced. If this type is a part of your development project, make sure that the project has been successfully built using settings for your current platform or Any CPU."

What I have tried:

When I open the form on which I've placed an instance of this control in the past (when the Designer was somehow working), I now receive the error message screen "To prevent possible data loss before loading the designer, the following errors must be resolved:"

"Could not find the type 'MyNamespace.MySpecialTextBox.' Please make sure that the assembly that contains the type is referenced. If this type is a part of your development project, make sure that the project has been successfully built using settings for your current platform or Any CPU."


I have tried the following:

  • Open Configuration Editor and make sure the checkboxes under the "Build" columns are all checked and that there is no conflicting Platform configurations (the solution platforms are only x64/x86 and every sub-project is the same configuration)
  • Doing as many Stack Overflow articles have suggested: Build -> Clean Solution, Build -> Rebuild Solution, exit Visual Studio, delete all bin and obj folders and then re-open Visual Studio. Error still shows up. My entire solution builds perfectly.
  • Pretty much everything else on Google. This shows up with controls directly derived off of .NET Framework standard controls, or UserControl as well. It's like the Designer has become allergic to custom controls or something.
  • I have verified that there are no broken references anywhere in my solution by going and expanding the references folders one by one and checking, fixing any yellow-triangle references (where Visual Studio is complaining about missing/broken references.
  • This happens in both Visual Studio 2010 with all the updates applied as well as the very latest version of Visual Studio 2017 with all the updates applied.
  • </ul

    Anyone have any idea what is going on?
Posted
Updated 23-Oct-17 14:25pm
v2
Comments
GKP1992 24-Oct-17 0:18am    
That usually happens when I change the dot net framework, the designer files get corrupted and I cannot see anything on the designer. Is this the case?
Hermann Jung 24-Oct-17 2:17am    
Open a second VS instance, attach debugger to first instance, enable exceptions "break when thrown" in second instance. Now try to open form-designer in first instance. I hope this will give you a clue - good luck.
Richard MacCutchan 24-Oct-17 4:17am    
The message is clearly telling you that the assembly containing this class cannot be found. You need to determine why by looking at the references you have included in your project(s). It may be that the assembly just needs to be rebuilt.
Richard Deeming 24-Oct-17 12:52pm    
The obvious workaround would be to move the control library to a separate solution, and replace the project reference with an assembly reference.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900