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.
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 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 a simple wpf application in c# with only one window, MainWindow.xaml. There is no database, not even textboxes, not a single line of code added by myself.
file structure wpf project
I also created an MSI setup project:
setup project
Building of either project works without problem. However, after installation, when I try to run the programme crashes without any error message. All that I see is that the circle-turned cursor is spinning and the windows explorer window can no longer be closed.
Operating system is Windows 10. Anyone has had a similar experience? Looks like a bug in the MSI installer.
Check all the .dll's are included in the installer. Often not all of them are and you need to manually include them. You can compare what's in the install (C:\Program Files...) directory compared to what's in the project bin directory. Often times items like "PresentationFramework.Aero.dll" aren't included and you get a missing .dll error.
If this is the case, you can copy over some of the .dll's until it works. Then add those to the installer.
I am quite new to Visual Studio (Express). I made a project and then put a shortcut on my Desktop to the .exe file. Later I made some changes to the project which are all visible when I run the project in Visual Studio using CTRL + F5. However, the .exe file that is pointed to by my Desktop shortcut still runs the old version.
Any advice is appreciated.
Regards.
by rightclicking on your project in solution explorer, going to properties and then going to the build tab you can choose your output path. bin\Debug\ is the default which is probably where your newly built .exe is going
You may need to use the "Rebuild" action instead of "Build". Sometimes .NET compiler gets confused what has changed - "Rebuild forces a recompile of the solution instead of just the "changed" files.
There can be many reasons for the issue. What I did was removing the .exe files present in the /bin/Debug directory. The rebuild will automatically generate the .exe file again.
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