Runtime error when deploying to Azure because of one dll file - asp.net-mvc

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?

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.

Related

Serilog Sinks BrowserHttp problem with ingest

I'm developing in ASP.NET Core Blazor WebAssembly.
Originally I had made a Blazor wasm project in Visual Studio 2019 where client, server, and shared were all part of the same project.
The project grew and I decided to split up the project into separate git repos.
I'm using Serilog.Sinks.BrowserHttp and it was working fine before I split up the project.
Now I'm getting an error in Console (Chrome):
Before the project was split up into two separate git repositories, all logging was saved in the database, but after the split, only the server-side logs are being stored in the database.
Is there a way I can store the logs straight into my Microsoft SQL database after having split up the Blazor project?
Here is my Program.cs logger configuration:
Logger Configuration
I just figured since both server and client were both in the same project and everything worked fine, the problem must be that the logger is assuming they still are in the same folder.
The problem was an old Nuget packet Serilog.Sinks.BrowserHttp 1.0.0-dev-00012. When selecting to manage nuget packets for my solution in Visual Studio, under package description the only version available is the installed version. But from the command line I was able to update to the lastest version 1.0.0-dev-00021.

Docker GetServiceReferences: The given path's format is not supported

Trying to run locally a Web MVC application using Docker. Application compiles and runs fine when Set as StartUp Project outside of the docker-compose project but fails when docker-compose is Set as StartUp Project during the build when it comes to Target DockerGetServiceReferences: with
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets(195,5): error : The given path's format is not supported.
I have added the docker-compose through Visual Studio 2017 to an existing application as described here:
How to containerize the .NET Framework web apps with Windows Containers and Docker
I appreciate this might be quite vague so if there are any more details I could provide please let me know.
EDIT:
Adding docker-compose to just default MVC template in a new project works fine so the problem seems to be with the legacy solution. Also noticed I can't navigate docker-compose project General Properties, I get the URI formats are not supported popup error
EDIT:
Adding a brand new MVC project from the template to the solution without any references to other projects also generates the error. Could this indicate that the problem might be somewhere on the solution level?
EDIT:
I have created a new Solution file and started to migrate all the projects. This way I am successfully able to compose docker image. Once I am finished migrating all of the project I will do a comparison on .sln files and try to see what is different.

TFS Release Task to Deploy a Web Deploy Package to specific directory

I've been digging for hours and i haven't been able to find what i would think is a pretty common scenario.
I am attempting to deploy a Web Deploy Package to my existing Web Site\Web App via a TFS Release. The location of my existing Web Apps is mapped to a different drive. My source code on my web server is not in C:\inetpub lets say its in D:\MyFiles.
I'm open to using any TFS task to do this. It seems like my two options are:
Run Batch Script - point to myApp.deploy.cmd
WinRm IIS Web App Deployment
I've seen lots of examples of overriding the computer name via the setParamater file but I have not seen one example of how to set the target path for the package?
Again, i want to deploy a web package via a TFS release to D:\MyFiles. I've created the package and it deploys locally to c:inetpub, I would assume if I can get it to deploy to a specified Target location locally then when I run that same. CMD file from TFS release it will use that location on the deploy to server.
UPDATE:
So... this just started working. I'm not sure what the issue was but the WinRm Task didn't do the deploy on Friday but did the deploy on Monday. I'm thinking it may have been related to a FQDN for the server path? Honestly I'm not sure what fixed it or what to do with this post? The answer below by #Andy may help someone so I won't delete it. That link is a good one and it showed me how to perform IIS configuration with Web Deploy.
Thanks in advance,
Greg
Seems you are trying to change the physical path of an IIS site/app using MSDeploy.
Just try adding an additional command (appcmd) to the MSDeploy package manifest to change the physical path of the IIS site during the deployment:
<runcommand path="%windir%\system32\inetsrv\appcmd set app /app.name:"Default Web Site/app12" /[path='/'].physicalPath:C:\temp\app12" waitInterval="5000"/>
Refer to this article for details:
WebDeploy/MSDeploy Quick TIP: Change IIS Site/APP Physical Path with MSDeploy

Public testing environment for RoR + Angular

currently I need a little hint for test running a RoR + Angular Application. And with test running I talk about that the "project owner" can see the current version of the project. For large projects with a lot of developers we had a build server, where the server got the current version from the git repository and deployed it as a "nightly build".
For projects where I'm the only developer I use dropbox to synchronize my working directory to a server, that is accessible for the project owner.
But now I'm working on a small project with 2 other developers. The build server is too much and the dropbox solution, well it's not going to work, because every one of us has a different state. And working on the same Dropbox directory is a no go.
So what's the best solution?
Consider running it on Heroku, which has a free tier. Once set up properly, deployments can be done by simply pushing to your Heroku git remote, or you can set it up to watch an existing remote repository branch (such as a particular branch on Github).
Or you could run it on your own machine. If you are behind a firewall you could set up a tunnel so your team can see it, with something like ngrok.

Deploying ASP.Net website in VPS (windows server 2012)

I've recently bought a VPS in which I wanna host a website. When I waana upload an ASP.Net MVC website in a normal shared hosting, I simply use the the publish option in the visual studio and the website gets automatically uploaded in the host. In the VPS which has Windows server 2012, there is a server manager which I used to create an area in the hard drive where I have to put my web file. (I put a hello world html file and it works)
My question is that, I have never manually uploaded an ASP.Net application before and I do know how exactly Visual Studio publish those ASP.Net website, so how can I manually build the website and put it in the VPS.
I used the batch build, VS made some Dlls and I don't know what to do with them .
If you call MS build from the command line in the following manner for instance:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe TestApp.csproj /p:Configuration=Release /t:Package
by specifying the target "Package" (/t:Package) you are commanding MSBUILD to package the website.
It will proceed to build and package your website into an MSDEPLOY package (specific zip file layout).
The build output from the sample build is actually very helpful and gives you clues as to where to go next, for example it tells us where it created the file:
Package "TestApp.zip" is successfully created as single file at the following location:
file:///C:/TestApp/obj/Release/Package
It also gives us a link to find out more:
To get the instructions on how to deploy the web package please visit the following link:
http://go.microsoft.com/fwlink/?LinkId=124618
Then it shows you where it created a sample .cmd file for deploying the package
Sample script for deploying this package is generated at the following location:
C:\TestApp\obj\Release\Package\TestApp.deploy.cmd
For this sample script, you can change the deploy parameters by changing the following file:
C:\TestApp\obj\Release\Package\TestApp.SetParameters.xml
Now you can customize the ".deploy.cmd" file to publish your application on your server. Edit the ".SetParameters.xml" file to setup specific parameters for your server. Login into your server, run the command file from a console that has right to publish and all should be good.

Resources