C# Portable Application vs .NET - c#

I've a Win32 application written in C# via Visual Studio 2015 and I want to make it portable in order to avoid the installation of .NET framework everytime I deploy my application to clients.
I read this article: the key point of making portable apps seems the use of mscorlib.dll
This method doesn't work, at least for me, despite my effort. I must presume this is not the real way to build an application as portable...?
What are my other options in Visual Studio? Should I rethink my entire application to avoid the use of NET?

Portable applications and packages still require .NET, but in a way you are not using the entire subset available in .NET, which makes it portable among different platforms (Windows Phone, Universal Apps, etc.).
As far as I know the only option you have to overcome the dependency on the .NET Framework, is by compiling your assembly in 'native', which will include all code necessary to run the app on its own.

Related

UWP - Use assembly targeting .NET Framework 4.6

I want to use a .NET Framework assembly in UWP (side loaded app). I know that it's not possible in any easy way, since UWP is targeting .NET Core.
I'm trying to create a Brokered Windows Runtime Component as explained in this article.
However I have issues:
I can't use any templates from the market, because they are for Visual Studio 2015 and I'm using Visual Studio 2017
I can't open the sample projects, because Visual Studio 2017 says that the projects (those with edited csproj files) are not compatible with that version of Visual Studio 2017
The post-build script from that article uses winmdidl however it's not in my PATH so I have to put the full path "C:\Program Files (x86)\Windows Kits\10\bin\x86\winmdidl" (don't know if that's an issue)
The winmdidl command returns an error error W1005: Exception Unknown exception
Additionally I have two questions:
The samples and article uses a C++ "Proxy" project, can I just write the logic in C# in the brokered component without using any C++ code? (I just need to be able to call some methods from UWP which are defined in a 3rd party .NET assembly)
Since the "Brokered Windows Runtime Component" method to call some code in .NET Framework seems cumbersome, maybe it's better to write some Windows Service or some other form of a REST service and communicate with it through localhost? That's a way I already use to communicate with some 3rd party tools on the machine. Is the performance and complexity in favor of the brokered component approach?
With Desktop Bridge features you not longer need the Windows Runtime Brokered Components. See this page for more information:
https://developer.microsoft.com/en-us/windows/bridges/desktop
I guess this sample using the AppService will help you to solve your scenario

Possible to create an application c# with no framework

