Binding PictureEdit

by Administrator 4. September 2010 15:05

 

The following line of code was causing an unhandled FormatException which Visual Studio was kindly ignoring and was resulting in hours of painful debugging. 

logoEdit.DataBindings.Add(

 

"Image", this.competition, "Logo");

I managed to fix the problem by simply changing the code to the following:

logoEdit.DataBindings.Add(

 

"Image", this.competition, "Logo", true);

 

The 'true' value is specifying to use formatting for the value.  Not sure why exactly this fixed the problem and I don't care to spend time on it right now, but hopefully google will pick this up and someone else might find a solution a bit quicker than I did.

Tags: ,

Playing nicely with Exceptions in VS2010

by Administrator 4. September 2010 13:45

Today I had an issue whereby a deployed application would fail with a System.FormatException on a form binding.  However when I ran this code in VS2010 it would run fine.  Then I noticed I was getting the following in my Output window of Visual Studio:

A first chance exception of type 'System.FormatException' occurred in System.Windows.Forms.dll

So, Visual studio was ignoring my exception.  After much searching around the net and forums I finally discovered the Exceptions window of Visual Studio - Ctrl-Alt-E or Debug -> Exceptions...  A quick search for "FormatException" and tick the "Thrown" box and finally Visual Studio throws a proper exception and I can debug my problem.

Tags:

OData, XPO, ObjC

by Administrator 12. August 2010 19:50

The number of times I've wished I could write some DotNet data access code on the iPhone is astounding.  Until recently I've always thought the process of remotely accessing data within iPhone apps was painful.  This week I've looked a bit at the OData project, and using it with XPO (DevExpress).  Making an XPO data model visible as an OData provider is very simple, there's an opensource DevExpress.Data.Xpo.Service class which does all the hard lifting, so basically all that's required in the addition of a WCF Data Service to your existing ASP.NET website. 

From the iPhone side there is an Objective-C SDK/Library for accessing the OData provider.  This part I haven't implemented yet, but the documentation makes it look very simple, almost trivial. 

http://www.odata.org for more information on all of this.   

Tags: , ,

iPhone Applications #2

by Administrator 8. August 2010 11:18

Following from my previous post I've decided I will write a new iPhone app to locate the nearest Brisbane CityCycle station, for the new Brisbane City Council project for short term bike hire.  This follows in the footsteps of other similar projects in other cities such as Paris, Barcelona and Bordeaux.  I had the idea a few weeks ago and emailed the council without any response, so I figure I might as well do it anyway - it's a good service.

I've decided to use a kml data file as my datasource and using the TinyXML parser to provide me with XPath support is much quicker and easier than the previous method I used which was to write my own parser using the base SDK NSXMLParser events.

Here are a couple of preliminary screenshots:

 

Tags: , ,

iPhone Applications #1

by Administrator 8. August 2010 11:12

Well I've finally written and published my first iPhone application to the AppStore.  It is the Goodlife Health Clubs timetable and information application which I originally developed as an iPhone-friendly HTML interface.  The new version supports mapping of locations for the clubs, and the ability to book a PT amongst other things.

Here are a couple of screenshots.  

 

Tags: , ,

Blog

XAF Data Import Functionality

by Administrator 2. May 2010 11:05

One of the biggest problems with migrating legacy applications to a new framework (such as XAF, netTiers, etc) is the process of importing existing data into the newly created application. I've always found this to be a challenging and boring step of the process, and usually it requires a fair bit of manual work or writing custom import functions or applications.

I think there are probably (generally) 3 common data import sources:

  • Flat File (CSV, TSV, etc)
  • XML File
  • Relational DBMS (Access, SQL, MySQL, etc)

As most of my projects these days are baed on XAF or XPO, I figured there must be a more generic way to do my data imports. XAF is an application framework built around eXtensible Persistent Objects (XPO) which is a proprietary ORM technology developed by Developer Express.

XPO Objects are defined in classes which derive from XPObect (or other) base classes with various Attributes to further refine persistent behaviour.

I have added a few of my own custom Attributes to decorate my XPO classes and properties in order to hint my data import library with any additional data required for the import process. I have a custom application XpoImport which uses reflection to enumerate all the Xpo classes and properties within a specified namespace. This application creates two connections to the source and destination databases and provides a small amount of in-memory caching for lookup data. Some examples will follow.

[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]

public class TableImportAttribute : Attribute

{

public readonly string SourceTable = string.Empty;

public readonly string KeyField = string.Empty;

...


[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)]

public class FieldImportAttribute : Attribute

