2

I have google this exception and found couple of good links as wel and tried whatever suggested. But still same issue.

This exception I am not getting on any of my local server even after deployment on my local server No such issues.

But when I move the site to hosting server, first time it loads with no error,but once I press ctrl+f5 I start getting this exception.

http://prnt.sc/8x4bm7 Exception on hosting server This exception I am getting only on remote/hosting server. No such exception in my local.

Could not load file or assembly 'file:///C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\ asp.net vs2010

as per the above link, I tried this..but doesn't seem to solve the issue.
I am banging my head for this

I am using ASP.Net4.5 MVC

Community
  • 1
  • 1
Kgn-web
  • 7,047
  • 24
  • 95
  • 161
  • 2
    BadImageFormatException is usually x64/x32 problem http://stackoverflow.com/questions/15917204/badimageformatexception-c-sharp – Dmitrii Dovgopolyi Nov 01 '15 at 09:39
  • @DmitryDovgopoly.. I read that link previously & checked all the build settings still issue persists – Kgn-web Nov 01 '15 at 09:47
  • Can you verify that your IIS process is x64 on that remote server? – Dmitrii Dovgopolyi Nov 01 '15 at 09:50
  • @DmitryDovgopoly.. strange is if I make some changes in my local and move these changes to hosting server.. its loads as desired for the first time but if I refresh the page or reload it.. I start getting this error.. – Kgn-web Nov 01 '15 at 09:59

3 Answers3

4

As @DimitryDovgopoly noted, this is a bitness issue.

When you push changes to the remote server, the application pool recycles.

If your 64bit app is the first to load into that process, then the 64bit version of the assembly is loaded.

If a 32 bit app loads into the same app pool first, it will load the 32bit version of the assembly.

Either one of these scenarios can cause a BadImageFormat exception for the other application. If you think you may have fixed it for your application, you may have broken it for another application that shares the same app pool.

Make sure that no two apps that have different bitness (32 or 64) are sharing the same app pool. If you have an application that is 64bit, consider turning off the 32bit support for that pool (Enable32Bit = false).

StingyJack
  • 19,041
  • 10
  • 63
  • 122
  • Jack, thanks.. but can you please tell me bit how do I crosss check this bitness on the hosting server and (Enable32Bit = false) for all my applications that shares the same pool – Kgn-web Nov 03 '15 at 17:59
  • 1
    I dont know what you have available from your hosting server, but on a windows server using IIS Manager, you can view the application pools. For each application pool, you can right click and view applications that are running in that pool to see if there are ones that should not be mixed. If there are ones that should not be mixed, then you will have to create a new application pool (first option on the right side of the window) and move your applications to it. – StingyJack Nov 03 '15 at 18:07
  • To check the properties of the pool, you can right click on the pool and choose Advanced Settings. This is where you can disable 32 bit application support and change framework version, etc. – StingyJack Nov 03 '15 at 18:08
  • Jack..thanks... but bad thing is that I don't have access to IIS as my site is on shared server..but will check with admin team of hosting provider to do it... – Kgn-web Nov 03 '15 at 18:12
2

Strange but this fixed my error..

I am using EF profile to anaylyze ef queries..and I had reference to Hibernate.Rhinoes.dll and I just thought of removing this refererece from my solution.

When I removed and rebuilded and deployed, it fixed my issue.

Kgn-web
  • 7,047
  • 24
  • 95
  • 161
0

I think this error is due to different framework version in hosting server. Please, check framework version.

Donald
  • 534
  • 1
  • 10
  • 18
  • @Donald..is this could be the cause then other subdomain should also reflect the same..but other subdomians are working as desired..even if I make some changes & move the site to hosting server it loads fine for the first time but if I reload the page it starts giving this expcetion.. – Kgn-web Nov 01 '15 at 10:13
  • Are you sure that IIS application pool for this app is using correct framework? – Donald Nov 02 '15 at 12:26
  • However, try to change platform compilation to X86 and rebuild, you should obtain the same error. – Donald Nov 02 '15 at 12:33