Silverlight, WPF or Windows Forms? - wpf

I need to create a desktop application for Windows and I'm in doubt about which technology to choose. Fact is that the application must do interaction with local resources:
Communication with SQL (need support for SQLite and MSSQL - local and remote, and would love to use NHibernate; maybe even with Castle's ActiveRecord)
Interaction with equipment connected via Bluetooth, Ethernet, USB and Serial (COM) port. I need to read a byte stream from sensors that connect via different protocols.
Preferably I'd go for Silverlight 4, and allow the application to run on the desktop with Full Trust. But I foresee problems with regards to these two requirements. Is there any solution for SL4, and if not, what alternative should I choose? I'm not limited to WPF or WinForms, but since it should run on .NET, I'm more or less limited to these 3 options (or am I?)

With a Silverlight app, you won't be able to connect to a SQL source without creating a service + you won't easily (or at all?) have access to the local resources such as COM port. If your app is intranet based, I'd go for WPF and click once deployment.

After you understand how to use WPF/Sliverlight controls, templates and data binding you will never want to touch WinForms again - it's not only that WPF/SL gives you a richer UI possibilities they just make it easier and less error prone to create applications (especially data-binding).
And it looks like you need relatively low level hardware access, even if it's possible with SL it will be easier with full .net
So, I would choose WPF
Just remember WPF/SL have a learning curve, if you never built a WPF project budget some time to learn the platform.

WPF would be your weapon of choice.
API-wise, WPF basically is a superset of Silverlight. Moreover you are in full control and have complete access to local resources.
If you are into .NET 4.0, you would probably enjoy Entity Framework, as an alternative to NHibernate. Not that it exceeds NHibernate in any way, but it integrates beautifully and comes with the package.
But, as Nir also stated, there's a learning curve for WPF.

Related

Silverlight OOB vs WPF ClickOnce

Silverlight Out of Browser technology and WPF ClickOnce on the surface have similarities. Easy and simple deployment, the ability to specify the level of trust access to the underlying host, etc.
What are the key issues I need to consider when choosing one over the other?
To put a finer point on it, I'll be deploying LOB apps on a corporate network running only windows computers.
The big one is cross platform compatibility. If you need you app to run on a mac as well as windows (not sure if Silverlight is supported in Linux yet) then use Silverligt. If you want to make an assumption that all your users will be in a windows machine then go WPF.
Obviously WPF has a much richer toolkit than silverlight so it may well be that silverlight just isn't an option. If I was just building for windows though I know my job would be easier in WPF.
Given that you are targetting a private infrastructure running Windows, two points worth thinking about
Wpf has a richer control tree, whereas Silverlight is a reduced set for compact size
Wpf requires .Net framework installed locally, whereas Silverlight has its own platform independent browser-based runtime
While your target platform will likely have the latest .Net framework installed, rendering this last point moot, keep in mind any updates to the framework [ie .Net4.0 and any future updates] may require a restart of the machine - which is a major pain point for businesses that demand constant-on stateful desktops [ie anything in finance, like banks and trading].
As with all problems, your requirements, not the technology, should inform your solution. :)
You mentioned trust access to the host which I think rules out Silverlight unless you want to run SL4 (beta).
We recently went through a lot of discussion about file system access. Silverlight 3 runs in a partial trust sandbox more or less. You can't maintain a pointer to files in the files system outside of your application's isolated storage. This was an issue for us as we wanted the user to be able to use the application to reference odds and ends on your file system. That said you can allow the users to load and save files from anywhere on the system but you just get/or push the file stream and (to the best of my knowledge) don't have access to the folder or file path information.
Silverlight 4 (in beta) has support for your application running in full trust mode. I haven't played with this yet however and can't speak to how well it works.
In talking with a lot of people who work with both Silverlight and WPF, even those who are excited about Silverlight and push for it strongly, I hear a lot of the say fairly emphatically that if you are going to be developing exclusively for a full-trust Windows environment, WPF is hands-down the obvious choice.
That's not to say that Silverlight is an inferior product or that there aren't times will Silverlight will be the clear winner. But when you say "I'll be deploying LOB apps on a corporate network running only windows computers," it sounds like WPF is the clear winnder.
You could decide to go down the Silverlight route in anticipation of all of the great new OOB feature os SL4. I've even heard rumors that SL and WPF will eventually merge, so it may not even really matter, right? Well, I think what you'll find if you go with Silverlight is that some of the advanced features that you thought were there weren't there in the way you expected. For example, SL4 will be able to run in "Elevated Trust" (not full trust) and you might find this limiting at a frustrating point in the project where a lot of your code base is already in Silverlight.
Certainly keep your eyes on Silverlight, but for your current business case, WPF will likely be the best fit.

