Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS 2010 designer error 'Could not find type XYZ' in Windows7. Works fine in XP

I'm stuck on a problem in VS 2010 C# .NET. I've had a project on Windows XP that includes forms, classes and a handful of my own custom components. These components are simple extensions of built-in MS components (e.g. DataGridViewEx as an extension of DataGridView). Everything has worked fine in XP. I'm trying to port this project over to VS 2010 on Windows 7 / x64. I've got the solution to compile OK on Windows 7, however in design mode, when I open a form that contains one of the custom controls, I get an error 'Could not find type XYZ.DataGridViewEx. Please make sure that the assembly that contains this type is referenced.' XYZ is the namespace I use for these controls and it is the same namespace as the forms that are using the controls. All are part of the same VS project.

When I open a form in the same project that does not contain one of these custom controls, that form opens OK in the designer, and I see the custom controls along the left side in the toolbox. However if I then try to drag one of these controls into that form, it pops up an error message box 'Failed to load toolbox item 'DataGridViewEx'. It will be removed from the toolbox.' And then it gets removed from the toolbox.

Everything was always working fine in VS solution in XP. This problem only occurs in the VS solution in Windows 7 / x64.

I don't understand why it complains about not being able to find the component, since the component is part of the same project. That's a valid thing to do, isn't it?

I've search the web/forums and found cases of the 'Could not find type' error, but it seemed to be caused by a different issue, and I haven't yet found a way to get rid of the error.

Any help/tips are much appreciated!

like image 205
jble Avatar asked Oct 14 '12 00:10

jble


People also ask

Why can’t I open the designer in Visual Studio 2010?

Anyone who’s used Visual Studio 2010 [1] for a non-trivial Windows Forms project has run into situations wherein the designer can no longer be opened. Usually, it’s because the class encounters null-reference exceptions when referencing data that is unavailable until runtime.

Why could not find type ‘system Windows Forms usercontrol’?

I get the following error: Could not find type ‘System.Windows.Forms.UserControl’. 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 using settings for your current platform or Any CPU.

Why are the Designer files not available in the solution Directory?

It was unofficially available because the assemblies were included in the solution-local third-party folder, but the designer files were not.

Could not find type 'mynamespace'?

Could not find type 'MyNamespace.CommonUi.InformationBox'. 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 using settings for your current platform or Any CPU.


1 Answers

If your project is targeted at 64 bit, you need to build for 32 bit and choose the 32-bit solution while doing your GUI editing. This is because studio is 32-bit so cannot load 64-bit controls.

like image 76
Richard Whitehead Avatar answered Oct 12 '22 23:10

Richard Whitehead