views:

456

answers:

2

I'm getting this error in visual studio 2008 in a Mobile Desktop application .NET 3.5.

Could not find type 'MyNamespace.MyType'. 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.

This shows up when opening a form. The type that it can't reference is a user control that is part of the same project. Nothing is wrong with the namespaces. This is maddening -- the project builds just fine.

Also, the referenced control is not a generic class like in this article: http://stackoverflow.com/questions/9314/could-not-find-type-error-loading-a-form-in-the-designer

UPDATE: well now later it seems to be working. This seems to be a sporadic problem...

+1  A: 

Is the actual line that is causing a problem in the Form.designer.cs/vb file? Occasionally there are name qualification issues that result in the error you are seeing. Try opening up the designer file and changing the name as follows

C#

global::MyNamespace.MyType

VB.Net

Global.MyNamespace.MyType

After that, rebuild and reopen the designer

JaredPar
Didn't work. Initially the declaration was just "MyType ucMyType1" since the user control and the form are in the same namespace. But neither MyNamespace.MyType nor global::MyNamespace.MyType fixed anything.There is no line number -- the warning for "Could not load type" has row/col blank.
Clyde
+1  A: 

Might be worth looking at the accepted answer for this similar question

Rowland Shaw
(+1) I agree, a change in assembly version is potentially an issue. When you see this message, delete all copies of the dll before you recompile. It sounds like it is finding a different version of the dll than it was compiled for.
Pedro