Winforms or Silverlight

I have a small project that I will be working on shortly that collects employees time and what project the person was working on. Pretty straight forward. I was orginally going to work on it in WinForms but since im new to that I though maybe using Silverlight for the application since I will have a learning curve for each. Here is a couple of business requirements that i need to incorporate into the application.
-System will use an Access database hosted on a particular persons computer.
-Ability to generate and print reports
-Installed on the emploees desktop who will have access.
Would one technology be recommended over the other in terms of what I need to do. Here is a screen mockup of one of the pages I will need to create.
http://teewebco.com/images/main-copy.png
If you want access to the machine on which the application will run (e.g. to access a database, and to use printing), that pretty much rules out Silverlight, without jumping through a lot of hoops (e.g. having to install something on the user's machine anyway).
You say that WinForms will require a learning curve for you - well you might as well use WPF then, as it's a similar technology from the UI perspective as Silverlight. However, you can proably find a lot more resources online for WinForms though, and it's likely you'd be more productive in WinForms given its strong Visual Studio designer support.
Deployment with WinForms or WPF should be fairly easy with ClickOnce.
Since it's a local (desktop) app which needs to access a local resource (Access database), it's probably better to do winforms.
However, you might be better off doing this as WPF instead - it's more current than winforms.
Winforms and WPF are easier than Silverlight when you have to access a database because you can do it directly. If your install base uses only .net 2.0 then stick with WinForms, if you know they can install .NET 3.5 then try out WPF. Just be warned, there is more to learn with WPF and XAML but it's very rewarding especially if you want to get fancy.
Silverlight 3 lets your application to run on desktop as well.
So I'd write it on silverlight. Yet another technology to master.

Are ActiveX applets dead?

Are ActiveX applets as a technology supported by Microsoft dead?
What are the alternatives to ActiveX to create extremely rich internet applications using Microsoft Technologies? (Silverlight does not cut it for me, as it doesnt give me access to serial ports - or does it?)
You can of course still make ActiveX applications, but know that they will only work with Internet Explorer, unless users of other browsers install hosting plugins, that aren't all that good anyway.
In either case, a web application that requires access to a serial port? Are you sure you're not better off with a desktop application instead? A simple refresh and you've cut off that serial port.
Not all applications belong in the browser.
If you want to launch an application via a web browser that can access the serial ports, one option would be to use Java Web Start with JavaFX as the rich interface API, and Java Communications for the serial port access. You could end up with a cross-platform application at the end as well.
Or just write a native application using your favoured Windows toolkit if you absolutely are restricted to using Microsoft tools.
ActiveX as technology is very much alive, and will remain for many years to come. But its usage for Internet is dead. ActiveX is to be only used from within windows stand-alone applications.
ActiveX as of 2015 is a dead technology that even the maker is no longer interested in continuing to use it. Here is something to read.
No, Silverlight is designed from the ground up to be completely sandboxed, no way to bypasss that (thank god).
If you need that kind of access, but are looking for an easy deployment, I would suggest building a Clickonce application.
There are restrictions, because I think by default they are not full trust, but that's the best you will get.
It's also going to be the only easy route if you need printing (unless you are willing to round-trip to a server to generate a PDF file).
If you need direct access to some hardware (like for a POS software with cash drawer, receipt printer etc), you need to go "desktop". Clickonce can give you some deployment options, XBAPs can give you the "browser experience", but you are going to have to make compromises based on what your "hardware access needs" are.
EDIT:
I didn't notice the Silverlight exclusion in the original question. My comment it not really applicable. Sorry!
I don't know that I would call ActiveX dead just yet, but I would be cautious if you are planning to build an application based upon this technology. My recommendation would be to use Silverlight. This provides much of the functionality that is commonly desired in ActiveX controls, but uses the newer .NET technologies.
There is alot of talk about using Silverlight for media playback, but it has many powerful feature that can also be used to create Line-of-Business applications as well. In fact there is a great podcast episode on DotNetRocks that discusses this exact subject.
Here are a few more links that might point you in the right direction:
Microsoft Silverlight Getting Started
Silverlight 2 and a Glimpse of Silverlight 3 by Scott Guthrie
To the best of my knowledge, Silverlight 4 still doesn't give you direct access to serial ports, but it does give you access to any local web cam and microphones now. You could presumably also run Silverlight 4 out-of-browser, which gives you access to COM objects, and you could write a quick-and-dirty COM object which wrapped serial port access. That said, I also agree with what folks said above about not all applications belonging in the browser.

WPF vs Silverlight 3.0

Silverlight 3.0 beta has just been announced at Microsofts Mix Conference in Las Vegas.
Two features of the new beta are 3D-graphics and the ability to run applications outside of the browser, which to me seemed to be two of the major features that WPF (Windows Presentation Foundation) previously offered over silverlight.
I am currently evaluating WPF and Silverlight for possible use in our companies future development activity, and this announcement has left me confused as to the intended direction of these two UI technologies and why I would choose one over the other.
Has anyone implemented a new application using WPF recently, and if so, what drove you to that decision? Given the announced changes to silverlight, Would your decision have changed had you made it now, and if not, why?
Any advice would be appreciated.
The biggest difference I find is the asynchronous model you have to adopt
in your Silverlight application.
It does seems like an advantage (and it can be), but it does make
life very difficult sometimes.
There are also some limitations that can be a real challenge like the absence
of print support.
I would recommend Silverlight over WPF when:
- There is no need for best possible performance (graphics included)
- Can get around the absence of print support (it will come, we just don't know when)
- Camera/Microphone support is not needed
- Can tolerate the assync app/development model
- Can tolerate limitations on WCF (no support for WS-Security at this point)
- There is no need to store huge amount of data on the client.
- There is no need to direct integration with client side applications like Office.
- Has a server to host your application
I would say the main difference is that WPF requires the client to have the .Net 3.0+ framework. Silverlight only requires the runtime. Now that being said, WPF is geared more for controlled environments such as an intranet. Silverlight is meant for the public web. Another difference is that Silverlight is cross platform (Windows, Mac, Linux in the future & Cross browser). WPF is meant for Windows only.
The .Net framework can be a huge download for some users. Silverlight is only 4-5MBs. This is a big difference to run your app on the web, but not a big issue if its an internal application at your company.
Silverlight is Sandboxed which is meant for web use. So if your app requires more permissions you will need WPF.
There are also some differences between Silverlight code and WPF. But from what I've heard, the ultimate goal is to get a Silverlight to run inside of WPF with minimal code changes. But they aren't there just yet.
I have just worked on a WPF project that in hindsight we feel we might have chosen SilverLight for. It is probably more important to know the differences and select the one that is most appropriate for what you're doing.
Here's my starter for ten on some of the important differences - there were originally some differences in the available controls, but that has largely been smoothed out now.
Silverlight
Runs entirely on the client with AJAX
calls to the server for data
Can run on any server, including Windows and Linux / Apache
Uses COMPACT .NET framework
WPF
Runs on the client... usually calls services for data
Runs on Windows XP / Vista with .NET 3.5
Utilises the entire .NET framework
Silverlight is basically a stripped down version of WPF in order to make the runtime libary download as small as possible.
As a result, WPF simply has a lot more functionality available in it and tasks that are simple in WPF often become not so simple in Silverlight.
If running as a web app is not a requirement then the decision is a no-brainer - WPF all the way.
Has anyone implemented a new application using WPF recently, and if so, what drove you to that decision: Well since WPF was desktop only (or browser based using XBAPS - but that was more a deployment system than a real system) that was a good reason to it.
"Would your decision have changed had you made it now, and if not, why?" - No Silverlight, even on the desktop in v3, is still highly sandboxed and so certain functions are going to be hard/impossible to do due to the sandbox. Also the ability to use DirectX parts in WPF will still give another optimisation area which Silverlight and it's 3d won't be able to use.
It's worth noting that Silverlight's 3D is not the full 3D support of WPF, but only projection of 2D into 3D - i.e. take the 2D plane and allow rotation in X, Y & Z directions. WPF has full 3D modelling with materials, view ports, lighting and camera positional support etc.
I'm well along in the development of our first WPF app for release. Silverlight 3 looks great, but for this application I would still have chosen WPF. The application centers around presenting and manipulating very large sets of images hosted on a central server on our clients' networks. Additionally, the software update/change rate will be minimal. Mass import of new images from a local drive, no Internet connectivity requirements, performance concerns, etc. make this a project well suited for WPF.
One of our upcoming projects, however, will require many remote users to access a single data store on our network. The data they work with requires significant validation and error handling, so running that code locally is ideal. They will need the ability to work both on and offline and remain in synch (probably with SQL Data Services). SLOOB (Silverlight Out Of the Browser) will most likely be our choice for that one so they can have all the Silverlight advantages but use it like a regularly installed application, even without an Internet connection.
Both formats have their place: the trick will be to avoid using Silverlight for everything - we have more tools than just 1 hammer. :-)
Another difference is that with SL you only have one 'window', you can't have dialogs (they can be simulated but their size is limited to the main window) and you can't add multi monitor support.
If you have to interact with existing business applications (e.g. open a document in the archive viewer) you need to use WPF.
I recently have built several internal tool using wpf, and I chose it simply because It was easier for me coming from win32 work. I don't really think that the differences are major, and really... everything i have seen/heard indicates that porting between wpf and silverlight is quite easy.
Storage: You only have 25MB of isolated storage out-of-browser. If I remember correctly from some mix09 video, this limit is lower if your app is in-browser.
http://bliny.net/blog/post/Out-of-Browser-with-Silverlight-3.aspx
No FlowDocument: So there are limitations there too.

Can i host WPF Controls in ASP.net 2.0 or sharepoint?

This may seem like a high-level question. But that is because I'm unfamiliar with cutting edge ASP.net and even less with this behemoth called Sharepoint. So please bear with me..
First off is it possible to take functional custom WPF controls which contain certain unmanaged subcomponents that do DirectX rendering (for performance reasons) and drop it into ASP.Net? as an example consider a specialized chart control
Does Sharepoint add anything that makes this possible ?
The use-case is to take certain panes or areas from a thick WPF client and slot it into an existing Sharepoint based solution.
Is this possible or are they (WPF Controls and Web Controls) as different as chalk and cheese? (Assume that the current control interface can be freely changed.) Would it wise to develop web-aware stripped down version of these controls than to attempt to hammer the current controls in somehow...
On a fundamental level, can a web-page contain a control which takes over the rendering for its client-area/rectange ? Or does everything have to broken down into plain html by the time it hits the browser.
I found a few unanswered queries online. But other than that its unexplored (or forbidden).. in either case I'd like to know. Thanks for reading..
The short answer is: Yes it's possible but you probably don't want to do it.
Asp.Net, with the exception of java script, is primarily a server side technology. Meaning that the majority of the processing code runs on the server vs. the client. IIRC share point is built on top of Asp.Net and thus has the same format.
WPF is a client side technology. The code runs on the actual physical client computer.
Combining these two technologies into one application does not work due to their conflicting natures. However, there are several options for you.
Silverlight: It's easiest to think of this as flash for .Net. It allows for rich WPF applications to be run via a web browser on client machines. It's a subset of the full .Net framework but rich enough to build great applications.Silverlight is limited in that it must be a 100% managed solution. You're post mentions using a DirectX control which I presume is native code. If this is the case Silverlight will not work for you
ActiveX controls: These allow for essentially any form of client code to be hosted in a web browser and run on the client machine. This includes .Net, WPF, C++, etc ... If you have a native component this is really your only option.Unfortunately though, ActiveX controls are following out of favor. Primarily due to their insecure nature. Once you run an ActiveX control on your machine you're at the mercy of the control author and it's easy to do malicious acts.More data on ActiveX controls: http://en.wikipedia.org/wiki/ActiveX

Resources