Thursday, October 30, 2008

WCF error when transferring large byte arrays

Today I was receiving the following error when attempting to send a reasonably large byte array to a WCF Service.

There was an error writing to the pipe: Unrecognized error 232 (0xe8).

 

As you can see another potential candidate for least descriptive error message known to mankind. The only references to this error that google could find (here and here) were not all that helpful as they were about timeouts and closing the channel, in my case nothing was timing out. The solution was eventually obvious, a simple oversight on my part, the maxReceivedMessageSize property of the binding needed to be set to an appropriately high number so that the channel would allow for such a large message to be sent. Note you'll also need to set the maxArrayLength parameter of your readerQuotas configuration entry to a suitably large number otherwise it won't accept your byte array. eg.


<binding name="MyBinding" maxReceivedMessageSize="99999998">
<readerQuotas
maxStringContentLength="65536"
maxBytesPerRead="9000000"
maxDepth="96"
maxArrayLength="2097152"/>
</binding>

Friday, October 10, 2008

Personal Projects

Most developers have them, an idea in the back of their mind for a project they'd like to write. Could be anything from a little utility app to automate something that they find tedious, through to the next big web 2.0/3.0 application that will change the world (or at least make them very rich). I know I always have a few that I've got on the boil from time to time. Mitch Denny has even gone as far as posting up some of his ideas. My biggest problem has always been finding the time between a fairly full on job, and a reasonably active social life, to sit down and make some significant progress on any of them. This in fact has formed part of my justification for taking a year off work and travelling to Argentina (for a full list of justifications see this post on our tangotrails blog).

I have been making some significant progress on a couple of my ideas over the past few months, and it has re-affirmed to me the professional value of having personal projects like these. The main project I've been working on is an idea to combine my technical side and my creative side. I won't say any more in this post, except that I want to see how far the web can push the way we experience the narrative form.

Because it is my project, and my idea I have full ownership over everything, good and bad. I have full ownership of the codebase, I have full control over the direction, over deadlines and milestones, I have full responsibility for testing and bugs, I'm even in charge of running a beta program (which I intend to do soon), and marketing the product. Legal issues, hosting provider, selection of tools, graphic art, everything is my responsibility, and mine alone. It has been a really educational experience to work on a project so fully from end to end, and not be able to assign parts of the application off that are "not my problem" to someone else. I am learning so much, not just about new technologies, but also some of the non-technical aspects of getting a project like this off the ground.

I think forward thinking companies should try to encourage these personal projects for their technical staff, even if the projects their developers want to work on don't wholly align with their business goals. I'm thinking along the lines of a company integrating personal project time into their staffs professional development plan. Something like allocating X days of your professional development time to a personal project. Of course you may need a project approval process, but this shouldn't be aimed at the business determining if the project is aligned with their goals, but more that the project is significantly challenging for the developer for her to really gain something out of it. Also, a short presentation of their work, in whatever state it is in after the allotted X days, would ensure the developer is kept honest, and that information is disseminated to other developers in the organisation.

I can see this benefiting this hypothetical forward looking company in a number of ways. For starters, I've seen a lot of developers get bored with what their business wants them to do on a day to day basis. Often developers end up in roles where the domain holds little or no interest for them, or if it once did, the constant focus on it destroys some of the enjoyment they once had. Focusing, even for a short time, on something completely different, that they are really interested in, will re-invigorate the developer. Also, having developers play with technologies outside of their normal sphere of day to day experience in the business, will make them a valuable asset if the business ever needs to consider any of those technologies in the future. Being able to advertise this approach to professional development would also attract the right sort of candidates when recruiting. A really forward thinking business may also be open to the possibility that one of their developers might just be creating the next big web 2.0/3.0 application and might even be willing to partner with them in an endeavour to commercialise it.

 

Sunday, October 05, 2008

XHTML 1.1 strictly ASP.Net

For those of you who are interested in web standards, you may have noticed that when you create an ASP.Net application the standard project item templates create a web page that complies to the XHTML 1.0 Transitional doctype. This may or may not be what you want.  XHTML 1.0 Transitional is for existing websites that are in the process of migrating, or if a website specifically needs to support browsers that don't know about CSS. This is because XHTML Transitional still supports the presentation based tags such as <font> and <center>. New websites however, should generally adhere to the XHTML 1.1 strict doctype which does a better job of enforcing separation of content from presentation. So as an ASP.Net developer I have to re-jig all my pages when I add them into my solution, to comply with this doctype.

 

No longer do I have to do all this manual work, thanks to a fellow Readify colleague, Damian Edwards, who's work I really admire and respect, you can now add proper XHTML 1.1 strict templates when developing ASP.Net applications. Damian has created this CodePlex project that installs XHTML compliant item templates for ASP.Net Web Project items such as Web Form, Master Page, Ajax Web Form, Ajax Master Page, HTML Page, and StyleSheet for Visual Studio 2008.

 

Note : you also have to add the following to your web.config

<xhtmlConformance mode="Strict"/>

This tells the ASP.Net rendering engine... "no I really meant it when I said strict, and I know what I'm talking about."

What does this guarantee you as an ASP.Net developer?

Because of ASP.Net's browser capabilities detection mechanism, what this guarantees you is that when ASP.Net is serving a page to a modern browser, it will serve XHTML 1.1 strict compliant markup. Be careful, this does not necessarily mean that your site will validate with the W3C Validation Service, in fact I've been caught out on this one before.

This reminds me that I've been meaning for a long time now, to write a more concise article on developing standards compliant web pages in ASP.Net, I'll put it on my daily goals list, item #44 right after "learn Spanish". (sorry for those who don't quite get the obscure red dwarf reference).