logo

Sometimes You Have to Go Native

Learning to create web applications using ASP.NET (MVC) with C# in Visual Studio and with Entity Framework has had a beneficial side effect, which I hadn't realised until this last week -- I can now easily write "native" Windows apps too!

Until now I've been using Visual Web Developer 2010 Express, which only lets you create web applications. But, I have recently downloaded Visual C# Express 2010 Express with which you can create Windows Forms applications.

Windows Forms apps run on top of the .NET Framework. Like Java apps which run on top of the JRE. But Windows Forms apps look just like you'd expect a Windows app to. You know the kind of thing - something simple like this:

What surprised me was how easy it is to create a Windows app using the knowledge I've picked up while making Web apps in ASP.NET. Lots of what you use is the same. There's C# for starters, then there's the Entity Framework concept of data access, app.config and settings files. In short the IDE is just the same. You just have a different target.

When downloading Visual C# Express you get the option to download SQL Server CE (compact edition). This lets you use a lightweight (distributable) database with your apps (a bit like using SQLite with Adobe AIR).

When you package the app you've made you can tell the installer that it needs SQL Server CE and it will download it via the web when your users run your "setup.exe" for the first time (assuming they don't have it already). Same goes for the .NET framework itself. Your install files are generally a few hundred Kb in size.

All in all it's a surprisingly straight-forward and hassle-free process making, packaging and distributing a database-drive Windows application. I've been pleasantly surprised. There's no need to be scared of the prospect of going "native".

Why Am I Writing Windows Apps In This Day and Age?

Writing a Windows app!? Yeah, I know. But there's good reason.

I like to think of myself a "go to" person. Come to me with any IT-related requirement and I'll do whatever it takes to meet those requirements using the best-suited solution.

When a customer comes to me with a requirement which is obviously suited to a custom Windows app I'm not about to walk away and turn down their money because "I'm a web developer" and "I don't do that sort of thing".

Without going in to too much detail I have a requirement from an Event Photographer who can process tens of 1,000s of photos at any given event. They need a streamlined way of importing from memory cards of the various photographers at the event in to one central PC. The process renames and catalogues the files. It also needs to print out contact sheets of the imported images and categorise according to where at the event they were taken. Only a Windows app is going be able to do this.

What Am I Getting At?

My point here is that any time you spend getting to grips with developing ASP.NET web apps inside the Visual Studio environment is time well spent as those skills are transferable and allow you to make Windows apps, should the need arise.

Comments

  1. <applause>

    Jake, it's really good to see the total solution space view being promoted. I try to push for this (have for years) wherever I can and am surprised how often I hear "it's not our core" or "I don't know how" when there are LOADS of free tutorials online and free tools, to boot, in many cases. Honestly - this is the only way to survive as technological evolution accelerates.

      • avatar
      • Jake Howlett
      • Thu 26 May 2011 09:39 AM

      My lack of experience in making Windows apps is more than catered for by the amount of documentation and forum solutions out there. Most of it's fairly intuitive anyway.

      While this isn't my core. It's not so complicated that I can't cope.

      As long as I know a solution is technically feasible I'll take a stab. You just need to know what your limits are. If Air Traffic Control came looking for a new system I might gratefully decline ;-)

      Show the rest of this thread

  2. Jake - Air can now access removable drives.

    Dont know if that makes any difference to you.

      • avatar
      • Jake Howlett
      • Thu 26 May 2011 10:37 AM

      Might be the topic of another blog entry, but initially that's what I looked at. In theory AIR can do it. It can detect insertion of removable media and copy files over. However, AIR can't multi-thread and it locks up ("not responding" greyed-out window) as it copies. This is true when doing Async copying and also using native processes. I had no choice to but to give up and try Windows Forms, where I'm using delegates / backgroundworkers to copy files without locking up the app.

  3. My question is what sort of professional photographer is using a windows machine and not a Mac :P

    As for air I have been using th native process api to do some serious file movig and haven't had issues with that halting the app whatsoever across win/Linux/Mac nonetheless.

    1. Easy - one with a small budget! ;-)

  4. To be fair I'm using a rather strange method of moving files. I generate either a batch or shell script then use the native process API to run it. (was the only way I could find to get around Air not allowing you to write to the application directory)

      • avatar
      • Jake Howlett
      • Thu 26 May 2011 03:12 PM

      The "problem" here is that the batch file doesn't report back progress as it works. With the Windows app I can use a progress bar to keep the user informed of what file it's copying and show them a *truthful* gauge of how far progressed it is. AIR can't do that.

      While I'm sure I could have gotten AIR to do it. I was banging my head against the metaphorical wall at a point way to early on to make me want to continue. With Windows Forms I can rest assured there'll be no barriers.

      I love the idea of it being truly cross-platform but this is one case where a Windows app is the order of the day. I did perceiver with AIR for as long as I could...

      Show the rest of this thread

    • avatar
    • Martin Davies
    • Fri 27 May 2011 04:47 AM

    Take a look at Windows Presentation Foundation - next gen Windows forms

      • avatar
      • Jake Howlett
      • Fri 27 May 2011 05:12 AM

      Interesting.

      Does this use the same XAML markup as Silverlight then? I see there's an option for a "WPF Browser app" project - is that a silverlight app? So this is a bit like creating web vs AIR app in Flex?

      Might switch to using WPF for this project, before I get too far in. Thanks for the heads up. Was wondering what WPF was...

      Show the rest of this thread

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment:


About This Page

Written by Jake Howlett on Thu 26 May 2011

Share This Page

# ( ) '

Comments

The most recent comments added:

Skip to the comments or add your own.

You can subscribe to an individual RSS feed of comments on this entry.

Let's Get Social


About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »

More Content