Twitter Fail

by jmorris 12. September 2011 05:50

image

I find it hard to believe that twitter is still experiencing problems of scale given it’s popularity and available resources. Mind boggling, really.

Tags:

rant

UH, OH!

by jmorris 30. August 2011 20:05

image

image 

image

Looks like the cloud evaporated…

Tags:

rant

MonoDroid and MonoTouch Alive!

by jmorris 20. July 2011 22:11

There was a lot of noise and confusion on the Monodroid mail group when it was reported that Novell had been sold to Attachmate and subsequently laid off the entire Mono team. The two major products that the team had been working on, Monodroid and Monotouch (cross platform .NET platforms for Android and iOS development) apparently were dead.

Well, it looks like Miguel and his team have worked a deal with Attachmate:

Through an agreement with SUSE*, a business unit of The Attachmate Group (the company that acquired Novell in April 2011), Xamarin has a broad, perpetual license to all intellectual property covering Mono*, MonoTouch, Mono for Android and Mono Tools for Visual Studio. Xamarin will also provide technical support to SUSE customers using Mono-based products and assume stewardship of the Mono open source project

- http://blog.xamarin.com/2011/07/18/first-press-release/

This is good news indeed for open source .NET development and all involved.

Tags: ,

Android

The Mysterious +<>c__DisplayClass1

by jmorris 9. July 2011 01:23

While unit testing a a VirtualPathProvider today, I came upon an interesting exception:

System.Runtime.Serialization.SerializationException : Type 'Foo.Web.Core.UnitTests.Plugins.Modules.PluginRegistrarTests+<>c__DisplayClass1' in assembly 'Foo.Web.Core.UnitTests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.

I was stumped by this…what, where and who  is +<>c__DisplayClass1'? Granted my scenario was somewhat complex in that I am testing in a by using a fake AppDomain that mimics the ASP.NET HostingEnvironment ala this post.

When I saw that error, I immediatly thought the problem was that I was missing the Serializable attribute, since the exception explicitly states: “[type] is not marked as serializable.” I added that attribute to class that I was loading into the faux AppDomain for the same result:

image

WTF? I was stumped! I googled around a bit and got side tracked by some discussions of MarshalByRefObject and finally stumbled upon something on Ode2Code. I wasn’t quite sure of what the problem was until I read some of comments. Most notable this one. A quick check of the IL with ILSpy confirmed my suspicions:

image

Fix was easy: simply move the declaration of the FakeHttpApplication class to within the scope of the delegate itself. Here is how I had it defined:

image

And after I moved into the scope of the delegate:

image

So, what was the problem? Basically it comes down to the scoping of Anonymous methods and how the compiler generates code to support them. Anonymous methods are simply compiler generated types. The generated type c__DisplayClass1 is not marked as serializable, so it fails when passed into the scope of the Anonymous delegate call…which is executing in another AppDomain (that does not contain the Anonymous type definition).

Tags: ,

Unit Testing

Monodroid and Monotouch Dead?

by jmorris 16. May 2011 23:01

A couple of weeks back Novell was sold to Attachmate and there was a lot of speculation about what would happen to Monodroid and Monotouch, the Mono based development tools for targeting IOS and Android apps using C#. Well, it looks like they are both dead in that Attachmate laid off the development teams for both.

However, it looks like Miguel de Icaza, the main man behind Mono, has started a new company that will develop tools for developing Mono apps for IOS and Android: http://tirania.org/blog/archive/2011/May-16.html

While the death of Monodroid and Monotouch is a bummer for those who have invested their time, money and effort in them, there will still be tools being developed that will allow C# on these popular platforms. Also, no longer being tied to large company has it’s benefits and undoubtedly the Miguel’s new company will be better equipped to meet the needs of developers.

I was pretty close to committing to Monodroid for my personal droid development, but now I am glad I simply chose the Eclispe/Android toolkit solution. Java and Eclipse are a bit rough of a development stack, but it’s relatively easy to switch between C#/VS.

So, a short step back for Mono, but in the end I think this will lead to good things. At least I hope.

Tags: ,

Android

Using Datatables.net JQuery Plug-in with WCF Services part Duex

by jmorris 29. April 2011 23:51

My older post on using the JQuery Datatables plugin with WCF has been a very popular post, even now, a year later. One thing that people keep asking for and I never have gotten around to doing, is posting the source code. The original post was based upon code I used within the company that I worked for and definitely could not release, however, i was able to strip out and/or stub most of the dependencies and post a working example on github:

https://github.com/jeffrymorris/DataTablesWCFExample

I hope this helps :)

Tags:

Book Review: NHibernate 3.0 Cookbook by Jason Dentler

by jmorris 28. April 2011 23:06

This is one of the most timely and practical books I have ever read. If you are using NHibernate 3.0 and any of it’s “satellite” FOSS projects and you need a reference on how the community is using it, buy this book.

As the name implies,  the book is laid out in the same manner as a “cookbook” with each chapter grouping together several “recipes”. These recipes illustrate how the community in general is using NHIbernate each feature or API and while they may not cover every scenario, are usually enough to get you going in the right direction.

image

The chapters each cover one of the major components of NHibernate, for instance, there are chapters covering of fundamentals of NHibernate:

  • Models and Mappings
  • Configuration and Schema
  • Session and Transactions
  • Queries

Plus additional chapters on the practical usage of NHibernate:

  • Testing NHibernate
  • Creating a Data Access Layer
  • Extending NHibernate
  • Using the NHibernate Contribution Projects

