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
Related
I started learning c# a couple days ago and want to send my first program to my friend but as a standalone exe file that can be shared through google drive.
I've found several solutions but I coudln't understand any of them. Is there a simple solution to compile an exe file or a standalone app in visual studio 2019 that would just work when you open it
One annoying thing with .NET Core is that when you build it in Visual Studio it makes lots of separate files, which is annoying for portability.
A fix to this is to right-click on your project in Solution Explorer and click Publish. Select Folder Profile, give it a name and save it.
After that, you will need to edit the target runtime option, and set it to win-x86. After that, you should see a dropdown box at the bottom of the dialog, expand it and check 'Produce a single file'.
Then you can hit Publish and it should produce a single file.
NOTE: This does not work in .NET Framework, only .NET Core.
All you gotta do is simply build the project within Visual Studio, once that's done. Go to your projects folder and go into bin/Release (or Debug if you've selected debug build)/myprogram.exe. It should make a standalone .exe file!
Maybe this could also help you.
Official Documentation: Compiling Building in Visual Studio
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
This is my first time trying to use a dll file in visual studio (2012) so I am not sure what I am doing wrong. I am trying to get sqlite into my project following this tutorial
I right click on the project in the Solution Explorer and click Add References
I then click on the browse tab and find where I have the dll file,click ok then ok in visual studio and I get an error saying Reference to *dll path* could not be added. Please make sure the file is accessible and that is it a valid assembly or COM component.
did I miss a step here or something?
The file is located in my dropbox folder (where my whole project is) and the project is a windows store application is that matters
Not a direct answer but instead of referencing the dll directly, you should install the Visual Studio extension for SQLite. The extension includes the dlls for all platforms (x86, x64, ARM). It also makes sure that the right dll is used for the platform that you are building for.
After you install the extension, it will appear in the references dialog under Windows -> Extensions. Also, when you use the extension, you must change all your project build configurations to be x86 or x64 (on the desktop) or Arm (for Arm devices). It will fail to build if you use AnyCPU.
So I made a C# program, and its great and all (its a Windows Form Application). The issue with it, is I don't know how to use it outside of the debug mode form. How do I publish it? My target goal is to create a two folders, put a shortcut to the application in one, along with the other folder which will contain the application and all outside programs (some of the buttons link to batch files). Then I'd want to be able to put it in a RAR compressed file, and upload it online for others to download it.
How do I publish it so that happens? How do I take it out of debug mode?
Go into your project folder, then navigate to /bin/Release. If there's an EXE file with the title of your project in there, copy it somewhere (along with any DLLs that you may have linked) and there's your program. If it's not there, first try Build -> Compile Solution in Visual Studio. If it's still not there, navigate instead to /bin/Debug and do the same thing. Then, copy all your batch files into another folder, put them into the same folder, and RAR it.
P.S. Try not to use RAR, few people can extract them. Use ZIP or SEA (self-extracting archive) if at all possible.
First off, you need to build your application in Release mode, in Visual Studio simply change the drop down near the top of the window to "Release." This will create a bin/Release directory where your sources are located. The folder will contain an EXE for your application and DLLs you need to include. It could (and probably will) include some debugging *.PDB files that you do not want to include -- as those include debugging information.
Copy the contents of that directory somewhere and RAR it up.
Building in x86 Mode
(You should only do this if you have a specific reason to)
If your application uses 3rd party DLLs that are not 64-bit compatible, you may need to do a release build in x86 mode. To do that, click the "Any CPU" drop down and click "New Configuration" (or something like that) and follow the steps to add x86. Then build with the x86 -- Release setting. That will output x86 binaries to a bin/x86/Release folder where your sources are located.
The Preferred Soltuion
Most users are going to prefer some form of automatic installer instead of a simple RAR or ZIP. Visual Studio (Standard/Pro) can create self installing MSIs that do all the work for you. A basic overview is here. You can add shortcuts/etc using the wizards Visual Studio provides.
If you need an even more robust installer you could check out solutions such as InnoSetup or NSIS
To build your application in Release mode instead of Debug, go to the Build menu and select Configuration Manager.
Change the Active soluction configuration to Release. Now, when you build your solution, it will put the executable in the /bin/Release folder.
If you need to automatically perform certain actions once the solution is built, like packaging into a RAR or ZIP archive and copying the distributable to another folder, then check out post-build actions.
After Visual Studio 2010 , Microsoft remove Make setup utility facility from the visual studio and,we have to downlorad that plugin seperatly from
Get InstallShield Limited Edition for Visual Studio
You Have to fill the application
After intalation, goto
Visual Studio-->New Project-->Other Project type-->Setup and Development
You will see follwing screen
Now you can goto InstallShield setup utility and change the things as you requirement.
add all file in debug folder of your project in follwing interface and build solution,
Final setup will locate in your setup folder-->Express\CD_ROM\DiskImages\DISK1**
hope this will help you