Visual Studio putting web app dll in \bin\x64\debug instead of \bin\ - asp.net

IDE: Visual Studio 2010
.NET 4.0 x64 running on Windows 2008 R2 x64
All projects are configured for x64 platform.
When I compile the web application project, it puts all the required DLLs in the bin directory...HOWEVER, the web application's DLL is inside the \bin\x64\Debug.
This causes the dev web server (I use ultidev but this affects VS web server as well) to try to load the web application DLL from the \bin\ directory..but because it isn't there, it throws an exception failed to load type 'Global' (global.asax page). If I copy the web app dll from \bin\x64\debug to \bin\, it works fine.
Why isn't VS putting a copy of the web app dll to the \bin\ directory?

In the project properties (right click on the web project, at the bottom click properties) open the "Compile" section. You should see "Build output path" with a textbox below it and a browse button. Change the build output path to "bin\"

Due to another issue this didn't help me directly but did get me thinking.
I had to right-click on my project, "unload", then right-click again and edit the project.xml which included the outputPath variable.
That one was difference somehow so I edited it to point to "bin\", saved, right-clicked on the project one final time, choose "reload" and went about business as usual.
That solved my problem along with the issue of my break-points not being hit (because I had old files in bin\ which weren't getting cleaned up thanks to the bad path).

Related

.NET Core 31 - Single EXE - The application to execute does not exist

Converted an old .NET Framework project to .NET Core 3.1 yesterday. The application runs fine on my own machine and debugs correctly.
I have put both the following into my .vbproj/.csproj
<PublishSingleFile>true</PublishSingleFile>
<RuntimeIdentifier>win81-x64</RuntimeIdentifier>
However when I move the .EXE to a remote machine and attempt to run said EXE on that remote machine I get told that the DLL (for the project in question) does not exists.
I moved the .dll to the same directory that the exe is in (not ideal) and get the following error instead
A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\Program Files\dotnet'.
I used to use Costura.Fody to create a single file exe without any issues in .NET Framework, I was under the impression the above would do the same for the .NET Core packages.
Can someone point me in the right direction please.
For anyone else that may find this question and find it useless.
I was 'Building' the project instead of 'Publishing' the project, this in-turn wasn't creating the self-contained exe properly.
Don't be a donut like me.
In Visual Studio 2019, go to Build > Publish MyApp. This will open a tab in the editor area. Click on Show all settings to open the Profile settings dialog. Then click on File publish options and check Produce single file.

Unable to load DLLs when starting up IIS Express hosted web project (VS2015)

Backgroud:
I am in the process of migrating a console application to be part of our existing web API project. All development work is done on Visual Studiod 2015 (with IIS Express). The application uses few third party datasource api DLLs to grab data from that datasource. All these DLLs are managed by our internal nuget package sources.
Issue:
Now the console application runs fine and can load up the those DLLs. I copied across the logic into my web project and added the DLLs via nuget. Solution builds but got the following error when starting up the web project:
Could not load file or assembly 'ABC.DLL' or one of its dependencies. The specified module could not be found.
Where ABC.DLL is one of the third party DLLs.
I have done the following:
Confirm ABC.DLL is in the bin folder of my web project
Changed target build platform of my web project to be x86 and unchecked "Use 64 bit version of IIS Express for websites and project" setting in VS2015 (the third party dll is 32-bit)
Ran dumpbin.exe on ABC.DLL's dependency and got XYZ.dll,MSVCR120.dll,KERNEL32.dll,MSVCP120.dll,mscoree.dll
Regarding to the last step, those dlls were all missing in the bin folder (but the last 4 DLLs should be in system32 win directory so shouldn't matter?)
As for XYZ.dll, it is another third party library and is located on C:\Program Files (x86)\XYZ\ folder. I manually copied it across to the web project bin folder (in fact copied across all Dlls inside XYZ folder) and still get the same issue.
Questions
What am I missing here? The console app obviously can load ABC.DLL but the web project can't. Appreciate it if you can tell me what to check next.
The error message from start up web page is not very useful, is there a way to find out where the web project is trying to load the third party DLLs?
Thank you in advance!
Simply adding external DLLs to your Bin folder is not a great idea. Files can disappear from this folder for various reasons, such as your team members deleting a seemingly useless DLL, or through Visual Studio clearing it. Also, the output DLLs from referenced projects in your solution, would end up there, and are replaced every time you build your project.
What you should do for third-party DLLs, is create some "dependencies" folder in, or close to, your project, and stick the DLLs in there. Then you should right-click on the project, select Add Reference, browse to that new "dependencies" folder, and add a reference to the DLL that way. This is similar to the way NuGet works; it keeps DLLs in their respective folders inside the packages folder, and adds references to those DLLs.
I finally found the issue and thanks for all the help, I had to disable shadow copying in VS (mentioned in 64 bit managed assembly with unmanaged dependencies not loading in IIS / ASP.NET MVC 4).

Deploying ASP.Net Project to Ubuntu server using Mono

I have developed an ASP.net 4.5 Project using Visual Studio 2013 and I am assigned to deploy it on our Ubuntu server.
Like what other tutorials said I need to use Mono to make this possible. I think I followed those steps but when I try to open the page, it gives me this error.
I had this exception when deploying my application, but to a Windows Server. The problem was that some dlls references pointed to my local assemblies. (example: System.Web.Http.WebHost was referenced to C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Assemblies\System.Web.Http.WebHost.dll, so in the server this LoadException ocurred because this dll was missing.)
So the generic answer is: There is some dll missing. Compare the references in your project with the bin folder in the server. If there's some reference that points to local machine, change the property CopyLocal to true, so when you compile and publish the dll will be copied to the output directory.
I don't use Mono, but how this same problem ocurred to me in a Windows Server, may be the same problem with you in a Linux Machine.
If the probem persists, try to create a simple project, with just one page and a few dependencies just to see if the asp.net works fine in this server.

MVC: Visual Studio Publish Web dialog cannot find my application's Views

I am using these steps to publish my ASP.NET MVC 4 application using Visual Studio 2010 on IIS 7.5 running on a 64-bit Windows 7 Professional machine.
When I click the Publish button on the wizard after entering the values, it reports a single error that reads:
Copying file Views\Shared\Error.cshtml
to obj\Debug\Package\PackageTmp\Views\Shared\Error.cshtml failed.
Could not find file 'Views\Shared\Error.cshtml'.
I looked into the target folder where the wizard dumps the necessary files that will be needed to deploy the application. It turns out that the folder had the Views folder which had only the _ViewStart.cshtml of the root Views folder, but no other View. My application has at least 20 views, perhaps more.
I realized that it was my fault. The local copy of my project had the file Error.cshtml in the Views\Shared folder. However, the TFS copy of the project file did not. Apparently, the file had been excluded from the project at some stage.
I excluded the file from my project locally and ran the build and it worked.
In my case the problem was that the file was in the solution but didn't actually exist on the local file system.
For me, this problem occurred when I moved a file (via explorer) from the shared folder to another folder.
I added the file in visual studio, but did not "delete" the file from the shared folder (as far as visual studio was concerned).
For some reason, visual studio did not put a little flag or warning sign to tell me the expected file was missing (even after a refresh), so I didn't notice (although trying to open the missing file revealed the problem).
The error message is clear, and self explanatory. I just couldn't understand it for some reason.

Running aspnet web site starts on parent directory

I have some old project written in asp.net web pages. I open project by Open Website option and choosing MyCompany folder. I start a project with debugging. The Asp.NET Development server starts.
Actual: localhost:53669/MyCompany/somepage.aspx
Expected: localhost:53669/somepage.aspx
How can I force the ASP.NET development server to start on MyCompany folder location not on the parent folder location?
What version of Visual Studio are you using? In Visual Studio 2010, you can change it in the project properties
Steps
Open the Solution Explorer
Right click your project
Click Properties Window (not Property Pages)
Alter the Virtual path option from /MyCompany to just /
Example so you know you're in the right place
Before
After

Resources