C# Application publishing issues - c#

I have just created a Windows 7 Desktop Application that allows you to essentially record your screen. I have included all the resources. I am treating it like a "load from CD" type app, as it requires some files as resources. When executing the files to the folder I have made on my desktop, I obviously get the Application files folder, with the manifest and DEPLOY files in; along with the ClickOnce.exe launcher. I then also get the DVD/CD setup.exe file and another clickonce app.
Which installer should I use? And why am I getting these errors? See Below:
When clicking the setup.exe, I receive this error: http://pastebin.com/kgXSnMJY
When Clicking the Clickonce app I get a similar error: http://pastebin.com/1CCT1CKx
What could my issue be?

I managed to avert this, by compiling the files like a "release" inside of a debug. The issue was with the resources I was using, the .dll's did not seem to download correctly (at least I don't think so). Thanks for all the advice and help :)

Related

The file or directory is corrupted and unreadable on .exe files created from VS

So, all the .exe files that I am creating from Microsoft Visual Studio keep on throwing an error message The file or directory is corrupted and unreadable when I want to run them. This is only happening in a specific Windows 10 machine. The same is not happening on other Windows 10 machines. I have tried to recreate the .exe both from VS 2017 and VS2019. I have also tried to create WPF, Win Forms and Console Apps. The issue remains, as long it is a .exe created from VS. Other .exe files, for example, .exe downloaded from the internet or the ones in the Program Files are running perfectly fine. I read about running the scs \scannow and still, the issue persists.
Anyone who may be faced this before and how you solved it?
This error is often a sign of disk/file system defects.
I'd try to move the compiled files out of this folder into
another folder, preferably on another (physical) drive. Then check
if it runs there.
If option 1 does not work you could then try to re-build the files into another folder, also on another (physical) drive preferably.
If one of both of the above solutions works, thats an indication you indeed might have FS/HDD trouble. Try running chkdsk /f c: on the offending drive to check for errors.
If this also does not work, try re-installing Visual Studio.
So, all the .exe files that I am creating from Microsoft Visual Studio keep on throwing an error message The file or directory is corrupted and unreadable when I want to run them. This is only happening in a specific Windows 10 machine.
As the problem only happens with one machine, it seems clear that something is broken on that machine. Either with the OS (unlikely), the IDE or Compiler Installation, or at least that speicific folder.
Edit: As the behavior follows the file around, we can asume it is not the OS. Only something with the build process.
You could try by removing that folder, then making a clean reinstall of the IDE and Framework. But the reliable solution would be to just reinstall that computer from the Filesystem upwards. This is the kind of bug you can spend days trying to debug and still not get anywhere. And even if you could fix it, could you realy rely on the computer to not have other criticial bugs? Maybe ones that do not show a helpfull error message?
As you already verified it happens on no other machines and it persits for any .exe created on this machine, it would at best be trivia to figure out what precisely is wrong. I can give you a rough idea:
Some file got binary damage while in ram or on disk. Either that file was the compiler, or a file that then went on the corrupt the compiler, or a file that corrupted the file that would end up corrupting the compiler. As we are not dealing with the kind of hardware that has to run a mars rover, guided missile system or nuclear power plant, those things happen.
The reason why I was experiencing the stated issue is because of the data transfer methods (Teamviewer, AnyDesk and Microsoft Remote Desktop) I was using to move files between the two computers.
I discovered that the issue was not only about .exe files. Any file I copied across to this specific Windows 10 machine that was giving an issue, I could not open it. It could throw the same error message. In this case, I accept that this an OS issue. However, I was not prepared to reinstall the machine.
So, to resolve the issue, I did use FTP to move the files between the two computers. I uploaded the .exe file to FTP Server from the one computer and downloaded the .exe on the other computer that was giving issues. Downloaded files could then open without any issues.

C# exe not working once installed to program files folder via Wix

