Visual Studio 2010 - TypeLoadException During Publish RRS feed

  • Question

  • User-1942178298 posted


    I am having trouble publishing my website...sometime it will publish, sometimes it will not...even without changing anything. 

    After Debugging the compile, when the solution publishes, I do not get a TypeLoadException.   When the publish doesn't go through, it is an error on a page that I built.  The error is a TypeLoadException....Cound not load type "MySolutionNameSpace.WebPageClass" from assembly.   The .dll is being built during the publish. 

    If I rename the class in the application, it appears to load that assembly fine, and it gives an error on another assembly (on a page that I built).  

    I have

          cleaned my .dlls

          my webconfig I set a different tempDirectory each time.  

           I close VS,

           and even Reboot..and no luck.   

    During debugging the compile, and I get the error, I viewed the assembly during publish as soon as I get the error and everything in the .dll appears fine....meaing, what it is trying to load is  in the .dll   I am at a standstill. 

    I am using Visual Studio 2010 Professional   Version 10.040219.1 SP1Rel    Microsoft .Net Framework Version 4.5.50938 SP1 Rel.  The application runs fine as expected.

    Thursday, September 21, 2017 4:24 PM

All replies

  • User-1942178298 posted

    An add-on, the Publish Error that I get is the  "Object reference not set to an instance of an object",    but I believe the underlying issue is the TypeLoadException.

    Thursday, September 21, 2017 6:02 PM
  • User1771544211 posted

    Hi robbpat,

    The error is a TypeLoadException....Cound not load type "MySolutionNameSpace.WebPageClass" from assembly.   The .dll is being built during the publish. 

    Some possible causes to this issue are:

    • You didn’t install the assembly specified in the error.
    • Your DLL depend on other DLL’s to get its job done and if you didn’t copy or install those too, you’d indeed get this error message.
    • Or you have installed an older version of the assembly

    Some solutions are:

    • Make sure that you have the last version of the assembly installed.
    • Rebuild the solution.
    • Deploy the correct solution.
    • Uninstall the DLL from GAC, make sure that it is not present any more and install the new version

    Best Regards,


    Friday, September 22, 2017 2:48 AM
  • User-1942178298 posted


    Thanks for your response. 

    The .dll is being created during Pre-Compile time during publish in a temporary folder....I did redirect it to TempDirector in my webconfig.   It don't believe it is related to an older versions of the .dll...since a new .dll  with a different name is being created during the Publish's Pre-Compile.    I can publish, the Code fine, I turn around and try to Publish without any changes, and it will fail (based upon the TypeLoadExepton error).   Sometime it will publish, more often than not it will not publish.   I don't think it has to do with Installing the assembly specified in the error, since the assembly that is in error, is an assembly being built during Pre-Compile  (that is my code

    Monday, September 25, 2017 12:31 PM
  • User1771544211 posted

    Hi robbpat,

    Is there any errors when you build your project?

    That's a strange error I have ever met before, could you please share the detailed error message here?

    Best Regards,


    Tuesday, September 26, 2017 2:57 AM