AutomationNeeded
AutomationNeeded

Reputation: 73

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): enter image description here

Is there somebody that can help me? thanks a lot

Upvotes: 0

Views: 802

Answers (3)

Hui Liu
Hui Liu

Reputation: 1048

@ 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.

enter image description here

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. enter image description here enter image description here

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.

enter image description here

Upvotes: 1

gigiabbrescia
gigiabbrescia

Reputation: 160

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.

Add Project Output

Upvotes: 1

Amo Robb
Amo Robb

Reputation: 850

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

Upvotes: 1

Related Questions