mike-obrien.net Resume Blog Labs
Wednesday, November 08, 2006

Previously (Prior to v1.4) the Subversion server (svnserve.exe) couldn’t be natively run as a Windows service. You had to use a wrapper such as srvany.exe from the Windows res kit to host it. Well now as of v1.4 it will run as a service but you have to manually install it. Doing this is pretty simple; just use the sc utility to add it at the command line as follows. The first svnserve switch (--service) notifies it that it should communicate with the SCM. The second (-r), which is optional, allows you to specify the root repository path.

C:\>sc create SubversionServer binpath= "\"C:\Program Files\Subversion\bin\svnserve.exe\" --service -r  e:\Subversion\RootRepo" displayname= "Subversion Server" depend= Tcpip start= auto

C:\>sc start SubversionServer

You can find the release notes about this new feature here.

Wednesday, November 08, 2006 12:01:14 AM (GMT Standard Time, UTC+00:00)  #   |  Comments [0]  | 
Tuesday, November 07, 2006

I ran into an issue today where I was coding in a class under a particular namespace but couldn’t access a class in another namespace that only differed by its namespace root. Here is what it looked like:

MyApp.Common.MyClass // Class I want to reference (For a unit test)

TestSuite.MyApp.Common.MyClass // the class I'm coding in (A unit test...)

When I referenced MyApp.Common.MyClass it was actually resolving to TestSuite.MyApp.Common.MyClass. So if you want to reference the former, you need to use the "global::" prefix as follows:

global::MyApp.Common.MyClass

.NET | C#
Tuesday, November 07, 2006 8:49:11 PM (GMT Standard Time, UTC+00:00)  #   |  Comments [0]  | 
Sunday, October 15, 2006

In OOP, type variance refers to the difference between a class and its descendant or ascendant. For example lets say we have three classes; Vehicle, Spacecraft and Shuttle. Shuttle inherits from Spacecraft which inherits from Vehicle. They all vary by type. Vehicle is the contravariant of Spacecraft since Vehicle is Spacecraft’s ancestor whereas Shuttle is the covariant of Spacecraft since Shuttle is a descendant of Spacecraft. Invariance simply refers to a lack of variance. For example a parameter or return type that must be invariant cannot respectively accept or return an ancestor or descendant of the type specified, they can only accept or return the specified type.

Sunday, October 15, 2006 6:33:35 AM (GMT Standard Time, UTC+00:00)  #   |  Comments [0]  | 
Wednesday, October 11, 2006

The following is a breakdown of 4 basic bitwise operators; NOT, OR, XOR and AND.

NOT

NOT produces the inverse of a binary value. For example:

1 will be 0 and 0 will be one. In C# NOT operations are only allowed on Boolean values. The NOT operator is an exclamation point (!).

bool i = true;

Console.WriteLine(!i);

// returns false

OR

OR produces a 1 if either corresponding bit is 1. This means that if both are one or if only one is 1 the result is 1. If both are zero then the result is zero. For example:

In C# the OR operator is the pipe (|).

int i = 23; // 010111
int z = 45; // 101101

Console.WriteLine(i | z);

// 63 - 111111

XOR

XOR (Or Exclusive OR) produces a 1 if either corresponding bit is 1 but not both, in other words mutually exclusive. This means that 1 and 0 or 0 and 1 will be 1. 0 and 0, 1 and 1 will produce 0. For example:

In C# the XOR operator is the caret (^).

int i = 23; // 010111
int z = 45; // 101101

Console.WriteLine(i ^ z);

// 58 - 111010

AND

AND produces a 1 only if both corresponding bits are 1, otherwise it produces a 0. For example:

In C# the AND operator is the ampersand (&).

int i = 23; // 010111
int z = 45; // 101101

Console.WriteLine(i & z);

// 5 - 000101


 

.NET | Binary | C#
Wednesday, October 11, 2006 8:07:13 PM (GMT Standard Time, UTC+00:00)  #   |  Comments [0]  | 

Unary operations only have one input while binary operations have two inputs. For example ++i is a unary operation since this statement only has one input value, i. On the other hand i + n is a binary operation (Not to be confused with the binary numeral system) since there are two inputs, i and n. i + n + z is still binary since it is actually 2 binary operations; i + n = x, then x + z = y or (i + n) + z.

