VS2008 Web Deployment Project Section Replacement with Elmah - asp.net

I'm using a web deployment project and want to do some section replacement with the emlah/errorMail section. I don't want to send emails in debug build mode.
I have created the custom section and put it in an errorMail.config. In the properties of web deploy project under replacements, I have elmah/errorMail=errorMail.config.
The error I'm getting is An error occurred creating the configuration section handler for elmah/errorMail: Could not load file or assembly 'Elmah' or one of its dependencies. The system cannot find the file specified.
I'm guessing this is happening because Elmah is not in the GAC or it's not one of my projects. The Elmah.dll file does copy to the output\bin folder just fine though.
Is there a way to have section replacements work with 3rd party dlls?
[EDIT]
I found that if I drop the dll in question into the project folder for the web deployment project, that it will work fine. This is less than optimal.
So now my question is, how can I get this to work without having to put the dll in the GAC or having to copy the dll into the web deployment project folder?

If you add a reference to the elmah dll from your webproject, then it will automatically copy the dll to the output folder when you build it.
Those are the only 2 options though: to have the dll copied to the output directory or to put it in the GAC

A technique proposed here dynamically loads an assembly during the web deployment build process so that it doesn't have to be in the GAC. I tried, but was unable to get it to work, though.

Related

Partial ASP.net deployment issue - "Could not load assembly "App_Web_xxx.dll", make sure that it is compiled before accessing the page"

I am using Visual Studio 2017, and the application target .net framework is 4.5.2.
This application ABC (to which I am providing an enhancement) is already deployed and functioning pretty well.
Now that I have to only perform changes on 1 page (a simple condition change), I am planning to deploy only App_Web_xxxx in the ".\bin" folder.
After publishing the application using the "Precompiled" configuration, I was able to identify the respective App_web_xxx.dll file and copied in App. Server bin folder. Renamed it according to existing requestEdit.aspx file. All looks good till now, and interestingly, this App_Web_xxx.dll is common for multiple aspx files available under a common folder (users/request).
Once I try executing this code by accessing the website (respective aspx.cs UI file), it gives the error:
"Could not load assembly "App_Web_xxx.dll", make sure that it is compiled before accessing the page".
But the issue is This dll file doesn't break for any other aspx page available under the User/request folder, it is failing only for feature I modified.
What I have done apart from above mentioned way (considering usual way of partial deployment process):
Replaced requestEdit.aspx page and added new dll, by keeping old dll as is (which can be used by other aspx pages in deployment folder)
Error changed to:
Could not load assembly 'App_Web_xxx.dll, version=0.0.0.0, Culture=neutral, Publickey Token=null' or one of its dependencies.The system cannot find the file specified.
Replaced requestEdit.aspx page and added new dll, by removing old dll and renaming App_Web_xxx.dll in "Imports = Default.aspx, App_Web_xxx.dll" in all required aspx files (for which the old dll was removed)
If I am replacing the whole solution (except web.config) the solution works fine with no issues, the only problem comes when I am replacing only 1 .dll file.
All the solutions I found are providing information of IIS version or dll copying from Server to Dev, but my problem is I'm publishing on dev env (local machine) and partially deploying on the server.
Need help to resolve this issue as this is really inconvenient to deploy the whole solution just for 1 condition change!
Additional Info:
Page Properties --> MSBuild Options --> Allow this Precompiled site to be updatable (checked)

Relocating config files of depending assemblies

