Sunday, May 24, 2009

More lessons

I was testing out a table view navigation project and it kept crashing for no apparent reason. Finally in desperation I did a clean on the project and voila, it ran fine.... xCode, no love for you tonight!

Another lesson learned...

Command-R in xCode is build and run, whereas command-R in interface builder is simulate interface! This caused me confusion because I would build and run in xCode and it would go to a black screen, yet when I did the same from interface builder, it showed my nib file, but I did not realize it was a simulation. doh!

Little Gotchas and findings so far (iPhone)

A couple notes on my findings so far with iPhone development. First off, having been away from C based languages, I forgot that system headers show up in <>'s (#Import ) and that custom classes show up in ""'s (#import "Myclass.h"). Had an issue with that for a short time. Another thing I found was that if you forget a semi-colon in xCode, it is not very good at pinpointing this so it can cause weird messages... so always do a rough check to see if you are missing them (especially if you normally code in a language that does not use them). Something that also caught me, in xCode, when you create outlets and actions that you are going to use in interface builder, you must save in xCode before popping into interface builder so that they show up. I also had a little bit of issues with creating multi-view applications, so I will post on that later when I have more to say on handling that.

Monday, May 18, 2009

Starting an application!

Having chosen an application to work on and worked through some tutorials, I have finally begun to code an app. I have also been reading: Beginning iPhone Development, which is worth the purchase. It is interesting to see how much time it takes to write a functional class in a new language versus one you are comfortable with. I would say so far it is probably a 10:1 ratio for doing iPhone code versus .net for me. Anyhow I have learned a lot thus far! One thing to note, do not turn off the save before running prompt. I was thinking about doing this and then low and behold xCode totally disappeared and crashed when I ran one build. Weird... I thought the commercials suggested that only PC's crashed?

Tuesday, April 28, 2009

Ready, set, ....

1. Team: 3 peeps including myself, committed and ready.

2. Get MACS: One person already had a MAC and myself and the other guy just bought refurbished MAC minis for 499, with keyboard, mouse and tax, $609 canadian, not bad.

3. 40% of the way through Apple's objective C documentation. Not too bad, once you understand the slightly obscure syntax.

Next step: Keep reading, then on May 10th, meet up with team and pick one of several ideas we have. Then we go! Nice thing is that we each had to shell up some cash which really puts the heat on us to produce something.

Saturday, April 18, 2009

Progress so far

1. Team: Gonna roll with a 2-3 person team, depending on ability to get Macs for everyone... The team is picked, but will be finalized based on everyone's ability to get a Mac.

2. Get a MAC: Messed around with PearPc trying to get a virtual environment up...FAIL. Kijiji and Ebay, sometimes a bit dodgy.....Down to 2 options: One buy a mac mini, $729 bones. Reliable option, just a bit expensive. Door #2: A guy I know has a consulting firm and they have Mac clients. One client is replacing their Macs and the old ones have Tiger on them. At most will be $300. Lets assume I can get one of the intel based ones for $250, and then Leopard costs $129, so I might be able to get one there for about $400, which is basically half the price of the mini.

3. Read documentation: Currently on page 78 of 164 of the iPhone application programming guide.

Saturday, April 11, 2009

iPhone Dev

Alright, decided to make the plunge into iPhone development.. Looks interesting and fun and it should be a great learning opportunity as I think I've touched a Mac a handful of times. I will document my progress from zero to hero and hopefully provide insight on a good road map on how to produce an iPhone app. Here is what I have done so far:

1. Assemble a team (always easier and more creative with more people).
2. Get my hands on a Mac to develop with... and maybe one day an iPhone.
3. Read Apples dev documentation.

Tuesday, April 7, 2009

Drawing an image with transparency

I had a bit of trouble finding this, and I see other people asking it, so here it goes:

I found the key was using the imageAttributes class. Basically set the color key to the color you are using to represent the transparent area, and use one of the drawImage calls that accepts an imageAttribute parameter...

Imports System.Drawing.Imaging

' and in a sub somewhere:

Private mImageAttributes As New ImageAttributes
mImageAttributes.SetColorKey(Color.FromArgb(0, 220, 20, 255), Color.FromArgb(0, 220, 20, 255))

Dim imageRectangle As New Rectangle(pX, pY, pBitmap.Width, pBitmap.Height)
e.Graphics.DrawImage(pBitmap, imageRectangle, 0, 0, pBitmap.Width, pBitmap.Height, GraphicsUnit.Pixel, mImageAttributes)

Sunday, April 5, 2009

SQL Server Migration - The easy way

I have had the experience of moving an instance of SQL Server from one machine to another a few times and tried a few different ways of doing so. In simple cases, it can be as simple as scripting a few logons, and restoring backups on a new machine. Sometimes it is a little more involved if replication is involved. The scenario I am covering here is where you would like to replace a machine with SQL and move it to a new machine. I have used this method successfully to move a SQL instance from windows server 2003 to another 2003 box and even from a windows server 2003 box to a 2008 one. Here is an example of what has worked for me, where I want to replace a server named MainServer with a Server called NewBox

  1. Backup all databases on MainServer.
  2. On NewBox, install the same version of SQL as on MainServer, and make sure it has the same service pack if any. ALSO, make sure that the data and log paths on NewBox match that of MainServer (this is important).
  3. Shut down the SQL server on MainBox and set the SQL server service to start up manually as opposed to automatic. Rename MainServer to MainBox-Old or some other name and reboot.
  4. Rename NewBox to MainServer and reboot. Now shut down SQL Server.
  5. Now, since we had the data and log paths set the same on the new server, all we need to do is copy the data and log directories over to the new machine in place of the current install. So, for example, if I had a default install where the logs and data are in the same path (C:\Program Files\Microsoft SQL Server\Data\MSSQL.1\MSSQL), I would find the MSSQL folder for my instance that has the Backup, Data, LOG, etc subfolders and rename that folder MSSQL.OLD (as a fallback). I would then copy over the MSSQL folder from my old instance to the same location as MSSQL.OLD and then I can simply restart the SQL Server and it should start with all logons, replication, and settings of the SQL instance prior to the move.

Sunday, March 15, 2009

unable to find manifest signing certificate in the certificate store

I got this sweet error on my build server today, shortly after enabling signing of my project. I saw many different solutions on the web for this, but most of them involved removing the signature from the project, which I did not want to do. In the end, I ended up installing visual studio express on my build machine and opened up the project. What finally fixed it was going to my project properties -> signing tab, clicked the 'select from file...' button, browsed to my strong name key, and hit OK. Here it asked me for my password on the file (which I may have gotten wrong on the first build on this machine), I entered that, and then it was happy. I assume this action put the certificate into my store as it was building it fine after that.

Thursday, March 12, 2009

LINQ passing query results

Wow, first off, I need a better way to post code to the blog. I noticed this guy has rigged up a way and I will give it a try when I have some time: Please make a note blog
In the meantime I put my code snippet as a crappy image. The problem that I had being a fairly new Linq user was, what if I want to pass the results of a LINQ query to another method, or based on some logic in an if statement, do something different for the query, how can I declare it so I can pass it or use it and assign it based on logic. I found that in the case where I know what I am getting back from my query, then I can declare an Ienumerable of my type and assign it or pass it as I please. In this case I had a query return squares in a sudoku puzzle. You can see below how to declare and then assign the results of one of two linq queries.

Wednesday, March 11, 2009

SSPI Handshake errors

My initial purpose for this blog was to post things that caused me trouble at work that I could not find answers to what I was looking for on google. One of the things that has cropped up lately is some SSPI handshake errors for users connecting to a central SQL Server. The first most obvious cause of this that I have found is when a user has a basic change in their active directory user account. Sometimes their account gets locked out from too many failed password attempts or they change their password, and until this replicates to all sites, they can get handshake errors. Failing that the event log usually shows evidence of issues communicating with servers in regards to these issues. The best resource I have found when troubleshooting this issue is the sql protocols blog. There is one specific page that I can't seem to find again that has several different scenarios where this can occur and how to troubleshoot it. I think one of the keys to this is understanding Kerberos.

The ultimate brownies?

Totally off topic here, but..... I have been looking for a brownie recipe that is nice and chewy and moist just like Betty Crocker. The only difference is that I want to make them myself because they taste better when you make them. Anyone know how to nail these down like Betty? Mine keep ending up like hard plates.

Sunday, March 1, 2009

WCF Host and Client in same assembly

A few weeks ago I decided to write a networked, multi-player version of Sudoku. One of the first things I had to decide to tackle was how the client and server should communicate. I had done something similar in the .net framework 1.1 using sockets and that was my first thought, however I had heard of .NET remoting and thought that was worth looking into. After some research, I found that the most current practice for client/server communication was to use WCF, part of the .NET Framework 3.0 and thereafter. I could not believe how simple this ended up being, and it broke down to a few lines of code in the end. First I had to put this section in my app.config:


















For service name I just put the name of my class with the namespace, I gave the name of the service the same name as my class, and as my contract, I created an interface that has to be present in the server and client, but in my case my assembly could be either. The interface just specified which methods could be called on my server class, and then my server class just implemented that interface. For the server I added a thread to my user interface and when a user chose to host a game it just did this:

mHostThread = New Threading.Thread(AddressOf StartHost)
mHostThread.Start()

And startHost simply did this:

mPuzzleHost = New ServiceHost(GetType(PuzzleServer))
mPuzzleHost.Open()

Having this in a thread allowed the person hosting the game to also join as a client. Then to join the game (server) as client all I had to do was this:

Dim puzzleFactory As ChannelFactory(Of IPuzzleServer) = New ChannelFactory(Of IPuzzleServer)("PuzzleServer")
puzzleFactory.Endpoint.Address = New System.ServiceModel.EndpointAddress("net.tcp://" & frm.IP & ":3315/PuzzleServer")

Try
mPuzzleProxy = puzzleFactory.CreateChannel
mPlayerId = mPuzzleProxy.JoinGame(frm.PlayerName, frm.PlayerColor)
Catch ex As Exception
MessageBox.Show("Could not connect to host '" & frm.IP & "'. Reason: " & ex.Message)
Exit Sub
End Try

I hope that makes sense, if you have any questions feel free to email me.

Friday, February 27, 2009

It's on

Thats right, it's on, here it is...