{

public readonly string SourceField = String.Empty;

public readonly FieldConversionType ConversionType = FieldConversionType.None;


public enum FieldConversionType

{

None,

IntegerToString,

StringToPhoneNumber,

Lookup,

Enum

}

...


The business objects must now be decorated with these properties as such: (this example demonstrates that the new "Area" XPO object data will be loaded from the "tblAreas" source SQL table using "AREAID" as the key. The Name property will be populated with data from the "SEARCHTEXT" field from the "tblAreas" source.)


   [DefaultClassOptions]

[DefaultProperty("Description")]

[TableImport("tblAreas", "AREAID")]

[TableImportIndex(1)]

public class Area : XPObject

{

private string _Name;

[Size(20)]

[Indexed(Unique = true)]

[FieldImport("SEARCHTEXT")]

public string Name

{

get

{

return _Name;

}

set

{

SetPropertyValue("Name", ref _Name, value);

}

}


Once the required fields have been created, I run a small WinForms application which loads the business object assembly and iterates through the various objects to load the data.


201005021603.jpg


Still a work in progress, but slowly getting there...


Tags:

Hardware Manufacturers

by Administrator 29. April 2010 10:03

I can see the merits in hardware vendors and software vendors being more or less the same thing.  Eg Apple Inc.  I mean - you know there's compatibility throughout the life of your product, and generally long into the future.  The companies that anger me to no end are the ones like Behringer.  I have bought several of their products over the years and quite frankly they are useless.  The products may be good quality and well priced for what they are - but their product support is crap.

My latest example - FCA202 - a log-cost firewire audio interface.  Supports windows XP and "maybe" vista, but certainly doesn't support any 64bit OS. 

Works fine under OS X though - so now I'm kind of being forced into getting a new sound board just for windows... just so I can listen to a couple of MP3's when I boot into bootcamp? 

Tags:

Thread-Safe DotNet UI Updates

by Administrator 17. April 2010 06:18

I can’t count the number of times I’ve had problems in Multi-Threaded C# / VB apps, nor can I count the number of times I’ve had to Google for the solution to this common problem.  This week I finally found a generic method to handle the situation where you want to update UI from another thread.

 

public static class ThreadSafeInvokeExtension
{
    public static void ThreadSafeInvoke<T>(this T @control, Action<T> toPerform) where T : ISynchronizeInvoke
    {
        if (@control.InvokeRequired)
            @control.Invoke(toPerform, new object[] { @control });
        else
            toPerform(@control);
    }
}

To use the extension method just do something like this:

textBox1.ThreadSafeInvoke(box => box.Text = value);

For more information on the Action<T> delegate used in this method check out the MSDN page here : http://msdn.microsoft.com/en-us/library/018hxwa8.aspx

Another good use for the Action<T> delegate is on Steve Smith’s blog here : http://stevesmithblog.com/blog/eliminate-repetition-with-action-lt-t-gt/

Tags:

Things To Research Further

by Administrator 14. April 2010 08:46

I've been listening to Scott Hanselman's podcasts (www.hanselman.com) in the car recently and have heard about a few interesting projects that I think would be worth further investigation.

Also a couple of libraries I've used before but I think I need to research a bit further.

As part of my project to port AirpCap I think the QuickGraph library could come in very handy as a simple way to graph AP - Client associations and display them graphically.

Tags:

Porting AirPCap to C#

by Administrator 9. April 2010 12:51

As part of my security work I often perform wireless audits of 802.11a/b/g/n networks and use a variety of tools to manage this. A couple of weeks ago I finally got myself a CACE Technologies Airpcap NX device. It's a small USB wireless adaptor with two external antenna connections. The NX model supports packet transmission or injection also.

I've written a few custom tools before using the SharpPcap library for DotNet and figured I would do a couple more to utilise the enhanced capabilities of the new hardware. Out of the box it works a treat, and is visible to SharpPcap (and any other winpcap applications I suspect), however the airpcap specific features are not exposed through these apps. The only applications which support the full functionality of the device are some custom versions of aircrack and kismet which use cygwin to run on windows.

So, this brings me to my first opensource project. I've decided I should extend the functionality of SharpPcap to support an additional device type and expose the full capabilities of the airpcap hardware.

More details to come...

Tags:

Shaw Innes

I'm an independent software developer, security consultant and digital media expert.  I have worked on a variety of projects over the last 10+ years ranging from simple websites, through to complex network security audits, digital media projects, iPhone applications, mobile communications frameworks and more.  Currently I work mainly in C# .NET and Objective C for iPhone / iPad development.