How to rename "Primary output from MyProject (Active)" and .exe - c#

I am brand new to building and deploying Windows Forms applications, so new that I'm not even sure "build" and "deploy" are the correct terms. I read this excellent guide to creating an installer for my application, and I mimicked it almost exactly.
I have a winform project UmfExtract and a setup project UmfExtractSetup that installs UmfExtract . After installation, however, on Windows 10, an icon appears at the top of the start menu, under Recently Added: "Shortcut to Primary output from UmfExtract (Active)." I want to rename that to just "Shortcut to UmfExtract" or just "UmfExtract." Additionally, in the installation directory, the .exe and the .exe.config are the same as the original name of my project when I first created it, PythonExecuter. How do I change PythonExecuter.exe to UmfExtract.exe? Elsewhere on the user's computer, the application is named correctly. On the desktop, the shortcut icon says "UmfExtract," which is correct.
In all my research on this, people have said to change the Assembly name. I have done that. The Assembly name is UmfExtract:
I looked into the Outputs property of the Primary output object:
The AssemblyTitle and AssemblyProduct in AssemblyInfo.cs have been changed to UmfExtract:
What else could I possibly be missing? Could I perhaps accidentally be installing an older build of my project? I right-click on each project in the Solution Explorer and click Build (while the Debug/Release drop down box in Visual Studio is set to Release), then I navigate to the Setup project on my local machine and go to \Release\UmfExtractSetup.msi. I imagine that .msi file is updated/overwritten to the new information each time I Build the projects. Could it be that I'm building wrong?

I'm not 100% sure what was wrong, but the problem has been fixed. I believe the error was in the build process. I believe I was installing an old build of the project. I clicked Build > Clean Solution from the menu bar, then Build > Build Solution. I also right-clicked the UmfExtract project and then clicked Clean, then Build, and I also right-clicked the UmfExtractSetup project and then clicked Build (there was no Clean option in the right-click menu for the Setup project).

Related

Trying to obtain the exe for a c# form Application, getting .dll file

