posts - 114, comments - 204, trackbacks - 82

My Links

News

View Anthony Trudeau's profile on LinkedIn

Add to Technorati Favorites

Article Categories

Archives

Post Categories

Image Galleries

Other Links

Could not find type

I stumbled onto what I would consider a bug in the Visual Studio 2005 IDE today.  The issue came about after I rebuilt due to renaming a type that was used in a user control.  After building I got an error when I attempted to load the user control in design mode.  The error was:

Could not find type 'TypeName'. 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 variable 'ControlName' is either undeclared or was never assigned. 

It turns out that I had the assembly that was being built in the IDE also in the GAC.  It needed to be in the GAC for testing that I was doing outside of the IDE.  The problem went away after I uninstalled the library from the GAC.

I understand why the problem occurs, but in my opinion Visual Studio should not perform the normal assembly resolution -- especially when the type is internal to the project like it was in this example.  Anyway, hopefully, this will help someone else out.

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Print | posted on Thursday, April 20, 2006 11:58 AM | Filed Under [ .NET bugs ]

Feedback

Gravatar

# re: Could not find type

Anthony,

Perhaps one of the projects in your solution links to the GAC version, rather than the project version. Let's call the linked-to assembly A and the GAC-linking project B. If C references both (project-version) A and project B, this would introduce some ambiguity as to which version of assembly A should be linked to: the project version, or the GAC version (that referenced project B refers to).
This can particularly be a problem in VB.NET when Option Strict is not on. Is that your situation?
- HTH
4/20/2006 1:56 PM | Chris Falter
Gravatar

# re: Could not find type

I've just started using VS, and I'm having the same problem (I think). Could you tell me how to uninstall the library from the GAC? Or point me in the right direction?
5/5/2006 11:10 AM | Marc Durham
Gravatar

# re: Could not find type

If you put it there you can open C:\Windows\Assembly in Windows Explorer, select the library and choose Uninstall. If an application put it there you'll have to uninstall. You can also force the assembly to load your specific DLL if you don't want to uninstall the application. That requires doing some magic in the application's configuration file.
5/5/2006 2:14 PM | Anthony Trudeau
Gravatar

# re: Could not find type

It's a known bug. See;
http://support.microsoft.com/kb/842706/en-us
6/13/2006 6:11 AM | Oli
Gravatar

# re: Could not find type

Thanks for the link.
6/13/2006 6:56 AM | Anthony Trudeau
Gravatar

# re: Could not find type

Anthony; Thanks for the post. I deleted a form a couple of times and rebuilt it thinking I was doing something wrong. Applied your solution (removed libraries from GAC) and the problem disappeared. The link from Oli is for VS 2003. Evidently the issue did not addressed in VS 2005. Thanks again, saved me alot of time.
9/11/2006 2:07 PM | Morris DeShong
Gravatar

# re: Could not find type

Hello.
I also got this error message. In my case it was due to the fact that I had a form (class) within my project that had the same name as the C# project. I renamed the project and the this fixed the problem.
7/11/2007 1:51 AM | Augusto Cosatti
Gravatar

# re: Could not find type

Hi,

I have also struggled with this problem on VS2005, without libraries in the GAC or a naming problem. The following worked for me:

Closing all panes (all open forms and classes) in VS2005
Save the solution and exit VS2005
Restart VS2005 and open the solution
Clean and rebuild

On the first attempt I left the forms open and it didn't work!?

Giles
4/9/2008 4:32 AM | Giles
Gravatar

# re: Could not find type

Sorry - missed a step on the above post...

Before restarting, delete the bin and obj directories.
4/9/2008 4:35 AM | Giles
Gravatar

# re: Could not find type

Giles solution worked for me without deleting the bin and obj directories. Thank you Giles.

Closing all panes (all open forms and classes) in VS2005
Save the solution and exit VS2005
Restart VS2005 and open the solution
Clean and rebuild
4/25/2008 3:47 AM | Michael Bross
Gravatar

# re: Could not find type

Giles solution is the winner. Although I chose to only Build, as Clean was not an option.
5/17/2008 4:42 AM | Christian
Gravatar

# re: Could not find type

Thanks Giles - this was driving me nuts
7/8/2009 7:14 PM | OB1
Gravatar

# re: Could not find type

The problem is still in VS2008. It can be fixed as explained by Giles (no need to delete bin and obj though).
9/2/2009 2:04 AM | Michael
Gravatar

# re: Could not find type

And this worked for me in StudioExpress2008. Thanks Giles
2/11/2010 11:20 AM | w
Gravatar

# re: Could not find type

Thanks Giles. Closing all the panes and restarting was the key. I had tried deleting the Obj and Bin folder and restarting / recompiling, but that didn't work.
8/17/2010 7:35 PM | Josh
Gravatar

# re: Could not find type

All hail to the Giles! :)

VS2010 here. Self-written class extending panel, couldn't view it in Designer until using Giles solution.

Thanks man!
12/8/2010 9:27 AM | Jan
Gravatar

# re: Could not find type

VS 2010 here also. Sucks the same bug is in this many versions later. This exact problem has caused much upset before finding Giles solution attached to this top-o-the-search-results article.

Working on a 30k line project with a good 20 custom controls, this problem rears its ugly and stress inducing head every week and a half. But with a solution that works, I can just handle it as part of the development process.

Thanks all of you!
1/18/2011 7:13 AM | Wally Fortkrousty Knobthruscht
Gravatar

# re: Could not find type

Hi, still having this issue with vs 2008 and C#. people seem to have had luck with the above but not me. I have recently inherited this code and moved it to a new source control location. anyone have to do any extra steps that might help me? I have delted all BIN and OBJ in my sub project directories but no luck.
3/25/2011 11:52 AM | Mike
Gravatar

# re: Could not find type

""The problem went away after I uninstalled the library from the GAC.""

How can we do this ?
11/12/2011 3:56 PM | Zil-e-Huma
Gravatar

# re: Could not find type

For just a mucked up usercontrol designer error (no GAC involvement) I opened the usercontrol's resource window, ie double-clicking the .resx file, closed it, then when I switched back to the control's designer window, I saw the error page going away! Odd.
1/18/2012 12:30 PM | stentor
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 

Powered by: