none
"Could not load type from assembly" error

    Question

  •  

    I'm getting this error, when trying to add my UserControl to the form. This control is defined in 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?

    Wednesday, October 15, 2008 1:43 PM

All replies

  • 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.

    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..

     

     

    Thursday, October 16, 2008 12:25 PM
  • I already did it all, no success.

    I've added my 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)

     

    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..'

    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 same assembly (but of older version) was already loaded into VS process by some plugin.

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

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

     

    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.
    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 by Saals Friday, April 24, 2009 2:24 AM
    Friday, April 24, 2009 2:24 AM
  • Yes It works Changing the Assembly Name Thanks Saals
    Monday, April 18, 2011 8:54 AM
  • 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).

    ... and this answer keeps on helping, years later.  Thanks Saals.

    -Mark R.

    Monday, March 12, 2012 12:59 PM
  • Another example where this might occur is when you have one version of your assembly deployed in the GAC but has not been updated with new classes that you might have added on the assembly on your IDE. Therefore make sure that the assembly on the GAC is updated with changes you might have made in your project.

    E.g. if you have a Class Library of Common and in that Class Library you have Common.ClassA type and deploy this to the GAC strongly-named. You come later and add another type called Common.ClassB and you run your code on your IDE without first deploying the changes you made to the GAC of Common with the newly added Common.ClassB type.

    Wednesday, May 23, 2012 1:54 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).

    ... and this answer keeps on helping, years later.  Thanks Saals.

    -Mark R.

    indeed!

    i was playing around and renaming projects. I Forgot about the assembly name.... Thank you!

    Saturday, January 25, 2014 6:02 PM
  • I know this an old thread, but here is a scenario that causes this error that was not yet mentioned here:

    If Project A has a reference to Project B, and Project B builds an assembly that is in the GAC, the assembly that will execute during DEBUG will be the one in the GAC, regardless of any changes made to Project B in Visual Studio.

    This is specially true and common with Helper Classes projects in BizTalk. A solution is to UNGAC Project B assembly.

    I hope this helps someone,



    Wednesday, July 15, 2015 9:56 PM