Application works in VS, but fails once published - c#

I have an application that runs perfectly when I run it from Visual Studio. But once I hit "Publish" and try to launch "setup.exe", I get an error message:
This application could not be started. Do you want to view information about this issue?
Clicking on yes leads me here. I have no idea what "SHIM" is and it's definitely not part of the code.
The error is the same if I publish to a network share or to my local drive. Once installed, the application shows up in "Programs and Features" and can be uninstalled but a Start Menu entry is not added. It's as if the error occurs during the installation.
I tried chancing the prerequisites (and target framework) between 3.5 and 4, as well as Windows Installer 3.1 vs 4.5 - no dice.
While it is currently targetting 3.5, it was originally created as a 4.03 app. I did change the target framework a couple times and going back to 4.03 doesn't fix it. I'm pretty sure this issue appeared as a result of retargetting.
Can anyone provide clues where to look?

Take a Look at configuration files if you have any app.config or web.config.
If you didn't find any tag regarding the target framework, Do a File Search on you solution folder and if you find something in .csproj or .sln files, change it to the correct one.

Related

"CS0103: The name 'model' does not exist in the current context" error on SERVER only

Overview
I'm trying to patch an existing MVC 4 web app to MVC 5 and from Oracle DataAccess 11g to 12c. It runs fine locally in Visual Studio with no errors, with full functionality. However, when I move it to the dev server, I get the following error:
I looked at the following Stack Overflow posts, and tried the fixes there without any luck:
The name 'model' does not exist in current context in MVC3
Razor View throwing "The name 'model' does not exist in the current context"
I think they don't really apply here because the errors in those posts are occurring in VS, which is working fine for me. Unless I'm looking in the wrong place, my issue appears to be with the settings in IIS on the dev server. That said, if you want me to post the web.config file(s) I can do so.
Application
As I said above, I tried all the fixes in the two links I provided, to no avail. My Web.config files both seem to be okay; at the very least I'm able to run locally without issues.
I'm running the latest version of MVC 5, Razor, etc:
I also tried setting Copy Local to True for all DLLs, which was kind of a blind shot and didn't do anything.
When publishing the site I target "any CPU" and I do not precompile. I tried fiddling with both settings, and it doesn't seem to make a difference.
Server Stuff
My devops are unwilling or unable to help with this issue. When I go to them they simply say "what do you want me to do, it's the dev server." Server stuff isn't really my strong suit, so I'm in "poke and pray" mode.
The server is running Windows Server 2008 R2 with all the latest patches.
When I look at the "installed programs" section of the Control Panel it shows .NET Framework 4.7.1.
When I look at the basic settings for the IIS app pool associated with the application it shows the .NET Framework version as .NET Framework v4.0.30319 with the Managed Pipeline Mode set to integrated. Is there a reason that it's different than 4.7.1? Again, IIS is not my field of expertise.
When I look at the Advanced Settings for the app pool it shows the framework version as 4.0, and "enable 32-bit" as false. Let me know if there are any other settings you'd like to know.
Both 32- and 64-bit versions of Oracle 12c are installed on the server. I verified this with the DBA.
This is incredibly frustrating, because it appears to be fine locally, and I'm not sure where to look to see what's different on the server. I'm getting zero help from the server guys in my department. Any help from here would be greatly appreciated.
Update
Thanks for the comments, they contained excellent information. I had already tried making sure that the web.config files were available, and they were. What I wound up doing to fix the issue was to remove and recreate the "site" in IIS. I have no idea why that fixed it. As I said in the initial comment, I'm not a server guy
I was facing the same issue when deploying my application to server. In my case web.config file was missing in view folder of published application.Although it was there in actual project.
After I added it to back my view folder (Right click -> Add existing item) and on publishing the application. it started working.
Or if web.config file is not in view folder, you can create a new project with same project setting configuration, copy its View's web.config file into your actual project and add it to your project as mentioned previously.
Below is the step I followed to find the issue and fixed it.
1) Make "customError mode = on" in your home directory web.config file. This will show exception on screen. Or check the event viewer for details of warning or exception.
<system.web>
<customErrors mode="On" >
.....
</customErrors>
</system.web>
2) Deploy your project application folder(project home directory) on local IIS. In my case it was working because view was able to find its web.config.
3) Publish your application and deploy it on local IIS. In this case applicaiton was not working because published binary was dropping the View's folder web.config file.
Please check this link as well to your error.
For Oracle dll, if app pool is "enable 32-bit = false" , it is expecting 64 bit oracle.DataAccess.dll. in this case you just have to replace/copy current oracle dll with 64 bit oracle dll in your bin folder. Make sure oracle client is installed or appropriate oracle dll is in GAC.
I've faced the same problem.
I solved this problem by doing the following steps.
Check the files on the Server. In my case all files were available in the Repository but web.config file was missing on the Server.
I added Web.config file to the Server following which all pages started working fine.

Published WPF application exception

I can run my published WPF application file locally fine, however if I install to another machine I get a Windows report error dialog. The only useful error info I see is System.Windows.Markup.XamlParseException.
I've included all the necessary assembly used in the project, plus the 3rd party assemblies (syncfusion) also included in the GAC of that machine.
Is there anything I'm missing?
 
The reported xaml parse exception in the machines other than the local machine may due to the resource files not being included along with the deployed files while publishing the application. So please ensure that the necessary resource files needed for the application are marked as “Include” in the Publish Status like in the below screenshot.
Screenshot
Please check and let us know if it is helpful.
Regards,
Gokul S
I had a similar issues in published WPF .NET Core 3.1 VS 2019.
To me the solution was disabling Trim unused assemblies (in preview):

