Generation of designer file failed: Could not load file or assembly

后端 未结 9 1912
别跟我提以往
别跟我提以往 2021-02-09 15:56

I have an ASP.NET web application project which references another project called ModusCore (or Modus.Core). We\'ve had a variety of controls that use ModusCore up until now wi

9条回答
  •  梦谈多话
    2021-02-09 16:17

    I had a similar issue but with assemblies that we had created. In our case the version number was very specific, so this may not work if all your files say 1.0.0.0.

    First of all, delete the designer file for the problematic aspx file. Right-click the aspx file and select "Convert to Web Application", similar to what others suggested. Doing it on the file is faster and you get a popup with the error instead of a warning you have to look for. In our case the error was Generation of the designer file for OurPage.aspx failed: Could not load file or assembly 'OurCustomAssembly, Version=1.0.234.567...

    What I then did is use a tool that searches file contents (e.g. Agent Ransack) and pointed it to our source folder (which also has the build/cache files) and searched for files "containing text" with the specific version. For each of the projects that came up, I removed the reference to the assembly that was failing, re-added it, then rebuilt the individual project. Searching again showed that the version was gone.

    I ran Convert to Web Application again and now got the same error but with a different file. This time none of the above worked. I was able to determine that only some of the Register tags were problematic. I removed those register tags, created protected variables on the page's code-behind (since they weren't in the designer file) and recompiled the solution. Afterwards I removed the variables I had created, saved, readded all the Register tags, saved. At that point the designer file generated successfully.

    There may be a more straightforward way to do all this, but that's what ended up working for me. Time will tell, but hopefully this is a permanent fix.

提交回复
热议问题