Search code examples
asp.net-mvcazureruntime-errorazure-web-app-serviceazure-cloud-services

Runtime error when deploying to Azure because of one dll file


I build the app using Visual Studio and already publish it to Azure Services. However, when trying to run it, I got the following error:

Could not load file or assembly 'RandomColorGenerator.Forms' or one of its dependencies. An attempt was made to load a program with an incorrect format.

I looked into the bin folder in my local project and I can see the dll file just right. Any suggestions?


Solution

  • According to your description, your MVC project could work on your development environment, but when deployed to Azure Web App, you got the above error. Per my understanding, you could follow the possible approaches below to troubleshoot this issue:

    • Use KUDU which is an analysis tool for Azure Web Apps, click on the "Debug console > CMD", then check your deployed web content under D:\home\site\wwwroot\. Make sure the missing dll has been deployed to Azure Web App successfully.

    • You could try to create a new web app for deploying your MVC project, in order to isolate this issue.

    Additionally, you could try to empty your deployed web content via KUDU or redeploy your project by select "Delete all existing files prior to publish" under the "Setting > File Publish Options" of VS publish wizard.

    UPDATE:

    Based on your comment, you are using Azure Cloud Services. You could enable Remote Desktop and re-publish your application, then remote to your cloud services for troubleshooting this issue. Here is a similar issue, you could refer to it.

    An attempt was made to load a program with an incorrect format.

    As I known, the above message means that there be a 32-bit or 64-bit platform conflict. For more details, you could refer to this similar issue.