i've already searched and seen almost all in the web and in the forum, but i can't deal with that.
What I'm trying to do is to obtain an installer and then an exe of my form application by using c# in visual studio 2019.
So, i've followed that tutorial:
https://www.youtube.com/watch?v=fehVTLNQorQ&ab_channel=FoxLearn
so i correctly obtain the setup file. Then, when i launch it, it installs and if i try to run it i get that error: "You're trying to open a file type system .dll"
What i'm doing wrong?
I also structured my main class as in that response:
Changing a source file to compile Main() method in a project, in VS c# console application
I also used that suggested setting (sorry for non english language but it's quite understandable):
Is there somebody that can help me? thanks a lot
Some things you may want to check:
If you have more than one project in your solution, make sure that the main project is marked as Start-up project. On the solution explorer, right- click on the main project and select "Set as start-up project".
If you only have one project in your solution, check that no .exe is being produced in the corresponding bin folder. If it is, go to your project properties, inside Debug, and make sure that the option "Start project" is selected. You can also try to select the option "Start external program" and browse to the .exe in your bin folder (although the result should be the same).
If no .exe is produced, you may want to have a look at this post. It is similar to you problem I think but the other way round. I looks that the UseAppHost should be True for your case
You have to choose "Publish Items" and not "Primary Output" when you add a "Project Output" in "Application Folder" for .Net Core 3.1 in the setup project created by Visual Studio Installer Projects Extension.
# Alessio Orlando.
Based on my test, there is a different step between adding different project to the installer.
For WPF App(.NET Framework) project and Windows Forms App(.NET Framework) project: You could choose Primary output when you add a "Project output" in "Application Folder" in the setup project.
For WPF Application(.NET Core) project and Windows Forms App: As gigiabbrescia said, you have to choose Publish Items when you add a "Project Output" in "Application Folder" in the setup project.
Finally, there will be an .exe file in your installation directory after installing your Setup (Like the picture below). And you could click on your .exe file to run the program.

Cannot build my class library on Release, only on Debug

I've right clicked the project in Visual Studio and selected properties. Then I changed the Build configuration to Release. But even after hitting Control+Shift+B to build my library, I still find the /Release/ folder empty.
If I close the properties window and re open it, I see the option has switched back to Active(debug)
What am I missing?
You haven't actually changed to make the Release configuration active - you've just gone to the properties for the Release configuration.
The "active configuration" is normally in a toolbar just under the main menu - look for "Debug" there and change it to "Release" like this:
Or go to "Build > Configuration Manager" and change the active release there.
Open your Output Window of Visual Studio and after successful build ensure that your project's DLL is created in Release folder, with actual complete path provided, where you are checking for binary presence.
If it's ok, check if your Console application doesn't have any post build event in it, which simply moves the binaries of DLL projects.
If it's not, try to not use Control+Shift+B combination, but simply make a RightCLick DLL project and make it Rebuild.
Hope this helps.

Visual Studio project not building when I click debug or press F5

VS2010 c#, winforms project.
It does not build automatically when I click on debug or press f5. If I manually build the project before I debug, it compiles and changes are picked up.
My other projects all work as expected. Why doesn't it build automatically?
Right-click the Solution (not project) in the Solution Explorer and select Configuration Manager. Check if Build is turn off for the current configuration.
Check your settings in Tools->Options.
Go to the projects and Solutions area, Build and Run page.
There is a setting "On Run, when projects are out of date:" Make sure this is set to 'Always build.'
I ran into this same issue and I did the following:
Run Build Clean
Close the solution
Delete any .suo and .user settings files
Delete any .ncb files
Open the solution again
Unload the project
Reload the project
Make sure the project is set as startup again
Debug away!
You may be able to only do steps 6-9 but I don't know how to get back in that state.
Because my project was independend from other projects by using prism I had to uncheck 'Only build startup projects and dependencies on Run' in Tools->Options->Projects and Solutions->Build and Run.
When you work on a dependency
In my case, I am working on a library used by an executable.
It was necessary to say to the solution to include the dependency of the library in the executable project solution to build the executable code and the library code before launching the debugging:
Tools Menu, click on Options. Go to "Projects and Solutions/Build and Run", "On Run, when projects are out of date" needs to be on "Always build".
Right-click the Solution (not project) in the Solution Explorer and select "Project Dependencies". Check the boxes of dependencies "Lib1" and "Lib2".
Just in case someone else runs into the same problem as I did: for me it turned out to be a setting in my web.config as follows:
<httpRuntime fcnMode="Disabled" targetFramework="4.5" maxRequestLength="40960" executionTimeout="1200" requestValidationMode="2.0" />
What this guy does is he disables File Change Notification, which is used to restart the application domain when a change is detected in critical files e.g. anything in the bin or .config files. Without fcn, I would make code changes, press F5 and still see the old code, and all breakpoints would be whited out because the source was different to what IISExpress was serving up.
I had a similar situation with multiple projects in a solution in Visual Studio 2013. One of the projects that the Startup project uses was not building when I clicked the Run button. I had to right-click on the Startup project and select "Build Dependencies" and check the project that wasn't building in there.
Was scratching my head on this for a while, turns out our office's Folder Redirection configuration (e.g. My Documents to point to a Network location) did not integrate well with VS.

Why are my binaries not placed in the /bin/release folder when I build a Windows Service in C#?

I am new to C# and VS 2010, and am following an online guide to creating a C# Windows Service in Visual Studio 2010.
When I try and build the application however, I don't get any files created under the /bin/release folder.
I do get files under the /bin/Debug folder.
I have tried all the build configurations e.g Active, DEBUG, Release, All but nothing changes.
I have tried closing the solution down and restarting etc.
I have also experienced this same problem on a number of other projects which have been C# console apps.
The /bin/release folder exists (as I had to create it by hand) and I have checked the output path in the properties tab to ensure the release configuration is targeted to that folder.
I asked our "C# guru" at work and he didn't have a clue. Does anyone know what could be causing this?
Most likely, you are only configuring the Release build, not actually building the project in Release mode.
Simply select "Release" mode from the drop down box in the toolbar, as shown in pic below:
or you can do the same thing from your project's Properties:
Then when you will build the project (Ctrl+Shift+B), it will build in Release mode and place the output in the folder you have configured in Project properties. (Usually this is bin/release.)
If you still don't see files in the release folder then as suggested by Gishu in the comments, check the Output Window while the build is in progress to see where the binaries are actually being created.
I witnessed the same problem.Even when I had the configuration as Release as shown above,VS will some how ignore it and as I can see from the output window,it puts it in the Debug folder.
Trick that worked for me:
1] Go to Build Tab on VS.
2] Click Configuration manager.
3] Under the drop down both at active solution configuration and the project specific configuration, select release.
4] Check the project properties just to make sure. Then build it.I the release folder the required files.
Accept the answer if it helps.

"A project with an Output type of Class Library cannot be started directly"