Wednesday, October 11, 2006 6:16:27 PM (GMT Standard Time, UTC+00:00)  #   |  Comments [0]  | 
Tuesday, October 10, 2006

I recently had the opportunity to work with a 2d area scanner (aka Bar Code Reader) in a .NET application. Previously our client used proprietary software that just plain stunk so we decided to write our own software. One very cool thing I discovered while working on this project was that many USB devices (Like bar code scanners, joysticks, game pads, mice, keyboards, etc) sport a Human Interface Device (HID) interface. This interface communicates using the standard HID protocol defined by the USB Implementers Forum. The cool thing about this is that one standard device driver can be written and used for all USB HID devices on a particular platform. Normally you would have to write your own device driver or use an existing one to communicate with a USB device, ouch! USB HID eliminates that requirement. Windows ships with a standard USB HID device driver and automatically makes the HID interface available when a USB HID device is plugged into the system. Nothing to install, no device driver to write, yay! Windows also has a fairly easy to use API (Although a little quirky) for communicating with HID devices. This site, run by Jan Axelson, has a lot of good information on communicating with USB HID devices. His book, USB Complete, is also an invaluable resource, I would definitely recommend it if you will be doing HID development on any platform.

I have an HID .NET library available here if you want to skip most of the gory details and get right down to business. I have used this library in production and have not had any issues, please let me know if you have any feedback. Using this library, while encapsulating most of the underlying details, will require you to understand the format of data contained in the payload of the reports sent to and from the device. HID’s communicate using "reports" which are analogous to packets in network terminology. The reports themselves are a standard USB HID data structure although the payload of these reports will be specific to the device or device type. Usually the payload data format can be found in the device SDK and/or by simply analyzing the payload data the device sends.

The following library, developed for the HHP IT4600/IT4800 area scanner, uses the aforementioned HID library.

IT4XXXScanner.zip (1.98 MB)
Tuesday, October 10, 2006 8:15:40 PM (GMT Standard Time, UTC+00:00)  #   |  Comments [4]  | 

Have you ever wanted to embed an HTTP server into your application? For example let’s say you have a Windows service that you want to administer or monitor (Google desktop is a good example of this). Or let’s say you have an application that requires an alternate interface such a kiosk application. Wouldn’t it be great to have an embedded HTTP server that would allow you to provide a web interface for your application without requiring IIS and without requiring you to write a web server? If so then Lomez is your friend!

Lomez is an in-process HTTP server that allows you to create virtual directories, serve static content from a file or embedded resource and expose any object by implementing the HTTPHandler interface. It loosely resembles ASP.NET to allow you to use it with ease.

Ok, enough of the spiel… Basically I have a number of applications I work with that I would love to have HTTP access to, especially Windows services. I have looked high and low but have not found a library to allow me to do this. So at that point I figured I would have to develop something myself and Lomez was born. I have successfully used this library in a production kiosk framework (At 2 tradeshows so far) and it has worked like a champ. The current version of the library can be found here. I would love to hear any feedback you might have on it.

I consider the current version more of a proof of concept and would really like to rewrite it from the ground up. So hopefully I can begin doing that soon. I would really like to include basic authentication, challenge/response and SSL in the next version. I would also like to optimize the HTTP pipeline so it is lean -n- mean. It’s definitely not right now.

Anyways, if you end up on this page because you are looking for an in-process HTTP server for .NET please let me know your thoughts. And if you decide to use the library, let me know what you think of it.

Thanks!

The Management

Tuesday, October 10, 2006 7:04:45 PM (GMT Standard Time, UTC+00:00)  #   |  Comments [1]  | 

Interesting TechEd presentation on SaaS by Gianpaolo Carraro.

Tuesday, October 10, 2006 4:34:04 PM (GMT Standard Time, UTC+00:00)  #   |  Comments [0]  | 

So I needed to setup build, dev and staging servers on a limited budget. Getting 3 new servers in a small company is not always feasible as you probably already know. The solution? Microsoft Virtual Server 2005. Although I was familiar with the concept of running virtual servers I had not actually done it before (Shame on me!). So I was very surprised with just how easy it was to setup and configure MSVS! The configuration is so intuitive that I literally didn’t read a word of documentation (Which really appealed to my male, "I don’t need to read the directions" side… ;-)) and had a virtual server up and running in no time. The other thing that really surprised me was performance. I’m running Windows Server 2003 Standard on a 2.0 GHz AMD Athlon XP 2400+ box with 1 GB of memory (Not a very beefy box). The host system is acting as the build server and two virtual servers are running as a development and staging servers (Both running Svr 2003). I’m very surprised how "zippy" the virtual instances run.

