Winforms app wont run on production server - c#

I would really appreciate any help as to why i get a system.io.filenotfoundexception message when i double click the setup.exe on the production server's desktop after installing the app from a CD. I had earlier deployed the winforms app using VS2010 ClickOnce tool, on the Development server (WinVista) to a CD, then ran the CD on the prod server and installed the app to the prod server.
What could be the missing required file(s), or were the files installed in the wrong location/directory??
Or have i missed out something/done the wrong thing while setting the configs in ClickOnce?

What is the installation URL that was used when the C/O application was published? Did you check the box that says you are deploying to a CD?
Do you have an update URL or an installation URL that the application can use to get updates, or are you only providing changes via CD?
If you are not going to provide updates via a file share or web server, I would have the deployment NOT include a deployment provider URL in the deployment (there's a checkbox in the publishing options). Then it will set it to the CD drive when it installs, and look there for updates when the user runs it.

is the setup.exe executed as administrator ?
check how resources are used, f.e images in resouces - do they have "embedded Resource/linked at compiletime" or "copy to outup" activated ?

Related

asp.net core app deployed on iis meets 500 internal server error

:( Oops.
500 Internal Server Error
An error occurred while starting the application.
This message came out when I added database functionality to my asp.net core app and deployed it to iis. When I developed it in Visual Studio, everything went well. But after deploying, this error messages appeared.
I tried to use dotnet myapp.dll to run my app in the deploy folder, and found out it worked well. It is likely that the problem is relation to iis. I tried to add <compilation debug="true">..</compilation> to web.config, but it seems useless. What is problem are actually, or is there any other way to see the detailed error info to help find out what's happened?
Change stdoutLogEnabled="false" to true and then check the logs at stdoutLogFile=".\logs\stdout". The error(s) there might tell you something.
Check that you set up right Environment Name using ASPNETCORE_ENVIRONMENT environment variable as so use correct settings like connection string. On your machine by default you have "Development" environment.
You may use Error Handling middlewares for showing exceptions like
app.UseDeveloperExceptionPage();
Had the same issue. Here is the guide that helped me. Note, that I did not want to install the "Runtime" on the web server, but rather deploy all the necessary files as a stand alone app. Below are the steps in a more abbreviated form:
On your local PC, Determine which version to publish based on your server. I was targeting Windows Server 2008, R2 which meant i needed to publish win7-x64. Open a command prompt in your project directory and run the command below:
dotnet publish -c release -r win7-x64
This creates a publish folder containing hundreds of dlls, an .exe, and web.config located here: bin\Release\netcoreapp2.0\publish
On the web server with IIS, go to this landing page. Click the link for your desired version. Find the link for the Runtime and Hosting Bundle. Click to download and run.
Restart IIS by running this from an elevated command prompt:
net stop was
net start w3svc
Copy all of the files in your local publish folder to your desired application folder on the IIS server.
On the server, Open IIS, and create a separate AppPool and Application like normal. For the AppPool, under Basic Settings, change the .NET Framework version to No Managed Code. Make sure your Application in IIS points to your desired folder and the proper AppPool.
Test your web application in a browser.
In my case, I got this because I hadn't actually installed the latest 'DotNetCore.2.0.0-WindowsHosting.exe' on the windows server I was running it on... so it was working fine on my local machine in debug and error five hundy'ing on the server.
I had other non trivial to fix issues with the upgrade also... I'd advise avoiding it if you can.
Mark333's comment below solved my problem.
Quoting for easy reading:
"I'm using the normal publish provided by Visual Studio. And, I just
found out using the latest version of Hosting Bundle will fix the
issue. +1 on this
microsoft.com/net/download/dotnet-core/runtime-2.1.0-rc1"
I had to install for 1.1 since my app is a little older, but Hosting Bundle fixed it. In my case we deploy to a Docker image for our official environment, but when I want to do some testing locally I publish it and let my local IIS serve it up.
My problem was solved installing .netcore latest: https://dotnet.microsoft.com/download/thank-you/dotnet-runtime-2.2.2-windows-hosting-bundle-installer
https://learn.microsoft.com/pt-br/aspnet/core/host-and-deploy/iis/index?view=aspnetcore-2.2#install-the-net-core-hosting-bundle
Worked like a charm!
I had installed DotNetCore.2.0.5-WindowsHosting.exe on a Windows 2008 R2 Standard machine and encountered the same http 500 error. Logging didn't help (blank logs were generated - and Event Viewer logs were the generic ErrorCode = 0x80070002)
I had to do two things to solve my problem:
Give Read rights to the ApplicationPoolIdentity user (EG: IIS APPPOOL\AppPoolIdentityName) to the website directory and the application directory
I had to install IIS ASP Core under Server Manager (this felt weird, but it worked!)
I had the same issue.
My problem was that my connection string to db was not set in appsettings.production.json
And the internal server error 500 was to vague error message.
Changing the stdoutLogEnabled = true did nothing to me so i was not seeing any information about the error.
Make sure the App Pool has permissions to the folder where your app resides.
I experienced this issue. The problem was due to my local Sql Server instance. Remote connection were not allowed. So I manually restarted the SQL instance and my App restarted working fine.
I had similar issue after istalling dotnetcore-windowshosting using chocolatey while doing AWS ec2 instance bootstrapping.
When I checked my IIS modules AspNetCoreModule was missing.
This solved my issue. https://github.com/aspnet/IISIntegration/issues/434
I had to uninstall chocolatey package, restart machine and install it again.
Hope this helps!
In my case, I created a .NET 5 single file output, and I was getting:
500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
The problem turned out to be that the EXE file was for some strange reason recognized as a virus by the protection software (CrowdStrike Falcon). Re-building without "single file output" option solved that problem.
There is an article called "Configuring IIS, ASP.NET, and SQL Server" which I highly recommend.
I followed the steps described there and my asp.net core app now communicates with my SQL database (after being published to IIS):
https://www.codeproject.com/Articles/674930/Configuring-IIS-ASP-NET-and-SQL-Server
It also happens when you install dotnet-hosting-bundle/dotnet runtime beofore IIS.
In this case re-install dotnet-hosting-bundle/dotnet runtime.
To be able to see the excetion's detail I just needed to change the ASPNETCORE_ENVIRONMENT to "Development" in the "IIS Express" profile in the launchSettings.json file. I aldo needed to create the corresponding appsettings.Development.json file to set the variables and data needed in my App. When the environment is Development net core send the detail exception by defaul. As we can read here in the official documentation.

Deploying the Windows Form Application by Click Once

I knew nothing about ClickOnce and I tried to find more. I have an Windows Forms Application and I want to use a web server (http) to deploy it by click once for testing by customer.
I have Apache in my system to use my system as a web server (which is in XAMPP software)
I have several questions:
When I want to publish the application, must I copy it in specific directory?
Is there any free web server that I can use?
If there is, must I copy my application on web server? How?
BTW, If you know a detailed instruction about that ,may you introduced?
PS: I read this reference completely.
You specify the location of your ClickOnce Application in Properties -> Publish. The Publishing Folder is the Location, where Visual Studio tries to save the published Location. If you are using a WebServer where you have to log in, Choose here a local path on your computer. The Installation Folder URL is the URL, where the ClickOnce Application is looking for Updates. This is the Url on the Server where you have to copy all the Files from the Publish Folder to, if its not the same.
I dont think that there is a free web server you can use. There are a few Services which are quit cheap but as you mentioned, you can use your own Server with XAMPP. I never used XAMPP so i cant help you their
Yes you have to copy your application to the Web Server. Im using WinSCP for that. Be sure to copy the files to the location you have set in the properties. If you are using XAMPP, you may copy the files locally to the XAMPP folder
There are no specific instructions i can mention. You will find everything in the Web. There are some useful articels at CodeProject

Problems with ClickOnce deployment (to me, it's so annoying)?

I've just tried ClickOnce for the first time to deploy my SQL Server Compact application. I think this kind of deployment is very unprofessional:
The output setup is a folder including 3 objects, one folder named Application Files, a setup.exe and a .application file which I've never seen in a professional product setup package.
Plus, clicking setup.exe seems to help user install the application so quickly but user has no chance to select what location s/he wants to install the application. It's installed by default at somewhere in the target computer. And even I tried looking for its location after the installation, I couldn't find it.
The last, after the installation, there is a folder named "Microsoft" in All programs menu, and the installed application shortcut is located in there. I wonder why it is always Microsoft? I even tried editing my Company info in Assembly info through Project Properties window. The application shortcut is something strange when I can't find its target executable file in its properties window.
With all the above ClickOnce can bring to me, I consider it as a funny job for testing the application only not for publishing a commercial application.
Could you please correct me if there is any wrong in #1, #2, #3 and please give me a better solution for deployment, I'm interested in SQL server (service-based and file-based) application only?
Your help would be highly appreciated. Thanks.
A ClickOnce install is a per user "sandboxed" install, not a normal install you think about when installing normal applications. The .application file is used by the server as a manifest and to determine if it needs to update the install when clicked.
The reason you can't find setup.exe is because it isn't there. Once the files are installed, it isn't kept. The user isn't supposed to know where the files are, the system manages the location and updating of the app.
So, with all that, it appears you need a more normal install, not a ClickOnce. ClickOnce isn't intended to install services or other per machine files.

Installing a Windows Service -Setup.exe fails

There is a weird issue I am facing. I created my first windows service looking through various blogs and tutorials.
Then created setup for that adding installer etc. It works fine while installing , un-installing via Visual Studio but it fails when i deploy it .
Below is a summary of the errors, details of these errors are listed later in the log.
* Activation of C:\Users\bhuvint\Documents\Visual Studio 2010\Projects\CPNS Library\ServicePackage\CommonPushNotificationWindowsService.application resulted in exception. Following failure messages were detected:
+ You cannot start application CommonPushNotificationWindowsService from this location because it is already installed from a different location.
+ You cannot start application CommonPushNotificationWindowsService from location file:///C:/Users/bhuvint/Documents/Visual%20Studio%202010/Projects/CPNS%20Library/ServicePackage/CommonPushNotificationWindowsService.application it is already installed from location file:///C:/inetpub/wwwroot/ServicePackage/CommonPushNotificationWindowsService.application. You can start it from location file:///C:/inetpub/wwwroot/ServicePackage/CommonPushNotificationWindowsService.application or you can uninstall it and reinstall it from location file:///C:/Users/bhuvint/Documents/Visual%20Studio%202010/Projects/CPNS%20Library/ServicePackage/CommonPushNotificationWindowsService.application.
I have already un-installed the service and trying to install it from the deployed service in the same pc to test. But it fails with above error.
I feel i have deployed the windows service the wrong way. Could you guys please suggest how to deploy a windows service ?? (I have looked through net. All suggest building it and installing it from visual studios. But how to publish it is the thing which i need.)
Please help asap.
Possibly you built the setup project before uninstalling the preovious service. In that case you can't use the new setup to uninstall the service, since the setup won't be the same and can't be able to access the service installed.
You should try to go to a previous version of your project and uninstall the service and for the future unistall the service each time you're building your setup project.
This happened to me several times.
Run visual studio in debug mode, and in your properties of your service project goto tab build events in Post-Build event command line and add a -d so you can run your service without installing it, it will run as an console app
The LocalService account acts as a non-privileged user on the local computer, and presents anonymous credentials to any remote server. Use the other accounts with caution, as they run with higher privileges and increase your risk of attacks from malicious code.
If your service application will not install correctly, check to make sure that the ServiceName property for the service class is set to the same value as is shown in the installer for that service. The value must be the same in both instances in order for your service to install correctly.
NoteNote
You can also look at the installation logs to get feedback on the installation process.
You should also check to determine whether you have another service with the same name already installed. Service names must be unique for installation to succeed.
STUPIDITY PERSONIFIED
As i told i was deploying my service. So this published code had a "setup.exe" file to it. Now I had already created a setup project for the windows service , which i was using for the installing , uninstalling . And i din't know (These words needs courage !!) that msi file created is required to install the windows service. So as i got through the folder structure of the setup project. I came across the .msi file . And hence the problem got solved. The Main problem was :
Me not knowing to use setup projects
And I confused setup.exe with the published windows service with the setup of windows service.
I am really sorry for stealing bandwidth off your precious time. Thanks to all for the valuable inputs.

Published application cannot start, but release/debug version starts well

I have a problem when I try to Run published Application. When I Run Release or Debug Version from VS (key F5) everything work well. So I try to publish my application (no problem). After this I Installed application by oneClick installer. Instalation was finished without problem, but when I try to run this installed application, I only see message: Program has Stop Working.
Please, does anybody know where should be a problem? It´s really wierd, I suppose, when the application run correctly from VS, then it Should run after installing to!? Or am I wrong?
Or is there some option to reset Publish settings in Visual Studio?
Thanks a lot!!!
It depends how you have ClickOnce setup, but the main reason this happens is the ClickOnce system encounters an error while checking for updates or running the .application from the remote location.
It should give you the option to see a log of the problem (or at least the nasty temp file it threw it in).
From here you can determine the problem ClickOnce is having.
Most Common Problems I would Suspect:
The User's having trouble communicating thier auth token / credentials to the web server the ClickOnce app is on.
There's another web-related issue downloading the app manifest or .application from the server
Group / Local Policy Problems
Broken install in on local machine's ClickOnce somewhere causing it to have problems overwriting on disk or finding an appropriate location to setup the clickonce package.
Broken install in on local machine's ClickOnce causing a GUID Conflict (I.e. your app and the broken install can't be upgraded, but share the same GUID)
Antivirus / Firewall blocking access to the web component from the executable clickonce deploy.
These are all the problems I've encountered with ClickOnce and the reasons we've primarily moved away from it to a Wix style installer.

Categories