got net?

Kevin Hazzard's Brain Spigot

About the author

Welcome to Kevin Hazzard's blog.
E-mail me Send mail

Recent posts

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010

A Survey of Popular .NET Inversion of Control Containers

UPDATE: Gaja Kannan attended this presentation and gave me a great link to a post by Torkel Ödegaard concerning IoC container performance. Interestingly, of all the IoC containers out there, Torkel picked the same products as I did (plus StructureMap) for his tests. You can find the post at http://www.codinginstinct.com/2008/08/castle-windsor-dependency-lookup-and.html. Thanks, Gaja, for the link! 

On Thursday, October 2, 2008, I gave a presentation to the Richmond .NET User Group entitled "A Survey of Popular .NET Inversion of Control Containers". It covered Microsoft Unity, Ninject, Castle Windsor and Spring.NET. I talked about the history of the development of Inversion of Control (IoC) and Dependency Injection (DI). I demonstrated the concept in a sample application (linked below). I also discussed Aspect-Oriented Programming (AOP) and how it can be used to create highly cohesive, loosely coupled applications. The slide deck and code is available at the links below.

Source Code (77 kB)   Slides (268 kB)


Tags: , ,
Posted by kevin on Thursday, October 02, 2008 6:30 PM
Permalink | Comments (4) | Post RSSRSS comment feed

Richmond Code Camp 2008.2 Program Handout

I've been so busy planning for Richmond Code Camp 2008.2 on October 4, 2008 that I've been unable to blog over the past couple of weeks. But, because of what I've been working on, the program handout for the Code Camp is ready now. You can download the Adobe Acrobat file from here:

http://richmondcodecamp.org/RCCDocuments/Richmond+Code+Camp+2008.2+Program+Handout.pdf

If you are coming to Richmond Code Camp, you can download this document and plan out your day by looking at the speaker bios, abstracts and schedule. Keep in mind that we may have to make last minute changes to the schedule but, it's looking pretty solid right now. If you still need to register, you can do so here:

http://www.clicktoattend.com/?id=131306


Posted by kevin on Monday, September 29, 2008 8:44 PM
Permalink | Comments (5) | Post RSSRSS comment feed

Richmond Code Camp 2008.2 Speakers List

Richmond Code Camp 2008.2 Speakers List
October 4, 2008 - Please visit http://www.clicktoattend.com/?id=131306 to register.
Application Development Track



Understanding MVC for ASP.NET Developers 100 Brian Hitney 1AD1

Practical Entity Framework 100 Chris Love 1AD2

Design Patterns: Getting to the Aha! Moment 100 Sixto Saez 1AD3

Graphic Design for Developers 100 Frank LaVigne 1AD4

DotNetNuke: A .NET Open Source Web Application Framework 100 Chris Busse 1AD5

Creating Custom Templatable Controls in Silverlight 200 Page Brooks 2AD1

Building Rich Web Interfaces with ASP.NET MVC and JavaScript 200 Jess Chadwick 2AD2

Developing Peer-to-Peer Applications with WCF 200 Darrell Norton 2AD3

May the Source Stay With You 200 Steve Andrews 2AD4

Going Proxy-less: The Runtime WCF Proxy Factory 300 Daniel Bullington 3AD1
Career and Profession Track



Turn On. Tune In. Quit Your Job 100 James Avery 1CP1

Mentoring; Getting Things Done for Programmers 200 Jonathan Cogley 2CP1
Database and Business Intelligence Track



Bring Me Your Toughest SSIS Questions 100 Andy Leonard 1DB1

SQLCLR: What DBAs and Developers Should Know About .NET in SQL Server 200 Hal Hayes 2DB1

SSIS Frameworks 200 Steve Fibich 2DB2

Make Reporting Services Work For You 300 Jessica Moss 3DB1
Development Methodology Track



Better Source Control with Subversion 1.5 100 Kevin Jones 1DM1

Design Principles 100 Chris Eargle 1DM2

Test Smarter - Patterns and Tools to Make Your Life Easier 200 Al Tenhundfeld 2DM1

Advanced Techniques for Everyday Development 200 Edwin Ames 2DM2
  Test Driven Development with C# and Mocks 200 Jonathan Cogley 2DM3

Of Lists and Lambdas / An Introduction to Functional C# Programming with System.Linq and Mono.Rocks 300 Jonathan Pryor 3DM1
Emerging Languages Track



Fringe Languages and The Benefits to 9-5'ers 100 Amanda Laucher 1EL1

New Features in C# 3.0 100 Chris Eargle 1EL2

Microsoft 'N Ruby Sittin' in a Tree… 200 Justin Etheredge 2EL1

Stupid Python Tricks 200 Kevin Hazzard 2EL2