I have a C# winforms application which will not work once installed to the C:/ProgramFiles folder. I use an MSI created with Wix to install. When either double clicking the exe or right clicking and running as admin this window pops up and then nothing happens:
Application Error Message:
The application works in Visual Studio and when accessed via the bin/Debug folder of my VS project (the exe in the Debug folder is the one I am using for the Wix install).
After the MSI installs, if I copy the exe out of
C:/ProgramFiles to one of my user folders (ex: C:/Users/User/Desktop) the exe works.
I am guessing this is some sort of UAC/permissions issue but I cannot find any documentation to confirm that theory. Any direction would be much appreciated.
EDIT:
Looking at the error log it is denying me access to my config file. Here is the error text:
Access to the path 'C:\Users\*username*\AppData\Roaming\Leer Copy\leerConfig.xml' is denied.
EDIT II:
This problem is getting more confusing (and frustrating). It will allow me to write to the AppData folder but not read from it (shouldn't it technically behave the other way around?)... Would really appreciate some help. I am reading the contents of my XML file via XDocument.
Originally had hid the config file so people do not mess with it/accidentally delete it. Making the file not hidden fixed the access denial and everything works how it should now.

Where can i find an executable program once i have finished writing c# code

In visual basic class I learned where I could find the .exe file once the program was done and run at least once. Basically we could take the icon for the .exe file and place it on the desktop so that a user could just double click on the icon to run the program without needing to open the IDE or look at any code.
Where/how can i find this kind of file for c# code?
Go to the bin/Debug folder in the project. (or bin/Release if you're using the release build).
You can also go to your project settings, then to the build tab, and in the "Output" heading read/change the "Output Path" setting. This will let you output the exe to some other location, or just see where it is currently outputting in the event that it has already been changed on your machine.
Assuming you're using a web application project you'll use the .aspx file that is generated to access your silverlight application.
The "application" so to speak is actually a file ending in ".xap" that can be found in your web project's ClientBin directory.
The .xap file can also be found in the silvelright project's Bin
If you're wanting to install the silverlight application to a desktop you'll have to enable the ability to run the application "Out of Browser" and it'll have to be installed. More information on Out of Browser apps...

Updates made to application config are only being read correctly in Windows 7 when the application runs as Administrator

We have an application that was built for the Windows Mobile and Windows platforms, using Visual Studio 2005. We have both versions of this application developed using a single code base to try and reduce code duplication. One of the issues that we encountered with this was that the ConfigurationManager was not available for the Windows Mobile platform. We worked around this by building our own ConfigurationManager that reads and writes settings to the "Application.exe.config" file in the Program Files folder. So both our Windows version and our Windows Mobile version use this same custom ConfigurationManager.
This worked fine on Windows XP and Windows Server 2003, but on Windows 7 we have encountered a problem and I don't know how to work around it. When we make a change to the config file (which we can only do by copying it to another folder, changing it and then copying it back... otherwise we get an "access denied" message when we try to save our changes directly in the Program Files folder), the change that we make is only reflected if we run the application as Administrator. If we run the application as a normal user, the default setting from the install are always shown. We suspect that this is a Windows 7 security-related issue, but can someone explain why this is happening? How can we change the settings so that they are also applied when the application is run as an ordinary user?
Windows 7 requires elevated privileges for several folders, including program files. It's not good practice to try to work around this.
Since you are using a custom solution, one option is placing your configuration file under %APPDATA%\yourproduct, which can be reached with
var appDataFolder = Path.Combine(Environment.SpecialFolder.ApplicationData, product);
A better solution is probably to use different configuration managers for different platforms, though. Couldn't some kind of abstract factory be applied?
I suspect your app tried to write to the config file at least once running non elevated and without a manifest. This made a "compatibility files" folder for your config file. When you run non elevated it looks there now. (See http://www.gregcons.com/KateBlog/FindingFilesYoureSureYouWrote.aspx for screenshots of how you can confirm this.)
If all you want is for a human, or some utility program you wrote that can run elevated, to be able to edit the config file, you can leave it where it is and put a manifest on your app to prevent virtualization. See http://www.gregcons.com/KateBlog/AddingAManifestToAVistaApplication.aspx for a sample manifest. That blog post goes on to tell you how to embed the manifest, but you don't need to, an external manifest will work. If your app is foo.exe, name the manifest foo.exe.manifest and put it in the same folder. This will prevent virtualization and cause the app to read the "real" config file.
If changing the config file will be a normal everyday occurrence, don't write the file under Program Files. AppData is a good choice.

Error in asp.net but application run smoothly

I got a error:
Error 1 Cannot copy assembly 'ICSharpCode.SharpZipLib.dll' to file 'FileLocation\bin\ICSharpCode.SharpZipLib.dll'.
Unable to add 'FileLocation\bin\ICSharpCode.SharpZipLib.dll' to the Web site.
Unable to add file 'bin\ICSharpCode.SharpZipLib.dll'.
The process cannot access the file because it is being used by another process.
Any idea about this?
This is an error you can get when you have a file that's still locked by a process; it sounds like the file was still open by something when you went to build,so it couldn't copy it to the website.
As long as you aren't directly modifying the ICSharpCode.SharpZipLib source code, and since it's reporting it to already be in the location you need, it's possible that the development or IIS server just still had the file open, in which case it wouldn't be a big deal. (Did you close all browsers?) If that's the case, and your application is running fine, then it's probably not a huge deal, although I would probably close down the development server, and Visual Studio, then reopen and try again. (If running on IIS, try restarting the website.)
If you start having issues with whatever part of your code uses the Zip functionality, then you will need to investigate further.
Sounds like your app was recompiling and tried to copy the zip lib, which was already in use because of a bad ref in visual studio or a running program. When does this occur? Please provide more details. Close out visual studio (if its running). If its a web app, restart IIS and try doing whatever unknown action you were doing again.
Application tried to copied ICSharpCode.SharpZipLib.dll file from GAC or Visual Studio Assembly folder into your application's bin folder but it can't copied and application runs successfully on your system because your application put this dll file from GAC. But whenever you will run this application any another system on which Visual Studio not installed, on that machine it couldn't runs properly....

Categories