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

10

19

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!

Smooth answered 14/10, 2012 at 0:8 Comment(3)
I got it working by creating a new Class Library within the solution, and moving all the components from the original project over to the new class library, and changing the designer references to point to the new class library namespace. It was a pain, but it works.Smooth
i found that creating a new class essentially duplicated the problem into the newly named class...Cw
@Smooth you should post your solution as an answer and mark it answered in case others stumble upon this.Boycott
I
23

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.

Imminent answered 12/6, 2013 at 14:24 Comment(4)
I cannot believe that VS2010 does not even warn about this being a possible cause for trouble! It was exactly the culprit in my case. Thanks!Velez
After a long time of debugging this blew my mind. The problem is still present in VS2013. Will probably never be fixed.Pincince
Very sloppy development on Microsoft's part.Nasser
let's bring some YouTube feeling to this site: "Who's here in 2020?"Agribusiness
W
1

Ive run into this before, be sure that in your Form.Designer.cs code file, that each call to your custom controls are done so as absolute calls. For example:

Namespace.CustomControl control;

Rather than

CustomControl control;
Weiland answered 14/10, 2012 at 0:17 Comment(3)
Thanks - yes, I've checked this. The calls are done as absolute calls (fully qualified with namespace). Problem still occurs in Windows 7.Smooth
Just a check here, did you change the architecture setting in your project settings? This may have something or nothing to do with your current problem, but since you are going from x86 to x86_64 this would be a wise move, unless you want it backward compatible with x86. Honestly I can't remember exactly how I fixed this in previous projects.Weiland
was there any conclusion to this issue?Cw
B
1

Look at your references and find any that have exclamation point icons. Remove the bad references and add them back to your project.

Belisle answered 19/11, 2012 at 18:0 Comment(0)
S
0

Have you tried disabling UAC completely (running IDE as Administrator + disabling UAC just in case). Also - always use Fusion Log for tracing assembly loads! See http://msdn.microsoft.com/en-us/library/e74a18c4(v=vs.71).aspx for how to set it up

Stifling answered 12/11, 2012 at 21:21 Comment(0)
D
0

Did you rebuild your components from scratch?

Are the projects included?

Are they all building?

Are they all building on the same platform (x86 vs x64)?

Distributary answered 28/1, 2013 at 19:30 Comment(0)
B
0

Set the default built to x86 and that should fix it.

Bethune answered 7/2, 2013 at 21:45 Comment(0)
P
0
  1. Clean the solution
  2. Build the project containing the Control
  3. Add the control to the toolbox/form

See if this works.

Purser answered 3/3, 2013 at 9:33 Comment(0)
L
0

For anyone who with similar issue(s). I just came across this in VS 2013 (VB side) on an x86 PC. As mentioned above, I toggled from 'anyCPU' to 'x86' and the form designer opened right up. Simple, but probably wouldn't have tried it without the above post(s). For what it's worth, I toggled back to 'anyCPU', and as yet have had no recurrences...

Lazor answered 8/3, 2014 at 0:16 Comment(0)
A
0

I faced the same error, can't able to Build my application.

So searched here, Says to change the solution platform X64 or X32. But in my case the Solution platform only shows Any CPU and configuration manager option only

But i simply change the solution configuration.

Debug => Release

then

Release => Debug

Finally clean and rebuilt the solution. Its works for me!!:)

Anosmia answered 18/7, 2017 at 11:59 Comment(0)
F
0

While the top answer from @richard-whitehead is correct that the 64bit editor cannot load the 32bit controls which is why you're seeing the error, there is another way to have Visual Studio edit 32bit GUI controls in a 64bit GUI project as described here:

https://mcmap.net/q/667221/-could-not-find-type-39-xxx-xxx-xxx-39-please-make-sure-that-the-assembly

Fitzger answered 13/4, 2022 at 6:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.