Approaching Functional Programming with C# 300 Matt Podwysocki 3EL1

Functional Programming, the Hard Stuff 300 Amanda Laucher 3EL2

Unknown Topic 300 Ted Neward 3EL3
Mobile Application Development Track



Extending the Mobile Experience for Your Existing Website 100 Steve Presley 1MA1

Welcome to the World of Windows Mobile Programming 100 Chris Craft 1MA2

Beginning Compact Framework Development 100 John Baird 1MA3

A Closer Look at Windows Mobile - Using SMS and State and Notifications Broker 200 Lou Vega 2MA1

How to Target Smartphone and PocketPC from a Single Application 200 Craig Dahlinger 2MA2
SharePoint Development Track



Create and Deploy an ASP.NET 2.0/3.5 WebPart for WSS 3.0 100 Robin Edwards 1SP1

Creating your own SharePoint Usage Reports 100 Susan Lennon 1SP2

Integrate ASP.NET Forms-Based Authentication with SharePoint 2007 200 Nas Ali 2SP1

Getting Down and Dirty with SharePoint Branding 200 Michael Lotter 2SP2

Categories: Code Camp | Richmond
Posted by kevin on Saturday, September 20, 2008 12:00 PM
Permalink | Comments (2) | Post RSSRSS comment feed

Richmond Code Camp 2008.2 Open for Business

If you follow my blog, you can see that I haven't been blogging much over the past two weeks. OK, I haven't been blogging at all. I switched jobs and I've been spending every spare moment besides getting ready for Richmond Code Camp 2008.2 on October 4th, 2008. The registration page for the code camp is up and running as well as a 15-minute survey of the presentation tracks. The survey is important to us because it will help to determine the probable popularity of each of the 43 presentations that our speakers have prepared. At the new Learning Technology Center at J. Sargeant Reynolds Community College, we have rooms that will hold as few as 15 attendees, some that will hold 50 and an auditorium for the really popular presentations that will hold hundreds of Code Camp attendees.

Please take 15 minutes to fill out the survey if you plan on attending the Code Camp, OK? And make sure you register early. We have a beautiful new venue with a lot more space that we had before but we also have 35 top notch local and regional speakers coming from 9 states to present to us. Invitations are going out soon to the Greater Richmond Technology Council members and to all of the faculty and staff of the local Virginia Community College System. So, if you plan to attend, don't wait to register.

For those of you who've been encouraging me to restart my posts on Exploring the F# Language, I promise that the next installment is on the way. Thanks for your encouragement.


Posted by kevin on Saturday, September 06, 2008 8:00 PM
Permalink | Comments (2) | Post RSSRSS comment feed

On Quitting Your Job by James Avery

James Avery and I spent some time together at CodeStock this past weekend. He told me that he was tired of doing technology presentations. I entirely understand what he means. Education in the developer community is very important but at some point, you just want to switch gears and talk to your peers about other stuff that's important in our space. We're all geeks, that's for sure, but we need to be savvy business people, too. And that requires just as much peer training and influence.

James floated an idea past me for a presentation he would like to do and I liked it a lot. It's not your average Code Camp faire but I asked James if he would travel up from Raleigh on October 4th to present this session to our Richmond attendees. He agreed to come do it. The session is called "Tune In, Turn On and Quit Your Job" and it goes something like this:

Tune In, Turn On and Quit Your Job by James Avery

"We don't have a lot of time on this earth. We weren't meant to spend it this way. Human beings were not meant to sit in little cubicles staring at computer screens all day, filling out useless forms and listening to eight different bosses drone on about mission statements." - From the Movie Office Space (1999)

Stop working for the man and learn about writing a software product, building a successful web application or becoming an independent consultant.

I can hardly wait to attend this talk. I predict a packed house. I hope James keeps going on this vein and writes his next book on this topic.

James is one of many great regional and local speakers who will be presenting in Richmond at the upcoming Code Camp. Want to learn more about the Richmond Code Camp on October 4, 2008? As of August 11, 2008, we still need a few more speakers. Don't miss your chance to show the central Virginia developer community that you want to contribute your ideas, too. Submit your presentation abstract and bio here.


Posted by kevin on Monday, August 11, 2008 5:45 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Josh Carlisle and His Best Friend Fred

Josh Carlisle spoke to the Richmond .NET User Group this evening on Sharepoint Development for ASP.NET Developers. He was carrying what looked like a flask of vodka with him which made me think, "This is a guy I've got to hang out with." It turned out to be Fred Bottled Water. Unfortunately, I didn't get a picture of Josh with Fred, but here are pics of both of them. Doesn't Josh look unusually happy? He swears it was water of "exceptional purity with a high degree of virginality." Yeah, right.

