I am having great difficulty getting a Windows program, written in VS 2008 C#, to launch another type program. I've put a main program to offer you the ability to launch some other VS 2008 C# programs. When one of them is selected the following code is intended to do the launch:
System.Diagnostics.Process.Start(#"C:\Documents and Settings\rat\My Documents\Visual Studio 2008\Projects\PV_002_082708\PV_001\PV_001\bin\Debug\PV.exe");
It works, but each user will have a different path. The path shown is for my computer. The code would have to know where each persons program was installed! In the past, I could easily call a program that was in the C:\Program Files location because that's where the MS Package & Deployment program put the programs. VS 2008/2010 doesn't put them there!
I'm sure I am not knowledgeable about Visual Studio 2008/2010 to know if there is a way around this, so any help would be greatly appreciated.
System.Diagnostics.Process.Start(System.Io.Path.Combine(System.Windows.Forms.Application.StartupPath, "PV.exe"));
assuming that the program is in the launched application's path.
or...
System.Diagnostics.Process.Start(System.Io.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments), #"Visual Studio 2008\Projects\PV_002_082708\PV_001\PV_001\bin\Debug\PV.exe"));
assuming you want to open the project from it's place.
Once you create the installation package you can set the install path to some fixed path that users will not be able to change and than use that from your code (not very user friendly but it would work) or insert the user chosen path value into the registry and get it from there instead.
May want to have a look at this thread. How-to as well as lots of pro's and cons.
Embedded a *.exe into a dll
If you see the first answer to his question, I think this would work for you.
Simply he is saying, you add a resource file to your project, then when the user runes your program, it extracts your exe file that you added as a resource file to somewhere you know on the end users maching.
Related
Debug (or Release) folder of my Desktop application when copied to another location does not run the exe. It issues no errors, but simply hangs the system for a second or two, but returns to normal straight away, as if nothing had been run.
Does Visual Studio 2015 create dependencies in upper hierarchy of Debug as well? My installer created using Wix was not running the intended exe and i thought it was Wix's problem. But then i tested it by copying the full Debug folder in a temporary subfolder and the app was not running even from there. It can only happen when it has dependencies present in places other than the Debug folder (because system resources (dlls) are accessed from absolute path of C: drive, so they would always be available.
Could there be something wrong in your manifest file or some other settings file? Some relative path pointing to a folder in your source hierarchy? Maybe it is just an image file or some sort of settings file that is missing? Or it might be something completely different.
A I wrote in your other question, one approach for hard-to-debug dependency scenarios is to just bite the bullet and run a thorough procmon.exe session (that is a direct hotlink to the live sysinternals tool share, clicking it will start the download instantly - just so you are aware).
You can see a quick description of how to use this tool in this question: Registering a CPP dll into COM after installation using Wix Msi installer. The key is to set an include filter which will show only events you need to see - basically for your own application.exe should suffice I believe.
Many find this procmon-stuff overkill, and don't want to deal with it - but trust me, it almost always reveals something unexpected (not always useful however).
As before this answer may also be worth a quick skim (on dependencies in general): After creating MSI Installer for WPF app in Visual Studio 2017, EXE does nothing. I would at least try the Dependencies.exe tool - even if it is a bit "beta-ish". You can download from here: https://github.com/lucasg/Dependencies/releases.
And certainly double-check the modules view in Visual Studio which I describe in the linked answer (Debug => Start Debugging, then go Debug => Windows => Modules). It should show whatever was loaded to run your project interactively.
I'm running my .NET 4.0 (C#) project in debug mode after I start VS2013. It runs just fine.
The second time I start it from VS, I get the Dialog box that says "Error while trying to run project: Unable to start program C:\path\to\file.exe"
The process is still alive in the Taskmanager when I dismiss the dialog box.
From Windows Explorer, I can run the program just fine. And after closing it, the process is gone too from the Task Manager.
A rebuild doesn't help.
Is this a common problem with a known solution?
I had an issue similar to this and I had to clear the component cache instruction can be found Here.
Hope this helps.
For my case, it cause by Platform target, you could force choose it to x86 or x64 which your project is:
Each Project's Properties > Build > Platform target
As I pointed out also here, the only solution that worked for me was to disable the ConEmu integration:
ConEmu → Settings → Integration → Default term → disable Force ConEmu as default terminal for console applications
Some users reported that it was enough for them to disable the Aggressive mode in that same settings tab; that wasn't the case for me though.
The topic is old, but this might help someone else.
So in my case I made a file in Visual Studio with .cp extension (accidentally deleted the last 'p') this made visual studio just "include" the the file and not mark it as a compilation unit, thus not compiling it, I looked the *.vcxproj file in a text editor and found out about this, so if you open the project file in a notepad or something just find your file at the bottom usually and change from <Item .../> to <ClCompile .../>
I was getting similar errors. I just had to restart visual studio. Sometime couple times a day.
I had a similar error and resolved it by cleaning the solution. Right-click the solution name in Solution Explorer and choose Clean Solution.
I found a solution here:
Please check "Use Managed Compatibility Mode" under Tools|->Options->Debugging->General.
I'm Brazilian, I don't speak English very well. I did this translation on google translator.
I know the topic is old, but it can still help someone.
I had this same problem in the following situation, I have a dual boot computer (linux debian 11 and windows 10). Inside debian, on my NTFS D disk, I created a folder to perform programming tests. After accessing that same folder with windows, I created a new project in visual studio inside that same folder that I had created in linux. The creation of the project went without problems, however when I tried to run the project (F5), I received the same error from this topic. I tried all the solutions I found on the internet, and nothing worked. I gave all permissions to my admin user and it still didn't work. Then I realized that even going straight to the folder where the application's executable was and clicking directly on it, I still received the access denied error message. So, I took the project out of the folder I had created in linux, and it worked. So, what I could conclude, is that because the folder where my project was was created in linux, for some reason, my windows didn't trust this folder, so it didn't allow running executables from inside that folder, even this one executable having been created by visual studio from within windows.
Just simply create a folder name as "projects" in c drive and copy paste the newly created project in it. Run the project by doing clean & Build or Rebuild method . It will work
open the folder which contains the solution in visual studio.
again, open your *.sln file by double clicking it inside the solution explore once opened try running the solution or rebuild the solution. once rebuild gets completed, it will open without error from next time.
My way of solving the error : error while trying to load project : Unable to start program and c:\Path\to\file.exe was simply by
First restart Visual Studio
Click the build icon
Select the rebuild option
Run the Program or Debug the Program
This was a weird one. Going to put what happened to me here because it might happen to someone else. Everything was fine with the app until suddenly after some fairly insignificant code changes I suddenly started getting this error. Visual Studio was compiling the executable just fine. But, the moment I tried to run it (either from Visual Studio or directly) the executable file would be automatically deleted right out of the Debug folder. Super odd--never seen anything like it. I began to get suspicious that perhaps an anti-virus or the OS was somehow identifying a checksum or some signature in the executable as "dangerous". Or perhaps some obscure compilation bug was corrupting the executable. So on a hunch I made another innocuous change (added a couple of lines of code to color code some text in a rich text box) and the problem went away.
While trying to debug an asp.net website in visual studio 2013 professional I am having a weird issue. The website is simple but uses flat files and folder structure and files in it for performing some operations. There are two important folder in this website that contains 100 thousands of files and images. When I try to start debugging and do not remove files from these two folder then VS crashes and restart, but if I remove files then VS proceeds normally. The files in these folders are csv, txt and image files. What I can understand is that VS goes through all these folders and files before starting the debugger, hence somehow I need to tell VS to not to consider these folders. I am not able to find anything related to it. Please help. Thanks in advance.
Perhaps take a look at your Event Viewer first and see if you can find anything regarding VS crash.
Also you can try running Visual Studio from the command line devenv.exe /log and then load your solution. If crash still happens, then go take a look at following file %APPDATA%\Microsoft\VisualStudio\<version>\ActivityLog.xml. Perhaps you would find some more details about the crash.
If you happen to be using ReSharper, you might want to disable it and see if that would make any difference. ReSharper likes to index source files in the background which could lead to some usability issue in VS.
Answering for anybody who faces similar problem.
For some reason I dont know why, when starting degugging visual studio was scanning each and every folder, even the folders which doesnt contained any code file, this was making VS very slow due to very high number of files and out of memory exception was being thrown. Since in my case these folders doesnt contained any code file, but still were needed to run the application, I made them hidden from window explorer. This solved the problem as now vs ignores them, while still the program can output report and read reports from these hidden folders.
I'm trying to figure out how to publish an application I wrote. We didn't get to publishing in class, and my programming teacher is having some health issues and isn't available right now.
I found the "Publish" option, and can get it to create a folder with an install program... but I open it, and it just opens the program, and spams me infinitely, complaining that my Access database (located in the bin > debug in the build stage) can't be accessed (from some weird path I don't recognize). I tried using WiX, but it gave me an error when I tried to install, saying it doesn't have access to the install folder (running as admin). I've been googling for a few hours, poking at it, exploring, and I'm not getting too far. Can anyone ELI5?
When you use the "publish" option for desktop apps, VS creates a click-once installer that will place all the files it knows about in the appropriate locations.
Unfortunately, it can't guess which other files your application needs so you need to tell it explicitly.
If you right-click the Project->Properties, go to the Publish tab and click the "Application Files" button, you'll see all files that will be added to the installer.
Next, click "Show all files" at the bottom. Find your database, and change the Publish Status to "Data File".
Note that I've only ever used the Click Once installer to install static files (like images/documentation) that are never modified, only replaced in later releases. I'm not sure whether your (modified) db will be preserved during an update but I suspect not.
If the Click Once install process is too simple for your needs, VS2010 has "Setup Projects" which create more complex installers that support logic/code. For VS2012, the commonly suggested option is Wix. Unfortunately, it's got a steep learning curve but it can do pretty much anything you need.
I believe VS2013 and later have setup projects again through an extension but I haven't tried it myself.
Edit:
The easiest way around this is likely to set the connection string programatically based on where the application is executing from.
Note that as per this answer clickonce apps are usually executed from deep inside the user profile directory (also read the answer below about data directories). It's a side-effect of how ClickOnce works (it wants to install somewhere the user is guaranteed to have write access).
Check if there really is an .mdb in that folder. If not, you need to tweak the installer or the properties for the .mdb. Assuming it's in the same location as the executable, you can tell your application where to find it...
string dbPath = IO.Path.Combine(
AppDomain.CurrentDomain.BaseDirectory,
"access.mdb");
string connectionString = String.Format(
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source={0}",
dbPath);
I'm not sure why you think the database file added by the installer is in a directory directly under C:\. It's possible you're not looking at the file created by the installer.
To avoid confusion, try changing the name from access.mdb to something else (temp.mdb?), build the installer, rename back to access.mdb. Now, when you've installed the application, make sure the file you're looking at is now called temp.mdb. If not, you're looking at the wrong file.
This Link Has Full demonstration of Database Connectivity And Publish a C# application with database. The application is also running on another machines.
How to Publish C# Application with access database
Is there any way to make a hyperlink from a website which would open visual studio and find a file / find a class in a project or so?
We have some code review protocols where there are names of the classes to review and it would be nice if you could just click on the link and it would lead straight into the visual studio instance.
You have to write a program that installs a URI protocol like vs://C:/Projects/myproject.sln&class=Class%20A that would open the Solution myproject.sln as described in http://msdn.microsoft.com/en-us/library/aa767914(VS.85).aspx!
With this sheme you have to register to open another manual written program (clicked on a vs://-link) to start the devenv process with some parameters. Take a look at this to get some more information about "Opening a file in a project from the CMD".
Conclusion: There is no way to do this without installing a program and a macro in Visual Studio.
You can check devenv.exe start up switches(parameters) here:
http://msdn.microsoft.com/en-us/library/xee0c8y7(v=vs.90).aspx
http://msdn.microsoft.com/en-us/library/19sf6kk3(v=vs.90).aspx
Also you can use ActiveX to run CMD commands to invoke the devenv:
How to Run cmd.exe with parameters from javascript
I hope this helps :)