.Net ramblings
# Monday, 15 March 2004
Windows Forms DataGrid throwing a null reference exception on DataRowView.CancelEdit()

I encountered a frustrating issue using the Windows forms Datagrid today.  This problem was also posted without reply on an ms newsgroup. I'm posting my work around here for the record. 

Problem Description
My windows form had a tabcontrol, with 2 tab pages, each with a datagrid, bound to a table in a dataset.  The problem occurred when the user switched from the second tab to the first, with the last row of the datagrid being left as a new row with default null values. It was in 'edit mode' usually because the user added a new row, or pressed enter, which automatically places the cursor in another empty new row, with the default values. The exception I got was generated by the framework and not from my code, as follows:

Object reference not set to instance of an object, at:

System.Data.DataRowView.CancelEdit() at
System.Windows.Forms.CurrencyManager.CancelCurrentEdit() at
System.Windows.Forms.DataGrid.OnLeave_Grid() at System.Windows.Forms.Control.InvokeMarshaledCallbacks()

The exception is interesting in that the CurrencyManager kicks in when the focus of the DataGrid has left, and cancels the cell currently being edited. 

Solution
I tried several solutions, and eventually worked around the problem by forcing the user to click a button to switch from one tab to the other (I hid the tab change buttons off the screen), and then disabling whichever grid wasn't being used after the button was pressed.  This seemed to change the way the DataGrid cancelled the edit of the last row, and the exception doesn't happen now.

It's not an elegant solution, so I'm open to suggestions. I do think the datagrid should be able to execute CancelCurrentEdit without throwing exceptions, and I would be interested to understand why it happens.  I guess it will be fixed in .Net version 2.


Monday, 15 March 2004 19:12:33 (GMT Standard Time, UTC+00:00)  #    Comments [2]  .Net Windows Forms

# Saturday, 13 March 2004
Howto: configure a Psion Series 5 for internet access with a Nokia 6610 (GPRS)

This took ages to figure out, and plenty of experimenting with different settings, so hopefully this might save someone else the hastle of having to spend half a day to get their Psion 5 (not MX) connected to the net with a Nokia 6610.  I would say it would work with similar settings on other GPRS phones.

The internet settings are for the O2 network in Ireland and will need adjustments for a different network.

  1. install Psion Series 5 Message Suite version 1.52.
  2. Create a new modem called nokia 6610:
     speed 57600
     connection infrared
     fax class auto,
     init string: ATZ
     flow control: hardware (RTS/CTS)
  3. Create new Internet Service called GPRS with the following settings.
     
     connection type: dialup
     uncheck smart dialing
     standard dial-up number: *99#
     manual login unchecked
     username gprs 
     password gprs
     addresses: get IP from server. get dns address from server unchecked.
     primary dns address: 62.40.32.33
     secondary dns address: 62.40.32.34
     login: use login script checked. default 8 bit no partity 1 stop bit,
     delete all content of login script text box, leave blank.
     advanced: enable PPP extensions checked. allow plain text authentication checked.  
  4. On the psion, set Remote Link to Infrared 57600.
  5. Get the GPRS settings for your phone from your network. O2 will send those details to your phone if you request it from http://www1.o2.ie/CM/getcontent/0,1177,txt_html_OTA_Home,00.html. Save these details to your phone.
  6. Activate Infrared on the phone. Connectivity > Infrared.
  7. Point the Infrared port of the phone thin black band on top of phone) to the Infrared port on the psion (1cm band on back of psion) a few inches away.

Saturday, 13 March 2004 23:10:23 (GMT Standard Time, UTC+00:00)  #    Comments [0]  General

Introduction...

Hi, welcome to my blog.  This is where I will post solutions to problems I encounter while writing software for the .Net platform, in the hope that they may be of some use to people trawling google for an answer to the same problem.  I realise that I wouldn't be half the developer I am today if it weren't for the likes of Charles Carroll's aspNG community, GotDotNet, ms newsgroups, asp.net, windowsforms.com, to name but a few.  I have drawn on these resources for advice and technical assistance many times and this is my way of returning some of that generosity to the community at large, (as well as a space for me to rant about stuff and things).

a little about me
I've been developing in .Net since Beta 2 in 2001 and I write in C#.  I did my undergrad in University of Limerick in Computer Systems, and now I am self employed, doing contracts, training courses, developing software, etc. in Limerick, Ireland.

Flying Simon's Super-10 kite at CastleGregory, Ireland 2002Outside work, I like surfing, table-tennis, flying big kites, cooking and other stuff, so from time to time, you may see the odd post that is nothing to do with .Net...


Saturday, 13 March 2004 19:12:01 (GMT Standard Time, UTC+00:00)  #    Comments [3]  General

404 woes in Windows Server

I've recently started running Windows Server 2003 on my .Net development machine, and so far I love it, hasn't crashed yet, not like win2k, but there was bound to be some config issues..

problem description:
but i ran into problems opening a web project in visual studio 2002, i'm running .Net Framework 1.0 and 1.1 together.  VS would say "404 Not Found" and the two locations need to map to the same folder blah blah blah.  I checked out http://localhost/myproj/myproj.csproj and it did indeed give a 404 error, even though the file was definitely there.

solution:
i trawled google for a while and found an article that describes a similar problem, due to unknown mime-types in IIS 6. it suggested adding in a new mime-type for whatever file type you were using. i checked my mime-types list and .csproj was there already, and .webinfo.  i don't know of other files used in loading a web project, but i added in a new mime-type for .* and put "application/octet-stream" in with it, and it works fine now.

if anyone knows why this is, or how else to work around, please enlighten me, but as long as the above works, that's enough for me ;-)


Saturday, 13 March 2004 12:40:56 (GMT Standard Time, UTC+00:00)  #    Comments [0]  Windows Server