Josh Carlisle speaks to the Richmond .NET User Group on 7 August 2008

Josh's presentation was very good. He was a bit perplexed near the end because of SharePoint's pesky insistence on treating the term MasterPage differently from MasterPages (plural). Pfft! SharePoint is so picky like that. Anyway, we had a good time and Josh was just great. He really knows his stuff. He's welcome back to Richmond at any time. Maybe I could get him up here for Code Camp on October 4, 2008. We got to see Nas Ali, too, who travelled to Richmond with Josh, I think. Always good to see Nas. He confirmed with me that he will be speaking for us at the upcoming Code Camp. Nas is a good speaker and his talks are not to be missed.

Thanks again Josh for coming to Richmond!


Posted by kevin on Thursday, August 07, 2008 9:45 PM
Permalink | Comments (1) | Post RSSRSS comment feed

July 2008 Richmond Meet and Code Notes

The Richmond Meet and Code Dinner in Richmond tonight was awesome. We had 30+ people turn out. Our key presenter had to cancel at the very last moment but Justin Etheredge stepped up to the plate and pitted his self-proclaimed meager Ruby skills against the barrage of questions from the crowd. Justin did a great job, nascent Ruby skills or not. Harper Trow also presented on the history and current state of Ruby and man, I've so been looking forward to that! Harper was just great. I sure hope he steps out and presents more often. Harper's whole life experience oozes with "I love .NET and I love everything else, too." We need more of that kind of healthy alternative-yet-embracing thinking in the .NET community I believe.

The Meet and Code Dinner format is excellent, in my opinion. I think what Justin is doing is commendable. The goal of his group is to build up the community, not potential sponsors. He's going to be setting up a website and taking donations via PayPal. I am definitely going to support him financially in his effort.

In between two of Justin's sessions, I presented my ProxyGen tool again. This is the same tool that I presented at the last Richmond .NET Code Camp and at the last NOVA .NET Code Camp. Except this time, I focused not on the task of dynamic proxy generation against WSDL contracts but on the use of the ScriptRuntime and ScriptScope classes in Microsoft.Scripting to host a Python or Ruby scripting engine within a C# application. I think I got the brains of the attendees pumping with ideas which is all I was after. I described an application that could be statically typed and early bound, written in C# with a dynamic lower edge that could be scripted from a remote source. People in the crowd started coming up with all sorts of great ideas to implement business logic in dynamic code and inject it. Awesome thinking!

I've attached the latest build of the ProxyGen code below. Here are a couple of screenshots that show how it works. This first screen shot shows running IPY.EXE to execute a Python script to call a SOAP-based web service with no precompiled proxy. The only magic here is in some dynamic code generation that my ProxyForWsdl class does by downloading the WSDL contract and building classes for services, operations and data contracts. As you can see, I am calling an integer factoring service dynamically. No new Python knowledge yet. But read on.

The next screen shot is of the test harness in the sample code showing how a Python script similar to the one shown in IPY.EXE above can be injected into a C# application.

The C# code to embed the Python engine is simpler than you would think. I wrote a little wrapper class to make it easier to digest:

using System.Collections.Generic;
using Microsoft.Scripting;
using Microsoft.Scripting.Hosting;

namespace TestHarness
{
    public class DynEngine
    {
        private readonly ScriptEngine _engine;
        private readonly ScriptScope _scope;

        public DynEngine( string engine )
        {
            // get an engine from the script runtime of
            // the desired type
            _engine = ScriptRuntime.Create().GetEngine(engine);

            // creating a scope gives us a dynamic space
            // to run code in
            _scope = _engine.CreateScope();
        }

        public T ExecuteStatements<T>( string codeText,
            string resultVarName,
            IEnumerable<KeyValuePair<string, object>> scriptVars)
        {
            // inject some variables into the scope
            foreach (var kvp in scriptVars)
                _scope.SetVariable(kvp.Key, kvp.Value);

            // "compile" the code and execute it
            var source = _engine.CreateScriptSourceFromString(
                codeText, SourceCodeKind.Statements);
            source.Execute(_scope);

            // pull a typed variable from the scope as the result
            return _scope.GetVariable<T>(resultVarName);
        }

    }
}

Invoking the Python code is as easy as loading up variables into a dictionary, instantiating my wrapper class with the type "py" for Python and calling ExecuteStatements with the Python source code text:

var vars = new Dictionary<string, object>
           {
              { "url", tbUrl.Text },
              { "ep", ep }
           };

var engine = new DynEngine( "py" );
result = (List<int>)engine.ExecuteStatements<object>(
   tbPythonCode.Text, tbEvaluationExpression.Text, vars );