I downloaded a C# project and I wish to debug the project to see how an algorithm implementation works.
The project has come in a Folder, inside this folder there are -
.sln file and
a folder which has source files and a .csproj file.
I installed Visual Studio and opened the .sln file present in the main folder. I built the project successfully, but when I try to debug the project I get this message:
A project with an Output type of Class Library cannot be started directly In order to debug this project, add an executable project to this solution which references the library project. Set the executable project as the startup project.
The strange part is that I don't see a main function anywhere.
What should I do to get round this hiccup?
The project you have downloaded compiles into a dll assembly and provide a set of classes with implemented functionality.
You should add to your solution a new project with Output Type of either Console Application or Windows Application (VS Add Project wizard will offer you different templates of Projects).
In the newly added project, you can implement logic to test your Class Library.
Output type of the project you can find and change by the following steps:
Right click on project in Solution Explorer -> Properties.
In opened tab with properties select Application and there will be ComboBox marked with Output Type label.
Just right click on the Project Solution
A window pops up.
Expand the common Properties.
Select Start Up Project
In there on right hand side Select radio button with Single Startup Project
Select your Project in there and apply.
That's it. Now save and build your project. Run the project to see the output.
This was the solution that worked for me since I couldn't find 'Common Properties' option.
Select your topmost level project in Solution Explorer.
Go to Project, and in contextual menu Set as StartUp Project.
See also: A project with an Output type of Class Library cannot be started directly
Just needs to go:
Solution Explorer-->Go to Properties --->change(Single Startup project) from.dll to .web
Then try to debug it.
Surely your problem will be solved.
The strange part is that I don't see a main function anywhere.
That is exactly your problem. The project merely creates a DLL. It has no executable to run.
You will need to add a second project, which is an executable which references the other project, and calls something in it.
1) Right Click on **Solution Explorer**
2) Go to the **Properties**
3) Expand **Common Properties**
4) Select **Start Up Project**
5) click the radio button (**Single Start_up Project**)
6) select your Project name
7) Then Debug Your project
Right Click on "Solution Explorer" -> "Properties"
Expand "Common Properties"
Select "Start Up Project"
click the radio button "Single Start_up Project"
select your Project name from the drop down list.
If still not working after the above steps, then try this.
Expand solutions explorer.
Right click on project name -> "Properties"
Go to "Application" tab
Select "Output type"
From the drop down list select the appropriate type according to your application.
"Windows application" or
"Console application"
Then save (ctrl + S)
Try debugging (F5)
You'll need some kind of app (Console Apps are my favorite for debugging, but a WinForm will do) which uses your Class Library. Just add a new project (in the same solution) of a Console Application or Windows Forms Application, and add a reference to your current project. Once you've done that, make any calls you need, set your break points, and go to town.
I had a similar issue when trying to use the Experimental Instance of Visual Studio 2013. This was for a vsix project (Creating Snippets).
Solution was:
Right Click Project in Solution Explorer > Properties > Debug
Setting the Start Action to "Start external program" and using the following path:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe
This option was set to "Start project" which won't work for the application output type Class Library, which caused that same error.
Note: Yours may differ depending on how you installed VS.
Error solutions is that you have already open your project but by mistake you have selected another class library .. that's reason this error is showing ... so what u need to do you u just select u r project then right click on u r project
after right click u can see the list box and select the "Set as start up project " option .
Accepted answer works if your solution has a project that compiles to an exe. If your solution does not have any projects that compile to an exe, then you have to use 'Start external program'.
VS2019 instructions:
right click -> properties on the main solution
debug, start external program, and add command line arguments
VS2022 instructions:
right click -> properties on the main solution
scroll down to Debug
Debug > General > Open debug launch profiles UI
left click the 'new' icon in the top left, select 'executable'
fill it out as per VS2019 (pick the exe and add command line arguments)
when clicking the start button, first select the profile you made
Suppose you have multiple project in the solution. Select the project that you want to view in browser and select 'Set as StartUp Project'. In your multiple project soln which was the main, the visual studio was unable to identify. this was the main problem.
You can right click the Class Library project and from the drop-down choose Initialize Interactive C# which will load your project context and you can work it in the interactive session.
In my case, the cause was that one of my projects in the solution wasn't loaded. The reason it couldn't load properly was that the file path length of one of the files was too long. Upon deleting this long file, I could reload the project, and build the solution.
If the question involves an Azure project, make sure you have the "Azure development" tool set installed, or when you go to run a solution you may get this same error.
Tools > Get Tools and Features... > Tick the box next to Azure development > Click install
None of the answers provided above helped me resolve this error, this is what resolved the issue for me.
Right click on the solution and select "Properties", which is in my case "Sintctech.Data".
Select the section called "Application".
Check what you have selected as your output type. If it is "Windows Application", change it to "Console Appication".
Rebuild and the problem should be fixed.

Categories