How do I create a portable app (runs without installing) - c#

How do I create an app that is:
lightweight: I am guessing don't require .NET frameworks maybe?
portable: runs without installing and saves data in the app directory, so i can just move the folder or maybe even the exe?
this is just a personal experiment: i want to try create a simple todo list app that has the above attributes
I am thinking:
C#/WPF (but requires .NET framework, I can explore client profile thogh)
Appcelerator Titanium (i think this will be lightweight & good enough? I do not know if I can have a portable titanium app though)

It is almost portable if the target machines have .NET Framework installed.
NDepend is such a product, which is built against .NET 2.0 and runs fine on Windows Vista, Windows 7, and other Windows if you manually install .NET 2.0 before.
Personally, it is not hard to write an application launcher in native languages such as C++/Delphi to detect whether the target machine has .NET. If .NET is not yet installed, this launcher can display a warning or help install the framework automatically. (Even some installers allow you to do this.)

If you want to write it in C#, you either need the .NET framework or the Mono framework. Either way you need it. Thankfully .NET 2.0 is pretty ubiquitous.
By default, .NET uses xcopy deployment, so you can just copy the executable and any necessary DLLs around in a directory. It doesn't need to be "installed" unless you explicitly create external dependencies.

#jiewmeng, here i leave a few keys to build an portable application
If the application need save additional data like configuration files o data files , must be saved to the same folder of the exe application or an child folder of the application.
The application should not read/write configuration data to the Windows registry or in the %Appdata% folder.
avoid the use of external dependencies like ocx o dll files, that need to register in the system.
try to use an language wich makes native applications without framerworks dependence a good recomendation is use Delphi.
If you want to use .Net language, choose a version of .Net framework, that is in common use in most of the systems like the Microsoft .Net 2.0

Use Delphi, it's always portable and smaller

Related

How to Install a Driver as Part of a Winforms App

I am currently working on a WinForms app in Visual Studio 2019, which uses a USB to I2C adapter to read EEPROM register values from a device. The manufacturer of the adapter provides the driver for the device in a downloadable zip file on their website which contains the .inf and .sys files among other things. I would like to have it so when the end user installs the app, the driver is automatically installed as well. What is the best way to do this? I have a Setup project in my solution, which I can use to put the driver files in the application folder, but that doesn't mean the driver is actually set up.
I found one potential solution that used System.Configuration.Install, but my targeted framework at the moment is .NET core 3.1, which unlike .NET framework does not have that namespace. I am only expecting users to use Windows 10, so I theoretically could switch to .NET framework for that namespace if necessary. However, I don't know if that will break anything in the app or if that is the easiest way to go about this.
I am very new to deploying apps so I really don't know the best way to go about this. Any direction is appreciated.
There are third-party .net core ways of doing this, such as
Core.System.Configuration.Install
Porting of System.Configuration.Install for .NET Core. (.NET 4.0
version)
Use at your own risk
however, there are also oodles of installers that have this capabilities.
Lastly, this can also be done with powershell, P/invoke and I believe there was talk in github about releasing this source code however you will need to track that down and follow the trail yourself

Running C# application with .NET - MONO

I have a simple application made using C#.
Now how do I make it , such that it runs on all systems.
If a PC does not have .NET framework installed - it shouldsiliently install it with only the bare minimum requirements that the program needs.
Installing .NET framework - too big in size compared to many program , which is just a few kilobytes. Also is shoulf be silent and only if required.
Basically the application should be light and capable to run in all Windows systems.
Not interested in getting to Linux users.
Should I use Mono Project.
Else is there a way to get the bare minim .NET framework selectively pre-installed.
Please advise.
Thanks
Have a look at mkbundle. It will create a standalone executable, with no other dependencies. In particular it does not need neither the Mono runtime nor .NET to be installed in order to execute.
The size might still be a problem (it will likely be several megabytes, even compressed), so there is another tool to strip out everything you don't need from the assemblies: the monolinker.
Note that the size will likely not reach the kilobyte range even after doing all this.
You can do this with a lot of work and the help of the Mono framework. See Embedding Mono for more information.
All that considered, it would be much easier to use a boostrapper to get a version of the .NET Client Framework installed. But you're going to lose the ability to install silently or be in the "kilobytes" footprint.
Unfortunately you cant run a .NET program on a machine that does not have the .NET framework installed and the installer of the program could be made to download the framework automatically but not in .NET .
To run .net applications you need the .net framework installed, that should be either the full version or the limited client profile edition.
The easiest way is to create a setup project from VS and require the .net version you want... the installer should be able to install the .net framework from the internet so you are not required to ship it with the app, which you can do by the way from the installer.
Mono won't be different since it still needs to be installed on the system. Mono however has full AOT support, but I don't have any idea whether that would help you or not... it is still a huge overkill anyway.
If you need your app to be small and run on ANY windows without any dependencies, you should do in c/c++ or vb6 whose runtime ships with most windows versions.