for strict constrains in my scenarios, I have very few room to install my application, and .net framework is not installable (any version).
If the application is really simple (more or less), it is possible to create an application in visual studio (in c#) with no dependendency from the .net framework?
Thanks!
Short answer: NO.
There is no way to create a .NET application without any framework.
It is possible to compile a C# app such that it has no dependencies on any of the built-in .NET types & libraries, by using the /nostdlib switch (see http://msdn.microsoft.com/en-us/library/fa13yay7.aspx). You then need to supply your own System namespace.
However, this doesn't remove the need for the .NET framework on the target machine if you use the standard C# compiler. As well as containing the built-in types, the framework also includes the JIT IL compiler, the CLR extra, which all .NET executables and dll's are reliant on.
There are ways of compiling C# code such that it doesn't need the framework though. The Xamarin product for example (http://xamarin.com/), supports compiling C# code to native iOS apps, which are wholely independent of the .NET framework. I'm not aware of any equivalent for "desktop" OS's though.
Writing, compiling and running a C# program without .Net means running a special C# compiler that produces native code instead of managed code. I think such a compiler exists from WinRT for mobile phones, which uses COM instead of .Net (And C++/CX instead of C++/CLI). Code it produces does not depend on the .Net Framework, but does depend on the WinRT runtime.
You may create mono GTK# application and then use mkbundle to generate independent executable. You can use Visual Studio to build your logic and use Xamarin studio to build GTK# GUI. For more information about mkbundle see this and this.
To reply to your query. It really is not possible to create a .Net application without the .Net frame work. And moreover if you have installed Visual Studio by default it would have asked you to install .Net framework or would have installed it by default. In that scenario there is already .Net framework installed in your PC.
Thanks

Install C# application on user system with system libraries

I have created a C# 2010 application and now when I install it on user application it asks for complete dot net framework. Is it possible if I can only put required dll files with my application instead of installing complete dot net framework on user machine ?
No it is not possible
The .NET framework is more than just assembly to copy on the target computer. It is a more complex infrastructure that interact with the OS when an executable is loaded and, if it contains IL instruction, it compile it just in time in order to have it running. So non chanches in order to me to have it working without a .NET framework setup, that can be done in a separate step, or by creating a Setup for your app with the proper framework version indicated as a prerequisite.
An overview of the framework can be found here, but many more others are available in the net, you should read it to understand why is not a just matter of functions you need or not.
You may choose to target .NET Framework Client Profile. That would decrease download size of .NET files. See this link for more details on subject: http://msdn.microsoft.com/en-us/library/cc656912.aspx#targeting_the_net_framework_client_profile
No, this is not possible. In order to install and run an application targeting the .NET Framework, the user must have the appropriate version of the .NET Framework installed on his/her computer.
If you want to make things easier, you should distribute your application with a setup program that ensures the .NET Framework is automatically installed along with your app. There's no reason the user should have to download and install the .NET Framework themselves. You can even create a setup program right from Visual Studio, so there's no excuse not to use one. It also makes managing dependencies and versioning conflicts much easier.
If you're really worried about the size of your dependencies and are targeting .NET 4.0, you can require only the Client Profile, which is a subset of the .NET Framework optimized for client applications. You'll have to set your project's Properties to target the .NET 4.0 Client Profile, and ensure that you're not using any of the assemblies it omits.
I hardly recommend wasting too much time on this, though. At last count, the Client Profile was only about 15–16% smaller than the full version—not an amount that makes much difference on the fast Internet connections found in most parts of the world today. And even less of a problem if you distribute on real media.
If you're absolutely dead-set on delivering an application without any dependencies (as comments to other answers suggest), you've got a hard road ahead of you. For starters, you'll need to drop .NET and C# entirely, and switch instead to an unmanaged language like C or C++. That's a very different programming environment than C#. Even if you're the best C# programmer in the world, there's going to be a significant learning curve to pick up C++.
And that still doesn't solve all of your problems. C++ applications compiled using a modern version of Visual Studio will still require that the appropriate version of the C Runtime Library be installed on the user's machine. This is, of course, a much smaller package than the entire .NET Framework, but you can't count on it always being there, so you'll need to install it along with your application.
Moreover, unlike the .NET Framework (which has WinForms, WPF, Silverlight, etc.) there is no GUI library bundled with C++. And if you choose any GUI library other than the native platform API (for example, Qt, which is quite popular for reasons that I still find inexplicable), that gives you an additional dependency. You mention Google's applications a couple of times as a model. Google Chrome targets the Win32 API directly and has written a bunch of their own code to draw their custom GUI on top of that base framework. That's really the only way you're going to eliminate dependencies entirely. And delay your app to market for a significant period of time.

Installation C# application without dot net framework

I have created a new application on C# 2010. After creating a Setup file I came to know that for installation purposes user must have a dot net framework. Is there any way I can get rid of installing dot net framework on a user computer. Each time I try to install my application on the user computer it redirects to install the dot net framework. Any suggestion?
Well that's a problem; because of the design of .NET applications.
Here's some references for you:
Visual C#
"C# (pronounced "C sharp") is a programming language that is designed for building a variety of applications that run on the .NET Framework." [first sentence]
Intro to C# and .NET
As the comments on the question attempt to imply, the .NET Framework is required in order to execute .NET applications.
You have two choices, really:
Require that users have the .NET Framework installed. This is the most common choice, for reasons that will become clear in a moment. It's not unheard-of to have such requirements. It's similar to requiring that a user have Windows installed in order to run your Windows application.
Distribute the .NET Framework with your application installer. This is possible, but less often used because the .NET Framework is large compared to the average application. However, if you must do this, then the option is at least available. Some quick Googling brought me to this helpful blog post.
This isn't possible. C# is built on the .NET framework, so any C# app requires that a version of .NET be available. At http://en.wikipedia.org/wiki/.NET_Framework#History, you can see what .NET framework versions are available in various versions of Windows. The short story is that XP doesn't include anything, Vista includes 3.0, and Windows 7 includes 3.5. If you build for one of these versions, then on those OSes, your users won't need to install anything extra. Using the Client Profile instead of the full .NET can also help reduce or eliminate installs your users will need to do.
Unfortunately No. Its not possible.
To explain it simple terms.
Suppose if you have written only 1 Line of code where you would have simply declared an int variable, who will tell OS that it should create a space in memory?
That framework does exactly that creates basic environment to run your app in a System.
OOPs says about Real-world modeling and Relationships, so let me give you one from it.
Think yourself to be the C# app and Mother Nature/Environment(Greenry) to be .Net Environment.(.Net is called an Environment)
Can you survive without mother nature? From first second that you are in this world, you breathe. Who provides you that oxygen. MOTHER NATURE
While creating installation bundle you can add dot net frame work exe file as prerequisites, then while installing your application it can check whether the system having .net framework or not. if it is not installed it your application can install the frame work.
When you are using managed languages to writing applications you agreed to use their vm, c# codes compiles to IL which needs dot net framework for executing.
.net framework by default exists on windows 7,8,8.1 and 10 and I don't think that this is a challenge.
but if you insist on it so there is a way by using Mono, just remove features that does not support in mono from your project.
first install mono and cygwin, then copy your exe and mono.dll file to a folder, be sure that your file name is not long because in some cases bundling faild,now you can start bundling using mkbundle command.
after bundling finished you have a exe file that can run without .net framework
hope this help you
I have the same issue and want the app to setup using the existing dot net framework version (4.6), because the app setup requires 4.7.2 version that the PC doesn't meet the requirements

Can c# compiled app run on machine where .net is not installed?

I want to develop a small utility for windows and I prefer doing that in c# because it is easier (I'm a java developer).
The utility will be available for download by many people and I assume some of them will not have the .net framework installed (is this assumption correct, say I target win xp and above?)
My question is: can a c# application be compiled in a way that it will not require the .net framework installed?
Normally, you will need the .NET Framework being installed on the target system. There is no simple way around that.
However, certain third-party tools such as Xenocode or Salamander allow you to create stand-alone applications. See this related question:
Is there some way to compile a .NET application to native code?
As these solutions are not straight-forward and require commercial products I would recommend you to create a simple Visual Studio Setup and Deployment project. In the properties of the project you should include the .NET Framework as a pre-requisite. The setup.exe created will then automatically download and install the .NET Framework prior to installing your application.
No, it will need the .Net framework installed. Note though that you will need only the redistributable version, not the SDK.
A minor aside - but in this scenario, consider developing the utility in Silverlight - it has a much smaller footprint and is supported on a number of operating systems. This might allow you to get the coverage including people who don't already have .NET.
If you need "normal" .NET, then "Client Profile" is perhaps an option.
You can probably also include the .net framework installer in your application.
In a related question, Can you compile C# without using the .Net framework?, it's mentioned you could do this using mkbundle from mono. I haven't tried it myself so I can't comment on if it's the way you should go, but you may want to consider it.

Categories

Resources