WPF one executable file from project - wpf

I have a WPF project with one external library. Is it possible to make one executable file "*.exe" from this project to run on windows systems even without .net? and how to insert that library into .exe file?

You will need to have the .net framework installed on the clients pc. What this says is that since .Net has been preinstalled on Windows since XP SP1, you should target your application to the runtime that is available on the system you wish to install it on. And since you are targeting WPF you will need to make sure that you have available .net 3.5 or greater. You may want to look into the Client installation of the framework since it is smaller. And you may want to look at this Stackoverflow question
i.e. from above link
Windows .Net Framework
Win 7 SP1 4
win 7 3.5.1 ( can be updated to .Net Framework 4 through windows updates )
windows vista 3.0 ( can be updated to .Net Framework 4 through windows updates )
windows XP Sp 1 2.0

You must have .net installed to use a wpf application. You can use clickonce to make the install experience more friendly to the user, if he doesn't the right version of the .net framework installed.
As for the external third party library, see my answer here for the same issue.

Related

Building Windows Presentation Form for multiple versions of .net

I am building a windows presentation form application. The issue I have is that my co-workers have different versions of .net installed on the desktops. If I build it on my machine which has .net version which is 4.6. When another person has a lower version of .net it fails. I can build the application multiple time with different version of .net but I would like to avoid that. So is there a way in Visual Studio to build a WPF that will work on multiple platforms and versions of .net?
You can change your target framework in the project properties (right click the project and select Properties):
Because higher .NET versions are backwards compatible with earlier versions, you can target a lower version that what is on your machine, though it means that you lose out on the newer apis.
So, for example, if you and your colleagues decide that .NET 4.0 is a good target, then having .NET 4.5 or .NET 4.0 will work for building and running the application.
For more information on Framework Targets, see:
What does it really mean to target a framework, and how do I maximize compatibility?
What is the effect of setting a “Target framework” in Visual Studio

visual studio 2012 .net 4 created application requires .net 45

I have created a WPF application, using Visual Studio 2012 running on Windows 8 that targets .NET 4. But, when I try to run the app on another machine, that runs Windows 7, the app cannot starts. The target machine has installed .NET 4, but the app cannot run on it. But when I install the .NET 4.5 on target machine, it works. I check the entire solution, and there is not any dependency to .NET 4.5. How is it possible? Any idea?
UPDATE: I'm using these packages:
Autofac.3.0.2
Autofac.WebApi.3.0.2
Caliburn.Micro.1.5.1
Caliburn.Micro.Autofac.1.5.0
EntityFramework.6.0.0-alpha3
gong-wpf-dragdrop.0.1.3.8
Microsoft.AspNet.WebApi.Client.4.0.30506.0
Microsoft.AspNet.WebApi.Core.4.0.20710.0
Microsoft.AspNet.WebApi.SelfHost.4.0.20918.0
Microsoft.Net.Http.2.0.20710.0
Newtonsoft.Json.5.0.6
System.Windows.Interactivity.WPF.2.0.20525
While all of them are targeting to .NET 4 in package.config file, is it any chance that one of them are using some .NET 4.5 features?
Please ensure that no reference assembly is targeted to or code contains references to 4.5 framework. Then it should works
Finally, I found the problem. I was compiling the project by (Any CPU) configuration. When I changed it to x86, the problem resolved.

Is prism using legacy code?

We are using prism for developing WPF applications. The newest(4.1) version supports only windows 7 and windows server 2008 as per the following link
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=28950
This begs a question. As far as I know specific operating system support is only required for assemblies with legacy code. If the assembly is completely written in .NET it just need the .NET frame work support as this itself is a "virtual machine".
If this is true is prism contains legacy code?
The Prism 4.1 Deveoper's Guide provided here says the following:
This guidance was designed to run on the Microsoft Windows 7, Windows Vista, or Windows Server 2008 operating system. This version has been smoke tested on Windows XP Professional and Windows Server 2003, but it has not been exhaustively tested. WPF applications built using this guidance require the .NET Framework 4.0 and Silverlight applications require Silverlight 5.
All this means is that they haven't tested it on XP, but you needed XP SP 3 and above for the last release (the minimum for .NET 4.0), so my guess is it will likely work for new projects.
No need to panic.

What package of .Net framework is required on target client machine in order to run .Net winforms application?

I'm Trying to deploy my winforms project using installshield in order to make is available to be installed on other computers. My project is written under .net framework 3.5.
My question is : What version of .net package should be installed on the target machine in order to be able to run my project?
One thing to notice is that target machine is not connected to internet so I have to embed a standalone offline installer for .net framework.
Surely, with .Net framework 3.5 full redistributable package installed, my project runs fine. But it's ~200MB. Should I really install 200MB in order to run my ~10MB project on target machine?
one other option would be installing client redistributable package which I heard ~30MB. But I couldn't find any official release and am not sure if that's gonna work.
Any help would be appreciated.
You should deploy with the web installer so that it can determine what your client needs and download only those components. The full install is that big because it contains all variants of the framework for all possible systems (x86, x64, etc.).
This site from Scott Hanselman is an excellent resource on the matter of deploying .NET.
http://www.hanselman.com/smallestdotnet/
As it states on that site:
If you look for .NET Downloads on
Microsoft's site, it might look like
the .NET Framework is 200+ megs. It's
not. Those big downloads are the
Complete Offline Versions of every
version of the .NET Framework for
every kind of machine possible. The
big .NET download includes x86, x64,
and ia64. It includes .NET 2.0, 3.0,
and 3.5 code for all systems all in
one super-archive.

How can I inform the user of an XCOPY WPF 4 app that he needs to install .NET 4?

I've made a small tool application with Visual Studio 2010 which to distribute it, I zip these files from the Release folder:
Data
MainData.mdf
MainData_log.ldf
DataBackup.exe
DataBackup.exe.config
FluidKit.dll
then unzip them on the target machine (no installation).
When I run it on a Windows 7 machine with .NET 4 installed, it runs fine.
When I run it on a Vista machine with .NET 3.5 installed, it gives me this default error message:
In order to run this appication, you
need to install the following version
of .NET: v.4.0.21006 To learn how to
install this version, contact the
distributor of this application.
When I run it on an XP machine with .NET 3.0 installed, it gives me an error that doesn't that the application cannot start but doesn't mention installing .NET.
Is there anyway that I can intercept these messages to e.g. give a nice-looking, custom message with install instructions and a link to the .NET 4 download?
I think that the only solution is to make a small non-.NET application that checks if the .NET Framework is installed, and if so, launches your .NET application. For the framework detection part, see for example here: http://www.codeproject.com/KB/dotnet/DetectDotNet.aspx
Check out the Application.DispatcherUnhandledException Event... maybe you could globally catch the exception and inform your user in there about having to install .NET 4.0. Probably this can help you determine what .NET platform versions are installed, and maybe even avoid using the .NET 4 features if you see that the client machine does not have it.

Resources