Our network admin had a great suggestion; first create a template server which can be copied for new instances. That way you can create new instances with out having to start from scratch. When you create the new instance you need to give Windows a unique SID. Sysinternals has a free SID changer tool called NewSID which will do this. You can then take it a step further and create instance specific copies. For example I can get our dev and staging server’s setup exactly how I want them and make a copy of those instances. Then if either one of those servers gets hosed I can wax them and copy out a fresh version literally within a few minutes.

MSVS installs a net driver that allows all instances to share a single NIC. From what I have read, each instance is assigned a random MAC address. The NIC is put into promiscuous mode and packets are filtered and routed to the virtual servers.

All in all I'm very impressed with MSVS. And I'm pretty hyped about how easy it is to setup complex test and R&D environments with minimal hardware. I would be curious to see how it compares with VMWare. I guess I'll save that for another weekend... ;-)

Microsoft offers Virtual Server 2005 as a free download here.

Tuesday, October 10, 2006 3:31:10 PM (GMT Standard Time, UTC+00:00)  #   |  Comments [0]  | 
Thursday, October 05, 2006

Some interesting peices on interviewing developers:

http://www.joelonsoftware.com/articles/fog0000000073.html

http://www.hanselman.com/blog/WhatGreatNETDevelopersOughtToKnowMoreNETInterviewQuestions.aspx

Among the many good points Joel makes, one that really struck me was on "illeagal questions" to ask an interviewee. I think some are pretty obvious but I think one really needs to be careful about questions asked in an attempt to take an interest in the person and/or be friendly. For example I love to learn about and understand different cultures, and most people love to talk about their culture and where they are from. So I usually have no qualms about engaging people in this type of conversation. But on an interview this is off limits since it could be taken, not as friendly conversation, but as discriminatory questions regarding race.The following FAQ covers these issues.

http://www.eeoc.gov/facts/qanda.html

Thursday, October 05, 2006 3:14:34 PM (GMT Standard Time, UTC+00:00)  #   |  Comments [0]  | 

Joel Spolsky (Who runs Fog Creek Software) compiled a very insightful 10 item hit list on how to write better code. A lot of good points. I especially like the points about quiet working conditions and one step builds... Check it out:

http://www.joelonsoftware.com/articles/fog0000000043.html

Wednesday, October 04, 2006 11:30:57 PM (GMT Standard Time, UTC+00:00)  #   |  Comments [0]  | 
Wednesday, October 04, 2006

When making schema changes to a DB in SQL Server 2005 Management Studio you may receive the following error for long running operations:

"Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding."

Then you’ll probably go check out the execution timeout only to find that it’s set to be unlimited (As I did… ;-)). Then you’ll probably search the web to find why this doesn’t make a difference and find that there is timeout override hiding out under the “Designers” node (The LAST place I would have thought to look!). Now the problem is if you uncheck the timeout override it will not actually remove the override (Bug?). So you have to actually explicitly set the timeout.

Wednesday, October 04, 2006 3:21:57 PM (GMT Standard Time, UTC+00:00)  #   |  Comments [6]  | 
Monday, September 25, 2006

I have been running into this problem lately where I try to create a VSS source control binding on a project that already has a binding (Albeit an incorrect one). When I try to bind the project I get this error:

"One or more of the project's destination paths are invalid. To open this solution, you must specify valid paths for each project. The error was "The Web at 'http://localhost/yada-yada-yada' already contains a project. You need to choose another location for your Web project.".

So I have found a solution in a number of blogs/forums that seems to work. Basically you need to remove the source control information for the project in question in the solution file. The lines will look like this:

SccProjectUniqueName1 = http://localhost/SolutionName/SolutionName.csproj
SccLocalPath1 = .
CanCheckoutShared = true
SccProjectEnlistmentChoice1 = 2

Then decrement the SccNumberOfProjects value by 1. Once this has been done, manually reset the binding and your golden!

Monday, September 25, 2006 4:24:36 PM (GMT Standard Time, UTC+00:00)  #   |  Comments [1]  |