I am trying to publish a WinForms c# application, but whenever I do, regardless of x86 or x64, I get an error on the target machine, saying that the .dll is missing. I have tried various solutions, but nothing seems to work, from adding the files manually, to switching the output to either x86 or x64, nothing works; the file doesn't get created if I publish it.
The only thing that actually works, is if I copy the whole of the release/debug folder on the target machine. That, however, is undesirable, as I don't want the user to actually have/see all those files. How do I solve the error?
To create a new setup project
On the File menu, point to Add, then click New Project.
In the resulting Add New Project dialog box, in the Project Types pane, open the Other Project Types node, open Setup and Deployment Projects, and select Visual Studio Installer.
In the Templates pane, choose Setup Project for a standard setup, or Web Setup Project for a Web application.
To add an existing setup project to a solution
On the File menu, point to Add, then click Existing Project.
In the resulting Add Existing Project dialog box, browse to the location of the setup project and click Open.
Related
I have a WPF app that works with local SQLite and Entity Framework Core. I want to distribute my app using ClickOnce.
Everything works fine when I run it using Visual Studio 2017. But app had a crash on a start when I used ClickOnce. The crash was so early so I couldn't even log the exception. After some time I found that in publish folder some dlls were missed. For example System.Runtime. All references are NuGet packages. Then I found that despite of I have a reference to the dlls in my project ClickOnce application files list doesn't contains it.
The only solution I have found for now is to add missed dlls as files in root of my project and set build action to Content. In ClickOnce application file dialog I set publish status to Include.
It works now but it looks like not the best way to do it. The question is why they are missed in the first place. More likely I missed something or I am not understand the root of the problem.
UPD:
You can find an example code here.
It works from Visual Studio but crashes on a start when you try to install it as ClickOnce application.
UPD: The problem was fixed in Visual Studio Professional version 15.6.1
There are two ways solving solve this.
At first, you have to go Properties → Publish → Application Files, and at this place, make your DLL files include in your project
But if it does not work, go to References and make the DLL file CopyLocal = False. You add a DLL file like Existing Item in your project and make them Copy Always.
It will work correctly.
But for your sample I watch this and I solved it. Look at this image:
You have four DLL files. You need do this for them:
System.Diagnostics.Tracing.dll
System.Reflection.dll
System.Runtime.dll
System.Runtime.Extensions.dll
At first go to your reference and make them Copy Local False:
Then go to the path of each DLL file and add them like Existing Item, and then make all of them Copy To Output Directory CopyAlways
Then Publish it and run it like in this picture. I run it from publish file and it works.
Even if you set the dll to copy local, the dll will not get copied over unless you actually use the dll in your code. You might try adding System.Runtime in your code somewhere like this maybe?
var dummytest = System.Runtime.GCSettings.IsServerGC;
Based on Issue 9 on https://blogs.msdn.microsoft.com/bclteam/p/asynctargetingpackkb/ I was able to do the following:
Symptom
ClickOnce applications targeting .NET Framework 4.0 that reference the Microsoft.Bcl or Microsoft.Bcl.Async packages may experience a TypeLoadException or other errors after being installed.
Resolution
This occurs because ClickOnce fails to deploy certain required assemblies. As a workaround, do the following:
Right-click on the project and choose Add Existing Item
Browse to the folder where the System.Runtime.dll lives
In the File name text box paste in the path of the file
Click the down-arrow next to the Add button and choose Add as Link
In Solution Explorer, holding CTRL select System.Runtime.dll
Right-click the selection, choose Properties and change Copy to Output Directory to Copy always
Republish
I have created single layer windows form application and added one Visual Studio Install Setup Project to create the installation wizard using Visual Studio 2013.
So my application contains one .exe file and number of .dll files (SQLite, EntitiyFramework, etc) and other publish items. I am trying to Obfuscate my code using ConfuserEx.
For that, first I have created the publish build using my Visual Studio 2013.
Using ConfuserEx, obfuscated my publish .exe file. This step was working fine. I tried to decompile the obfuscated .exe file and got the unreadable code files. So that means, the process works fine.
Then I have replaced the obfuscated exe file with release exe file (..\bin\Release\appName.exe).
Then, rebuilt the installer setup project to generate the setup.exe file.
Then I have installed the software using setup.exe. Installation was success.
Decompiled the installed application exe using .NET Reflector 9
Decompiler shows the exact source of my project. So that means something is wrong in the obfuscation process.
Anyone know how to fix this issue?
I find the issue.
I was replacing the ..bin\Release\AppName.exe file instead of ..obj\Release\Appname.exe
Now it is working fine.
Thanks.
I have tried your way, it worked for one time only. I found better and easier way to solve this issue as such:
In the VS installer choose the primary output folder, right click.
Choose exclude filter. form exclude filter window, Choose add
filter.
Write down your program.exe.
Now select your VS installer project, right click.
Choose add File.. Browse toward your confused exe.
After building this, the confused exe will be installed.
It work well with me
I have tried your way, it worked for one time only. I found better and easier way to solve this issue as such:
In the VS installer choose the primary output folder, right click.
Choose exclude filter.
form exclude filter window, Choose add filter.
Write down your program.exe.
Now select your VS installer project, right click.
Choose add File..
Browse toward your confused exe.
After building this, the confused exe will be installed.
Tried and tested all above ways, Failed -> Now look at this way: (A Smaller one)
In the VS installer choose the primary output folder, double click.
Choose your program.exe and remove it. (YES remove it)
Now select your VS installer project, right click.
Choose add File..
Browse toward your confused/obfuscated exe. -> Select it.
After building this, the confused/obfuscated exe will be installed.
the issue in above similar solutions is:
When you exclude the exe it will not include the executable file at all.
So you simply need to remove the exe generated from the project output and replace it with your obfuscated exe.
Thanks.
I have a click once deployment project that has been working fine for a long time now. I added some new dll's to a project that is referenced by it. The dll's can't be referenced in references, so I added them as files to the project.
Build Action is Content, copy to output directory is copy always.
when I build the application, the dll's appear in the bin\debug directory. The program uses them just fine too on my computer. When I deploy the application, the dll's don't make it to the other computer.
Under Publish in application properties I went to application files. the dll's I need are not listed there to be included in the deployment.
I would love some help, I feel like I'm missing something really simple.
I have a feeling if I put the dll's in the main project, it would work. I don't really want to do this, I would like to keep them all located in the project they are actually used in.
When I deploy the application, the dll's don't make it to the other computer.
...
Under Publish in application properties I went to application files. the dll's I need are not listed there to be included in the deployment.
You need to set them to download with the application. Click the DLL in the project properties, then press F4. Set the Build Action to Content, and the Copy to Output Directory to something like 'Copy if newer'
For information - it is likely if you download the DLLs for referencing by a built exe (for example) you may need to configure a manifest file for the executable as well to get it to pick up the DLLS correctly
I have Visual studio project about dataTier application, I prepared a project and in the same solution I have windows from application project.
I want to add as a reference dataTier project to Windows from project.
How can I do it?
Data tier Project in visual studio has no .exe or .dll file so I can not add it as a reference.
The Data tier Project will produce a .exe or .dll file if it compiles successfully on build. Looking in the Project Folder, you'll usually find it in the \bin\Debug or bin\Release subfolder (depending on which build configuration you've used).
But usually you don't want to add a reference in this way. If you right-click on a Project name in Visual Studio, you'll be presented with a menu which has an 'Add Reference' menu item. Click on this, then choose 'Projects' as the type of reference you want to add. You should see all other Projects which are included in the Visual Studio Solution. Just choose the one you want to reference and that's it.
EDIT: Ah, I realise now you're probably talking about the SQL Server Data Tier project type, which contains SQL scripts rather than compiled code so therefore can't be referenced by a C# project.
So, what are you actually trying to achieve here?
I've been looking around and other than: http://msdn.microsoft.com/en-us/library/31kztyey.aspx I have found no information on how to publish a Windows form application I have written.
I have managed to publish and then install my application on my local computer, but not in the way I had intended. I was hoping to be able to zip up the folder containing my published project and upload it somewhere, at which point people can download the zip file and install my application. The publishing wizard doesn't seem to be able to publish in such a way, or if it is, it is fairly unclear.
Can anyone point me in the right direction here? I can also clarify what I would like to do if need.
You can create Setup Project ( File-> New -> Project -> Other Project Type -> Setup and Deployment -> Visual Studio Installer -> Setup Project ). So, in Solution Explorer, you can add existing project. After add your project, you can add your program output in File System window( Right click on Application Folder -> Add -> Project Output ... ), so you select your project from Project ComboBox ). After adding your project output, you can build your setup-project and you will have your setup file in your setup-project.
For more information you can check :
Steps to Create Setup and Deployment
Setup Projects
Try this way: ClickOnce (Too simple, free, many ability like Update )
Edit : Absolutely there are many ways, also you can use third party software (like InstallSheild). and Look at Different Windows Installer and ClickOnce
You can create a setup-project - with this you can simply compile a setup and deploy all the setupfiles/msi and the user can install from this.