The code behind file is not being updated when published to IIS - c#

I am working on an ASP.NET project which is published to a configured IIS in the same machine.
I have made changes in one of the forms and than published it.
But while the changes on the web from file (.aspx) are being updated - other changes which reside in the code behind file (.aspx.cs) are not being updated.
My aim is to search addresses from a database and to display markers on google map.
Everything is working fine from my VS-IDE execution but after publishing it to the local IIS:
The front end is working fine while the back-end (the related .aspx.cs) does not work.
I tried those steps to remedy the situation:
I have deleted app directory from windows/frameworks/4.0/temp files.
I have even made new profile in publish wizard and published the project from a new folder.
I have deleted pool from IIS and made new one and mapped it to new ddl files folder.
I have also gone to project /properties/publish web/items to deploy and set to all files in the project.
But none of that solved the problem........
I am using
VS 2012
SQL Server 2012
EF 4.5

Do a clean and rebuild, then publish. Sometimes, sometimes, a change to a dll won't be detected and so won't be recompiled.

Try to delete everything in the bin directory wherever you're publishing the site, then try to publish again. Sometimes VS doesn't like to overwrite the dlls when publishing.

This is very late but search brought me here. The solution that worked for me was, in Visual Studio:
In solution explorer, right click on your project -> select "Build Dependencies", remove any incorrect dependencies.
In solution explorer, go to Project -> References, remove any unnecessary references.
Make sure your project is selected in solution explorer, on PROJECT top menu, select "Convert to Web Application." Ok.
Clean and Rebuild your project.
Publish. It helps to set your File Publish option in Publish Profile to "Delete All Existing Files Prior to Publish"
The code behind files do not get uploaded, because they don't need to get uploaded. Only config and markup files. All the project code is contained in your project's DLL file in the BIN folder.
Hope this helps somebody out there.

Related

Where is Visual Studio storing Publish Profiles?

I have a corrupted Publish profile.
I need to delete it. My other computer is fine, so I know it is local.
I have tried:
Clean checkout of codebase from Git (so nothing is local in my code directories).
Deleting C:/Users/<user>/AppData/Local/VisualStudio
Deleting C:/Users/<user>/AppData/Roaming/VisualStudio
Full text search of Profile Name 'MunicipalAgenda' through Registry
Full Text search through machine.
Creation of a new Windows User for Visual Studio Development.
Despite all of this, VS.NET is hanging onto that corrupted Publish profile.
Honestly I am at wits' end, and my next drastic step is to do a fresh reinstall of Windows 10. Please help before it comes to that!!!
Normally any publish profile store in particular project.
For that you have to look at following location.
Go to that project.
Project has special folder call Properties
Inside that there is a folder called PublishProfiles ( Something similar)
I also had some difficulty in getting my profile deletions to stick ... Visual Studio (2017) doesn't seem to be able to do it from Solution Explorer.
My latest attempt is to go to Source Control Explorer, open up the /Properties/PublishProfiles folder, and delete and commit the unwanted profiles from there. So far so good :)

WPF ClickOnce missed references

I have a WPF app that works with local SQLite and Entity Framework Core. I want to distribute my app using ClickOnce.
Everything works fine when I run it using Visual Studio 2017. But app had a crash on a start when I used ClickOnce. The crash was so early so I couldn't even log the exception. After some time I found that in publish folder some dlls were missed. For example System.Runtime. All references are NuGet packages. Then I found that despite of I have a reference to the dlls in my project ClickOnce application files list doesn't contains it.
The only solution I have found for now is to add missed dlls as files in root of my project and set build action to Content. In ClickOnce application file dialog I set publish status to Include.
It works now but it looks like not the best way to do it. The question is why they are missed in the first place. More likely I missed something or I am not understand the root of the problem.
UPD:
You can find an example code here.
It works from Visual Studio but crashes on a start when you try to install it as ClickOnce application.
UPD: The problem was fixed in Visual Studio Professional version 15.6.1
There are two ways solving solve this.
At first, you have to go Properties → Publish → Application Files, and at this place, make your DLL files include in your project
But if it does not work, go to References and make the DLL file CopyLocal = False. You add a DLL file like Existing Item in your project and make them Copy Always.
It will work correctly.
But for your sample I watch this and I solved it. Look at this image:
You have four DLL files. You need do this for them:
System.Diagnostics.Tracing.dll
System.Reflection.dll
System.Runtime.dll
System.Runtime.Extensions.dll
At first go to your reference and make them Copy Local False:
Then go to the path of each DLL file and add them like Existing Item, and then make all of them Copy To Output Directory CopyAlways
Then Publish it and run it like in this picture. I run it from publish file and it works.
Even if you set the dll to copy local, the dll will not get copied over unless you actually use the dll in your code. You might try adding System.Runtime in your code somewhere like this maybe?
var dummytest = System.Runtime.GCSettings.IsServerGC;
Based on Issue 9 on https://blogs.msdn.microsoft.com/bclteam/p/asynctargetingpackkb/ I was able to do the following:
Symptom
ClickOnce applications targeting .NET Framework 4.0 that reference the Microsoft.Bcl or Microsoft.Bcl.Async packages may experience a TypeLoadException or other errors after being installed.
Resolution
This occurs because ClickOnce fails to deploy certain required assemblies. As a workaround, do the following:
Right-click on the project and choose Add Existing Item
Browse to the folder where the System.Runtime.dll lives
In the File name text box paste in the path of the file
Click the down-arrow next to the Add button and choose Add as Link
In Solution Explorer, holding CTRL select System.Runtime.dll
Right-click the selection, choose Properties and change Copy to Output Directory to Copy always
Republish