Service Fabric .Net Core App - not working

I am creating a new project from Visual Studio 2015, a Service Fabric Application, picking up the one for ASP.NET Core, but it does not work when I trying to start it.
I'm running under admin power on VS, I tried to reset VS and computer, reset Service Fabric local cluster, and it's still the same. Then, It's strange but the template for API is working perfectly for me.
For me, it seems to be a problem building the executable, and then it's complaining that it doesn't found it, I took a look to the bin folder, and it's empty.
I attached a picture to describe the error:
I'd appreciate whichever advice/comment/tip/attempt to help me, thanks
EDIT: Added pic with the template which is causing the problem
EDIT: Added pic off the project.json
I'm really pissed off with this bug, I change the references to preview 1 to preview 2 and same error, Seriously nobody more has this error? I tried to uninstall and install SF SDK once again, but still the same, I need to fix it, Any ideas??
Compiling against rc2 can cause this issue.
Execute dotnet --version inside project folder to confirm.
Add global json referencing preview2 will get you up and running.

WPF application doesn't run on another computer

I created a new WPF project. I copied the built .exe file onto another computer and tried to run the application. But nothing happened. It was just loading. Nothing more.
All my WPF projects do this thing.
What am I doing wrong? Has anyone any idea?
Edit: For somebody in the future: the question might not be clear. What I meant was that I created a simple WPF application with nothing in it and tried to run the application on another computer. I wasn't able to make it run. Just nothing appeared. I figured out that the Avast Free Antivirus was causing this problem. When the antivirus is turned off, it runs as expected. Even though it is no solution, at least we know, what was causing the problem.
You are probably missing the dot net libraries on the target machine.
For quick fix, download the dot net framework distributable for the .net version you compiled against and install it on the target machine. Here is 4.5.1 for example.
For actual distribution, look at creating an installer that will ensure all dependencies are installed with the application. InstallShield has a limited edition which may be included with your edition of visual studio
Try publishing your application using click once. You can do this by right clicking on your project > Publish > Specify the location to publish your application > Finish. Copy the files inside the Published folder to another computer and try installing by click the setup.
Note: The instructions I said above only works if you only have basic functions on your app. If your application uses SQL Server, you need to install it first on the computer that you will be installing your application in.
For your reference. How to: Publish a ClickOnce Application using the Publish Wizard

VS 2013 hangs when publishing website to Azure cloud service

I have a website in C# Visual Studio 2013, which was developed by another developer and is hosted on Azure cloud service. Whenever I make any changes and try to publish, Visual Studio hangs and I can't publish it. It is not showing any error message. Besides that I can successfully deploy it by building it, but as it's taking too much time and also costs money to client (as VS Team Services only provides monthly 60 minutes of free build, after that clients get charged for extra minutes). I am using following steps for publishing and it's works fine but after publishing starts Visual Studio hangs and is unresponsive.
The steps to publish the website are as follows:
1) Open the solution in visual studio.
2) Right click on the azure project in the solution explorer, and select publish.
3) The first step in the wizard is to sign in, make sure to select your credentials.
4) The next step is settings, make sure environment is set to production and build configuration is set to release, then click next.
5) The final step is a summary, simply click the publish button.
I am very new to Azure so let me know if I need to make any setting during set up my project.
I hit the same problem after installing the 2.8 SDK and tools. After checking out these answers I still had the problem, but found a solution.
Right click the Azure project in the VS2013 solution explorer, open project properties. Go to the application tab, and there's an "Upgrade" button to upgrade the project to the latest SDK. That did the trick for me.
It sounds like you are doing the right steps to deploy using the wizard. However I don't have enough information to know what would cause this to hang. There are some documentation details about the wizard that might help? https://msdn.microsoft.com/en-us/library/azure/hh535756.aspx
There are other ways to deploy to Azure, which may solve the issue. You can for example download a publish settings profile, and use this to deploy instead of the wizard. Details here: http://blogs.msdn.com/b/avkashchauhan/archive/2012/05/10/downloading-windows-azure-publish-settings-subscription-configuration-file.aspx
Or you can deploy continuously from Git - https://azure.microsoft.com/en-us/documentation/articles/web-sites-publish-source-control/#Step75
Both solutions will require some tinkering in the Azure portal or getting in with PowerShell but there's a lot of ways to deploy.
Doing these two things fixed it for me, not sure which:
Clean build
Server Explorer > (Had to re-enter Azure credentials)
VS2013 update 5.
A related post found here..
https://social.technet.microsoft.com/Forums/virtualization/en-US/4e51b1f0-91c3-4ce9-9a15-a8d10f912c5b/publish-cloud-service-causes-visual-studio-2013-to-hang-crash?forum=windowsazuredevelopment
One user was able to get past the publish freezing by doing the following..
So I did a line-by-line comparison between all of the files in that
new project and everything in my existing one and found only two
possible things wrong:
1) The version stamps (dates, really) in my
files were not upgraded to reflect the latest version of the Azure
tools. I manually changed those in my existing project to match the
garbage test project's date stamps.
2) My XML files had some empty
sections that did not exist in the new project's files, so I simply
removed those empty sections.
3) Beyond that, I also deleted my *.user
file.
Specifically, I was able to remove schemaVersion="2014-06.2.4" from my ServiceConfiguration and ServiceDefinition files and it fixed the issue.
My guess is that your installed sdk version is different than the specified schemaversion.
I tried all above methods none worked for me. So this is for people who already tried above and still couldn't make it work.
=> Publish in Release mode :-)
Yes I was trying to publish in Debug mode which was causing it to hang till death ;-)

Categories