The HTTP path to the web service WSDL contract is passed as a parameter by injecting it as a script variable named url in the Python script. And the ServiceEndpoint is also injected as a variable named ep so that it's Name property can be selected in the Python script. This is a good example of marshalling a .NET object into the script scope where it can be fully discovered and used by a dynamic language. In the DynEngine class shown above, you can see the SetVariable and GetVariable methods on the ScriptScope being used to inject and extract variables as a type of Inter-Process Communication (IPC) mechanism. This isn't the only way to communicate between a host and a dynamic script but it's simple for illustration purposes.

That's pretty much it. Hosting a dynamic Python in C# is not hard at all. In fact, if I referenced the IronRuby assemblies on the TestHarness project, I could switch the "py" constructor parameter to the DynEngine shown above to "rb" and inject Ruby script just as easily. That's literally all we would have to do to move from Python to Ruby in this case. As we used to say in America in the 1980s, that's tasty!

The ProxyGen code's attached below. Be sure to download the IronPython distribution from CodePlex and reference four (4) assemblies in the TestHarness project. I am using IronPython 2.0 Beta 3, by the way. These are the four (4) IronPython assemblies you'll need to reference:

  • IronPython.dll
  • IronPython.Modules.dll
  • Microsoft.Scripting.dll
  • Microsoft.Scripting.Core.dll

All of them can be found in the root of the IronPython BIN distribution ZIP. Here's the ProxyGen code I demoed at the meeting.

ProxyGen20080731.zip (21.40 kb)


Posted by kevin on Thursday, July 31, 2008 10:18 PM
Permalink | Comments (3) | Post RSSRSS comment feed

News Page for the Richmond Code Camp

I've added a permanent news page for the Richmond .NET Code Camp to my site. It has news and information you'll want if you're a .NET developer in the mid-Atlantic region.

http://www.gotnet.biz/Blog/page/Richmond-NET-Code-Camp-News.aspx

Check it out!


Posted by kevin on Tuesday, July 22, 2008 3:25 PM
Permalink | Comments (3) | Post RSSRSS comment feed

Accessing Web Services from Silverlight 2

I presented tonight (10 July 2008) to the Richmond .NET User Group. We had a pretty good turnout, I'm guessing 40 to 45 developers. I gave this same presentation at my office today as a dry run and as a training opportunity within the company. It's so good to see the developer community eager to learn. I've attached my slides and the three demonstrations projects I used in this post. I'll be giving this same presentation to the Charlottesville .NET User Group next Thursday (17 July 2008). The abstract we put on both user group websites follows:

Silverlight is a client-side technology. So it’s not really a part of your SOA strategy, right? You may want to think twice about that. SOAP and WSDL support are coming to the web desktop via Silverlight. And Silverlight has good client support for REST+ JSON/POX and RSS/ATOM-based web services, too. During this discussion, we’ll dive into data serialization, security and cross-domain access policy capabilities inside Silverlight 2 Beta 2. We also talk about the nuances and pitfalls of provisioning your web services for an Internet audience. This presentation will be heavy on coding, demonstration and interactive discussion.

Powerpoint Presentation (289KB)

Twitter solution showing how to invoke a cross-domain RESTful service by way of an in-domain SOAP service bypassing the cross-domain access policy problem. (842KB)

REST solution showing how to create RESTful services in WCF and how to consume RESTful services in Silverlight (307KB)

Silverlight syndication solution showing how to consume cross-domain RSS and Atom feeds using the SyndicationFeed class. (11KB)


Posted by kevin on Thursday, July 10, 2008 10:39 PM
Permalink | Comments (3) | Post RSSRSS comment feed

SQL Roundtable Discussion with Andy, Ron and Mark

If you are in central Virginia today (12 June 2008), be sure to join Andy Leonard, Ron Deskins, Mark Hudson and me for a roundtable discussion about SQL server. Andy, Ron and Mark are all great community leaders and they happen to be excellent SQL database architects. This will be a fun and informative meeting. Be sure to register using the link below. Here are the details:

When: Thursday, June 12th, 2008, 6:30 PM - 8:00 PM
Social Time starts at 6:00 PM!

Who: Everyone! In particular Andy, Ron, and Mark.

What: This is going to be round table discussion facilitated by Andy Leonard, Ron Deskins, and Mark Hudson.  The topic is SQL Server, but other than that it is wide open.  Please post your comments to the board so we can get a lively discussion going at the meeting!  

Where:
Location: Markel Plaza
4600 Cox Road
Glen Allen, VA 23060 [map]

Register: Click here to register!


Posted by kevin on Thursday, June 12, 2008 8:10 AM
Permalink | Comments (0) | Post RSSRSS comment feed