Visual Studio 2013 Click Once Deployment

I have a click once deployment project that has been working fine for a long time now. I added some new dll's to a project that is referenced by it. The dll's can't be referenced in references, so I added them as files to the project.
Build Action is Content, copy to output directory is copy always.
when I build the application, the dll's appear in the bin\debug directory. The program uses them just fine too on my computer. When I deploy the application, the dll's don't make it to the other computer.
Under Publish in application properties I went to application files. the dll's I need are not listed there to be included in the deployment.
I would love some help, I feel like I'm missing something really simple.
I have a feeling if I put the dll's in the main project, it would work. I don't really want to do this, I would like to keep them all located in the project they are actually used in.
When I deploy the application, the dll's don't make it to the other computer.
...
Under Publish in application properties I went to application files. the dll's I need are not listed there to be included in the deployment.
You need to set them to download with the application. Click the DLL in the project properties, then press F4. Set the Build Action to Content, and the Copy to Output Directory to something like 'Copy if newer'
For information - it is likely if you download the DLLs for referencing by a built exe (for example) you may need to configure a manifest file for the executable as well to get it to pick up the DLLS correctly

precompiledapp.config - how do I create it?

I'm having a problem with a web application where the events in the global.asax class aren't being executed when I build the application through our build server and publish the website. In Application_Start is a single line of code sets up our logging, and in Application_Error I have some error handling code. Locally it all works fine, and if I copy the files directly from my development folder to the server rather than publishing it via the build server everything works fine.
From loads of Googling it would appear that this is a problem with the precompiledapp.config file being missing - sure enough it doesn't exist anywhere. However, nowhere can I find out how I actually get the TFS Build Server, or Visual Studio (2010), to create this file so that I can publish it.
Any advice on how I can generate this file would be much appreciated.
EDIT: A bit more information. I've just tried publishing the website through Visual Studio 2010 rather than the build server and this created the precompiledapp.config file. I copied all the files across to the server (except web.config which I left intact) and it logs successfully (which suggests the global.ascx events are being fired). What I need to do now is try and get the build server to do the same thing - any ideas?
Make sure your custom config file is set as a content file and Copy To Output is set to Always in the config file properties in Visual Studio.
I seem to have resolved this issue now.
As I mentioned in the Edit of my original message, when I published the website through Visual Studio 2010 to a local folder it created the Precompiledapp.config file, and copying the folder contents to the test version of the application got everything working. As I can't seem to get the TFS Build server to create this file, I decided to try just copying the file from my local publish folder to the test application, along with the rest of the files from the tfs build, and everything seems to be working as it should.
So although I've not managed to figure out how to get the build server to generate this file, my main issue is resolved and I'm able to use the global.asax file again.
I'm late to this question BUT you should probably verify that you have the correct SDK that visual studio would use to build the precompiled app (I think it's Azure SDK even if not doing anything with Azure but not 100% on that).
If you have visual studio installed on the build server you can just install the web workload (opening the solution will prompt it). I did this with Visual Studio 2019 today. MSBuild was ignoring not only my *.pubxml settings but even passed in properties via command line arguments to msbuild.exe (which overwrite the ones in the *.pubxml file).
I opened Visual Studio, it prompted me to install the necessary workload and I did. Everything started working as expected after that.
To precompile, in your pubxml file make sure to have this:
<PrecompileBeforePublish>True</PrecompileBeforePublish>
Also, this post refers to your Edit comment about how to get the build server to do it when it works on your machine.

publish winforms application without install

I've been creating winforms application for a while now, but i've never really published one to other people before.
Recently I started doing this but every time I publish my build, the user requires to de-install his current installation and install the new one.
Is there any way to remove this, so I'll only have to send a .exe file which they can use without any form of installing?
I've attempted to send the .exe file in the bin/debug/ but this only seems to work on computers where Visual Studio is installed.
Go to your solution and set the CopyLocal to true for all projects, this will ensure that the ..\Bin folder contains all the necessary assemblies for your program. Then just zip up the ..\Bin folder, get it onto the client machine, and then unzip it.
Hope this helps!
1) Change from Debug to Release in Solution Configurations
2) Right click on your project and click rebuild
3) Go to your bin=>Release=> app.publish for your exe version
4) Copy over any required .dll files,any .config files and any other resource/image files you need from bin=>Release to bin=>Release=> app.publish.
Your app.publish folder should now contain all the files required to run your form, and can be copied or zipped up and send to anyone who needs to use it !
You can try using ClickOnce as an installation method. It even has a built-in auto-update, so you can publish your application to a web server, and all existing installations will download latests version automatically.
To configure ClickOnce go to corresponding tab in your project settings.

Categories

Resources