Each chapter is divided into a series of “recipes”, for instance Using the Conversation per Business Transaction Pattern, and then offers an explanation of what the said topic is or does. Then it goes into sections on:

  • How to do it: detailed description what you need to do to get the example working
  • How it works: detailed description about what is going on behind  the scenes
  • There’s more: any additional information or examples that adds value to the recipe
  • Getting Ready: gives information that is required to get the recipe to work – e.g. download the project binaries from http://code.google.com/p/unhaddins

Pros:

  • Easy to read
  • Packed full of timely examples
  • Layout is easy to follow and comprehend
  • Will get you up and running with NHIbernate very quickly

Cons:

The author’s blog: http://www.jasondentler.com/blog/

Tags: ,

Book Reviews

What Am I Missing Here?

by jmorris 9. March 2011 07:16

So I am trying to purchase VS2010 for home use, side projects, etc…I google VS2010 price and click on the first “relevant” result: http://www.microsoft.com/visualstudio/en-us/products/2010-editions/professional

And click the “BUY NOW” link which opens:

image

Great $549 for VS2010, way to expensive but within the budget. So click on the link to purchase and this is what I am presented:

image

$799.00? WTF? But wait, full version $549.00 (my only option, really). And what do I see in the cart?

image

Fantastic….

Tags:

rant

Book Review: Introducing HTML5

by jmorris 4. March 2011 22:54

As usual I have been reading a ton of books lately on various subjects from HTML5 to NHibernate to unit testing and other subjects as well. The plan is to write a series of reviews of each book over the next couple of weeks.

html5

The first book I will write about is Introducing HTML5 by Bruce Lawson and Remy Sharp. If your not familiar with HTML5, it along with CSS3 are the latest and greatest in web standards and technology from the W3C. Too be honest, you have to use the term HTML lightly, with respect to HTML5…while it does add to the markup common associated with HTML and other SGML derivatives, it also offers a whole slew of technologies that are decidedly outside the scope of markup: graphics, client side messaging, geo-location and others.

I’ll keep this book review short and sweet, like the book at barely 200 pages…as the title states, it is an introduction to HTML5 and gives a summary of the various technologies that it comprises. It’s not a reference manual nor a deep explanation of the subject; it’s a brief description of each technology with simple, real world examples of their usage. In my opinion it’s worth is in that a few hundred pages you get enough understanding of each technology, not enough to walk the walk, but definitely enough to hold a conversation on one of the topics. If you are already past this stage, it probably would not appeal to you; it simply doesn’t offer he enough detail.

Additionally, one thing that it does do is give small nuggets of information regarding work-rounds for various browsers that only partially support HTML5 or have bugs in their implementation. In fact, the authors are not shy about discussing some of the limitations of the support for HTML5 across the common, modern browsers. Of course, this is somewhat awry from some of the HTMl5/CSS3 “fanboys” out their that try to pawn HTML5 as the next coming…the truth is that only portions of HTML5 are completely supported by all browsers and knowing the work-rounds (html5shivselectivizr, modernizr, etc) the key to using it now.

Who is the book for? Pretty much anybody with a cursory understanding of HTML, browsers, how the web works and maybe some experience with JavaScript or another programming language. Much of it is suitable for managers as well.

References:

Tags: ,

HTML5

ActiveMQ: Topics vs. Queues

by jmorris 9. February 2011 13:47

The JMS specification defines two different ways of defining message destinations: Queues and Topics. Understanding the behavior of each is vital to implementing messaging within a system and fulfilling any expectations of message availability.

First a quick aside, the purpose of this post is mostly to keep myself from committing the mistakes I made today based upon invalid assumptions regarding the availability messages sent to a queue within an environment with multiple listeners. In a nutshell, I was writing a test to queue up a single message and I have a listener within the test receive the message.  For some reason the message was never being received…baffling given the simplicity of the test and the maturity of the code.

Here is the test (ignore that the test is not well written, I just want to quickly test that the code works while I am developing):

image

I edited this code a bit for simplicity, but in essence a message should be pumped to the console and displayed (real test validates that message was received after x seconds delay). The only problem was I that I was getting nada…note that I am not testing the queuing API itself, I am testing that the strategy will push a message onto the queue without throwing an exception. It’s basically a throwaway test to prove that it works as expected in an integrated environment.

The problem was that the message was never being received by the listener (QueueReceiver is the listener), however other similar tests that are messaging API specific were working as expected. Running through the usual checks turned up nothing. The code simple didn’t work…but only for this test! Swapping out for another queue worked perfectly :(

Fool me once, shame on you. Fool me twice…

So, what was causing the problem? Well it all became very clear once I went back and reflected on the basics of JMS messaging and the differences in how messages are delivered to queues and topics.

The JMS specification supports two models for sending messages: point-to-point for queues and publish and subscribe for topics. In a nutshell, only one consumer of a queue will receive a messaging regardless of the number of consumers; round-robin message dispersal. Whereas a topic broadcasts a copy of the message to every registered consumer.

It turns out out that I had a windows service running that was a consumer of the same queue and It was the first listener, so it always got the first message. The unit test never received a copy because only one message was sent and the consumer on the windows service always pulled it off. This was proved by simply calling publish twice:

image

This consumer (_receiver) got the second message, because the first one was consumed by the windows service and the next round-robin listener was this unit test. ARGGGHHHH, what a waste of time and brain power!

Lessons learnt:

  1. Don’t write unit tests with external dependencies and assume they will behave as expected
  2. Don’t use shared queues for testing
  3. Don’t forget the difference between queues and topics

References

Tags:

Apache.NMS, JMS | rant

Jeff Morris

Tag cloud

Month List

Page List