Windows Develop Bookmark and Share   
 index > Windows Forms Designer > "Could not load type from assembly" error
 

"Could not load type from assembly" error

I'm getting this error, when trying to add my UserControl to the form. This control is definedin the external assembly, and that assembly references another assembly (it contains some util classes). Both these assemblies are added to the project references. WinForms designer says it can't load a data type from the util assemby, and shows name of this assembly with wrong version number (not good, because assembly is strong named). So it can find the assembly containing control definition itself, but can't load util assembly.

Any ideas, why this happens and how to resolve this problem?

Andrei Faber  Wednesday, October 15, 2008 1:43 PM

Make sure the third assembly is built properly and then add its reference to the 2nd assembly and then build the 2nd one and then add the 2nd assembly to your main project.Make sure all are properly built.

nag321  Thursday, October 16, 2008 12:02 PM

Hi

These cases occur because of mismatch of version number of Dll's references to other component.Make sure that from low level every thing is compiled and referenced to the other.

Hope this will help you out..

Sreenath G V  Thursday, October 16, 2008 12:25 PM

I already did it all, no success.

I've addedmy control to the form by manually editing form file; application starts and works ok, but form designer doesn't open now (shows the same error message)

Andrei Faber  Thursday, October 16, 2008 12:27 PM

Hi

Just try one thing..

close all you .Net IDE's and and reset your devenv...

It from visual studio command prompt which you can access it...

Start->Program files->Microsoft Visual Studio 2005-> Tools->Visual studio Command prompt..

approximately you will find it here..

Just open it and type this command..... Devenv /ResetSkipPkgs

This will reset your IDE...

Then open your application rebild all solution then open the form..

Hope this will work you out..'

Sreenath G V  Friday, October 17, 2008 9:23 AM

Actually I've already found reason of this bug and I was really surprised, in a very bad way. My component uses an external util assembly (as I mentioned before), and it turned out the sameassembly (but of older version) was already loaded into VS process by some plugin.

So, WinForms designer tried toload my component withthat old assembly, instead of correct one referenced by my component. Obviously,it didn't work. Very, very stupid bug in WinForms designer.

Andrei Faber  Friday, October 17, 2008 10:47 AM
Thats funny...

Sreenath G V  Friday, October 17, 2008 10:50 AM
Hi there,

This error as reported in the above-posted messages is due to a local copy in the bin\Debug folder of your solution or project. Even though you attempt to clean your solution, such copies will persist to exist.

In order to avoid this to happen, you have to force Visual Studio to refer to the correct DLL by adding reference paths within a project properties. Unfortunately, if you got 14 projects within your solutions, you will have to set the reference paths for the 14 projects one after another until completed.

Should you wish to know how to setup reference paths follow these simple instructions:

1.Select your project, right-click, then click "Properties";
2.In the project properties, click "Reference Paths";
3.Folder, type or browse to the right location of your DLL, click [Add Folder].

You will need to perform these steps for as many different locations you may have for each of your DLLs. Consider setting an output path under the Build tab of the same project properties, so that you may output your DLLs in the same directory for each of them, thus assuring you to find all the latest builds under the same location, simplifying forward your referencing.

Kindly,

WILL.
General Will  Tuesday, October 28, 2008 11:37 PM
There are a number of causes of this error.

If you have one project referencing another project (such as a 'Windows Application' type referencing a 'Class Library') and both have the same Assembly name, you'll get this error. You can either strongly name the referenced project or (even better) rename the assembly of the referencing project (under the 'Application' tab of project properties in VS).
  • Proposed As Answer bySaals Friday, April 24, 2009 2:24 AM
  •  
Saals  Friday, April 24, 2009 2:24 AM

You can use google to search for other answers

Custom Search

More Threads

• Form turns bad after converting from MC++ to C++/CLI
• Design time support for protected property
• How do I find out location of toolstrip in VB.NET 2005
• issues About Custom form Designer when running on .NetFramework2.0.
• AutoscaleMode.Dpi not working as expected on screen with different DPI
• collections problem...
• Moving controls doesn't work after migrating to VS2005
• Design Time Events
• Designer Error: One or more errors encountered while loading the designer. The errors are listed below. Some errors can be ...
• Multiple controls in a single DataGridView cell