Make programs with required libraries

Suppose that we have a program that uses only some of the libraries of .NET Frameworks, for example the I/O program that read and write file, so this program does not use as many as libraries like NET libraries and etc. So, i wanna make a program that include ONLY the libraries that is required to run! Not all of .NET Frameworks, can i do sth like this ? If yes, please explain your idea.
Thanks for your attention :)
Your program does not "include" the required libraries. They are loaded as required, so you don't need to worry about your program loading libraries it does not actually use.
If your actual worry is that your users need to install the complete .NET framework, you could have a look at the .NET Framework Client Profile. That is a smaller installer and does not install the complete framework.
When you install the .net framework it includes all the required libraries. .net libraries that you reference in your program are not included with it when you distribute it.
Your application does not include the entire .NET Framework. This is why users are required to install the .NET Framework before they c an run your application.
I think you are asking if you can write a program that will run on a machine without the .Net framework installed? And then to only include the dll files that are needed for that specific application.
I think that the .Net framework must be installed on the machine as the .exe you compile using the CLR's compiler automatically checks that the framework is installed when you execute it.
Even the smallest .exe you create will be in a PE32 format, and the ones emitted by csc.exe contain a sort of bootstrap at the top that kicks off the CLR's Just in Time compilation etc.
So you need to have the framework installed for this functionality regardless of what libraries you call.
This is as I understand it.
For what you want to do you probably need to write non-managed or unsafe code using c++ and calling Win32 DLL's directly.
Create a setup project that installs the required .NET Framework when they install your application.

How to prompt to install .NET Framework when deploying a WPF Browser Application?

Is there any way to make a WPF Browser Application prompt to install .NET Framework with ClickOnce like a regular installable WPF Application?.
Those publishing options are locked when the HostInBrowser property in the project file is set to True, which is necessary for the application i'm developing, however i need to make the installation of dependencies user friendly, and possibly from the .net framework installer already hosted in my server, as it would cut down greatly the use of bandwidth.
The program is intended to be used in intranet, as a "web page", by placing shortcuts on the desktop of each computer (which is done at the first run of the app), but most of the users don't have .NET Framework 4 installed.
is there any way to accomplish this without converting it to an installable wpf application?
Thanks in advance, Jesús.
No ClickOnce requires the .Net framework, because it's a component of it.
All ClickOnce applications require that the correct version of the .NET
Framework is installed on a computer before they can be run
You can however set a prerequisite which is a higher version of the framework, provided they have at least version 2.0 to begin with.
Commonly a bootstrapper written in managed code is used to overcome this limitation. You could use MSBuild for this, dotNetInstaller, or other third party tools. I've used dotNetInstaller a few times a recommend it, it's very flexible.

deploy application without the .NET

I have to give my customer my application. It's a simple application(3Mo).
I think it's really unnecessary to oblige my client to install the whole .NET framework (the 3.5) to work with a simple application (3 mo). I mean I'm sure that there is a way to avoid that, just include some dlls or something like that.
Well I have the dll in my project reference(LINQ dll, core Dll, system Dll, winfom Dll, office Dll and some other)
is it possible to give the application with those dll and that way I avoid installing the whole .NET framework?
Well I don't even need to make an MSI or setup project,
just give him the exe generated with Visual Studio and that's it.
I'm using VS 2010, C#, 3.5.NET
It's worth noting that Windows comes with various flavours of .Net installed depending on the version of Windows. If I remember correctly...
Win7 comes with .NET 3.5 SP1
Vista comes with .NET 3.5
XP SP2 includes .NET 2
Depending on your target audience you might find that this is good enough!
If these conditions are true:
a) you really want to avoid .NET framework dependency
b) it's a really easy/small application
Consider the option of porting it to c++
If not
use default framework (.NET 2, or 3.5 or 3.5SP1) that comes by default in windows as Dan Puzey said.
No it is not possible. Client has to install .NET Framework 3.5 (with SP1) redistributable package.
Edit: If you didn't want client dependency on .NET Framework you should choose another application type: Web application where .NET dependency is only on the server.
Most people have some flavor of .NET installed although most don't yet have 3.5. But you can create an installer that will download an install transparently to the user. Also if you target the Client Profile this dependency will be smaller.
Your client should have .net, there's no reason not to and if they haven't, they are a fool. Running XP with less than Service Pack 2 is dangerous. For the non-technically-inclined, compare it to using a van that's been subject to a manufacturer's recall. It may not necessarily be faulty, but the manufacturer has told you that it's no longer fit for use and are willing to make good at their own expense. As a responsible business owner, you wouldn't shirk that responsibility. In a similar vein, maintaining your Windows installation to the manufacturer's recommendation is not optional.
Have you considered making it a web app, with asp.net? The effort of porting should be less than a complete rewrite (depends on the applications functionality).

Categories