Could not load file or assembly 'App_Code' or one of its dependencies.

1.2k Views Asked by At

Problem: I want to deploy modified code into web server. web server is having IIS version set to V2.0. and now I have developed and published code on my local machine with version 4.0. (there is App_code.dll as part of all dll files).

Now whenever I am deploying all files along with App_code.dll I am getting following error:" Could not load file or assembly 'App_Code' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded"

1) My question is how do I build App_code.dll in older version. 2) I tried changing target framework to V2.0 while publishing but then its not working because AJAX functions from other dll are not compiling..

can anyone please suggest what to do to run the site..

Help is appreciated.

Thanks

2

There are 2 best solutions below

1
Fandango68 On

Sorry about the answers I've given... But try this...

Try adding <codeBase> elements to the application config file to specify the exact location of each dll, and the version of .Net it requires. Apparently this works because <codebase> is checked BEFORE the probing heuristics kick in each time an assembly needs to be loaded.

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="sharedlibA" culture="neutral" publicKeyToken="..." />
      <codeBase version="1.0.0.0" href="bin\sharedlibA.dll" />
    </dependentAssembly>
    <dependentAssembly>
      <assemblyIdentity name="sharedlibB" culture="neutral" publicKeyToken="..." />
      <codeBase version="1.0.0.0" href="bin\sharedlibB.dll" />
    </dependentAssembly>
  </assemblyBinding>
</runtime>

If that doesn't work try this.

0
Shakir Ahamed On

Late answer but, I'm writing this for future viewers. I had same error after publish the application to the Server. I figure it out doing like this.

While publish there is configuration in Setting.

enter image description here

In publish section there is option called

Precompile during publishing

you have to check the checkbox and save then Publish. This will takes your code files .vb/.cs and converts them into a compiled DLL files. In my case it was unchecked.