问题
Why after I've published my Project, I cant just run my exe (the one you find in your "Debug" folder) without getting this error message after you close your project? - Thus not using my published project, and still just using the exe
I've created a test project just to test if this is the case, and this happens every time.
- Create a new windows project.
- Build it.
- Go to the debug folder.
- Copy the exe to your desktop
Run the program
So a blank form opens up.
- Now close it.
- And there's the error message again.
How do you get rid of this? I've read you should add stuff to your manifest etc, but surely there must be an easier way? I'm using Visual Studio 2008 on a windows 7 64-bit machine.
EDIT:
I found the solution to the problem. The reason this happened is because I had the word "installer" or "Setup" in my project name, can you believe it... that something like that could influence the project like this.
i found that this question is answered here How to prevent “This program might not have installed correctly” messages on Vista This was indeed the reason the program did this.
回答1:
This happened because the project had the words "Installer" or "Setup" in the project's name. Creating a project with a name without these words in solved the problem. (A very strange problem indeed)
A link to a similar question and answer here
回答2:
Add manifest for your application with such content:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!--The ID below indicates application support for Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!--The ID below indicates application support for Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
</application>
</compatibility>
</assembly>
回答3:
Windows seems to think your program is an installer. There is a page in the MSDN with information on why Windows may consider your application an installer.
Maybe the answer to this question helps you find an answer?
回答4:
Turning off UAC works on Windows 7. You don't need to rename your app.
- Press the start button and type "uac"
- Open "User Account Control Settings"
- Drag the slider all the way to the bottom
- Restart your PC
- Open your .NET app again
But if you cannot turn off UAC (eg. on business machines) then the best way is renaming your app to remove "setup" or "installer" from the [AssemblyTitle] field in your manifest.
来源:https://stackoverflow.com/questions/14562138/error-while-running-exe-after-publishing-this-program-might-not-have-installed