My application uses NLog as a logging framework hidden behind a facade in MyLogging project. The project is referenced by a number of web sites to not make them directly dependent on NLog. After compilation NLog.config from the logging project ends up in bin folders of each site and NLog manages to find it automatically during startup. That is understandable and pretty much OK. However, editing any file within bin folder forces ASP.NET to restart the working process so I'd like to have NLog.config one folder up beside regular web.config.
Things I'm trying to achieve\avoid:
Keep NLog configuration in a single file `cause it's the same for all of my web sites
Not to embed it into sites web.config (to not trigger ASP.NET auto-restart)
Just moving the file after building projects with msbuild command is not an option because the sites are deployed to Azure (moved files won't be packaged during publishing process)
I'd like to avoid messing with post-deployment scripts and hard coding things like E:\siteroot\0
The issue is not actually NLog specific as I'd have same trouble with standard app.config files. What are my options here?
For ASP.NET applications, it's recommend to set:
"Build Action" to "content". Otherwise it won't be copied to the root folder (folder with web.config)
"copy to Output Directory" to "none". Otherwise it will be copied to your bin folder.
See:

Publish dll with website to Azure using Visual Studio

My (C# Asp.net) website works locally, but when I publish it to Azure, it is missing a dll (OpenXML SDK).
After extensive googling, I found that I should set the Copy Local property to True. The thing is though, there is no references node in my solution explorer. Even if I create a new project, and add a few references, there is no references node there. (MS Visual Studio Express 2013 for Web)
Here is the error:
Parser Error Message: Could not load file or assembly [...] The
system cannot find the file specified.
The error is caused by this line (in my Web.config file):
<add assembly="DocumentFormat.OpenXml, Version=2.5.5631.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Please help me to either:
display the references node
or manually upload the needed dll (feels odd)
or add some magic command to my Web.config to make it automatically upload the used dll-s.
The references node was missing from my Solution Explorer because I chose to create a Web Site, not a Web Application. For Web Sites, the actual physical folder structure is what gets synced to the server. It doesn't have a References node (and, by the looks of it, many other things are missing, since the basic idea is bit different - see this discussion for more details).
There were two solutions for the problem:
Converting my Web Site project into a Web Application project (instructions here)
Adding a Bin folder in my project folder (that is the folder with the project name, the on that has my .aspx files in it), and including the necessary dll in that folder
I chose the latter. After publishing the site again, Visual Studio automatically uploaded the Bin folder with the dll inside it, and it worked like a charm.

publish asp.net website into single dll file

I got a asp.net website from my client that need to be modified. The problem is that the old company was uploading the project as a release which means no code but a sinlge dll file.
We can make a single dll file the project type is web application not a website!!
Can you adivse how to publish sinlgle dll fiel.
Regards,
Moayyad
If you want a single DLL, then convert your website into a web application. Once you convert, everything inside your project will be compiled into a single DLL file.But still, any external assemblies will be inside their own DLL files.

ASP.NET Web Deployment Projects: getting rid of .compiled files

I'm using a Web Deployment Project in Visual Studio 2008 in order to prepare my ASP.NET application (ASP.NET web application, not ASP.NET web site) for being copied to several servers. I have to copy the files on local staging servers, on different servers via FTP and sometimes I have to fetch them from customers' servers.
So, it would be nice to have all files for deployment in a compact form without the necessity of doing a lot of comparing between source and destination. Web deployment projects have this nice feature: compile all your aspx and ascx files into a single (additional) assembly.
I somehow found out how to get rid of aspx placeholder files on the server, now I'd like to know if there is a (maybe self-made) way to get rid of these .compiled files.
From Rick Strahl's blog:
The .Compiled file is a marker file
for each page and control in the Web
site and identifies the class used
inside of the assembly. These files
are not optional as they map the ASPX
pages to the appropriate precompiled
classes in the precompiled assemblies.
If you remove the .Compiled file, the
page that it maps will not be able to
execute and you get a nasty execution
error.
Anybody out there with a creative idea, maybe using a module/handler which intercepts the check against the .compiled files in the bin folder?
The .compile file comes from pre-compiling on deployment. So you basically have 3 options:
Keep the .compiled file
Don't pre-compile and deploy source code
Turn this in to a Web Application instead of a Web Site and compile as an assembly
I have run in to the same problem myself. I actually choose #1 in most cases when dealing with deployment of Web Sites, but on the rare occasion when I know I am going to have to maintain the site for an extended period of time, I take the time to upgrade it to a Web Application.
I don't like the .compiled files either, but nobody gets hurt if they're there. So why bother?
You might want to take a look at Virtual Path Providers (KB how to here) in ASP.NET.
Credit for this suggestion must go to Cheeso and his self answered question here:
Can I get “WAR file” type deployment with ASP.NET?
I don't know about the .compiled files, but you could set up your servers to update their files with subversion instead of manually copying the files when you compile.
So you would compile the files using the Web deployment project (not into a single assembly), put them in a repository you created for this purpose, and on each server, just do an svn update to fetch and compare the files automatically.
I know it's not what you asked for directly, but it may be a path to explore.
Add "Exclude Filter" to your deployment project:
In the Deployment Project.
Right Click on Content Files.
Click on "Exclude Filter".
Add "*.Compiled"
click OK.
and thats it.
I remember at the days when I cant do Web Application with VWD Express, I use nant script to compile the project into a single dll and deploy, that would work (so I dont need the full VS to do dll deployment too), so if you really don't want to mess your project to Web Application, maybe this is a path to check too.
You can get rid of the .compiled files by using the aspnet_merge tool with the -r option.
Removes the .compiled files for the main code assembly (code in the App_Code folder). Do not use this option if your application contains an explicit type reference to the main code assembly.
If you publish your code as updateable (in publish settings) these files are generated. Uncheck that value and republish. This is an old question I know, but no answers are clearly defined for this here.

Resources