Jason's Infrequent Ramblings

work,play,programming.

.Net Stuff : StructureMap

Update: Code blocks look screwed up, sorry...

I'm always learning new things. When it comes to software development, I never seem to stop learning, and certainly wouldn't claim to be the greatest or anything. One of the recent things I have learnt is an intro to Inversion Of Control and Dependency Injection. I'm just scratching the surface of this thing, but the benefits are great so far.
Let me explain slightly...

Read the rest of this post »

Filed under  //   .net   c#   code   programming  

Tag And Release

Dscf3942

No, I'm not talking about fishing or birds.

I'm talking about tracking versions of software each time you release.
This should be common practice for any developer releasing code. But
you never know, might be some students or naive ones reading. I
certainly wasn't thought it in college!

Version control is a great tool for development. I'm partial to Subversion
(svn) myself, but they concepts are similar in all of them. The main
benefit of using something like svn is that it allows a team to work
on documents and code at the same without the risk of over writing
changes a colleague made. With people making frequent commits of
changes back into the version control system, almost nothing is ever
lost.

But it's not all about losing stuff, it's also about finding stuff. An
active project under a develop-release cycle can change very quickly
from day to day. One can run the risk of serious headaches if they
don't keep track of what code is where. What you don't want to end up
doing is reaching a point where you deployed a project say, on a
Monday, and your team keeps working away. A week later, a bug is found
in the version you put out. Patching might not be so simple if the
code base your working on has changed too much since the release.
You're caught between 2 points. you can't release the current code you
are working on, perhaps there are incomplete features, or new bugs at
testing haven't found yet.

By tagging the code, you are creating a copy of the code at the exact
moment of release. That copy never changes. Even if you get caught out
later, you can go back to that copy, fix just the bug, release and
make a new copy.

A very simple technique, but one that I hope every one is using.

Filed under  //   .net   owl   programming   software development  

I added a facebook "Like" button to my blog

And it only took 2 minutes.

Filed under  //   programming  

Migrating to Azure

A friend pointed me to this blog by a lad in a company called Assembly
Point about migrating a .net web application to Azure
http://www.assemblypoint.com/blog/elliot/

It's interesting to see someone record the issues they hit as they go.
Azure seems like interesting tech, and I find myself heading back to
check out the product pages every now and then.

Filed under  //   .net   programming  

.Net : Reusing Types Across Multiple WebServices (using svcutil.exe)

For a long time I had an issue. I had a server .net project that had
multiple .asmx web services in it. In the server project, these
different services shared and returned various types: for example
Product. Just say we have Service1.asmx and Service2.asmx

When consuming these in another solution by adding a service reference
in VS2008, The problem was that Visual Studio was creating a name
space and types for each service, and not reusing them, so you'd end
up with the classes

MyNamespace.Service1.Product
MyNamespace.Service2.Product

and Soap clients like

MyNamespace.Service1.Service1SoapClient
MyNamespace.Service2.Service2SoapClient


Which was annoying, as you would have to be sure to create the correct
type of product object depending on what service you were about to
use. What I wanted was

SomeNamespace.API.Product
SomeNamespace.API.Service1SoapClient
SomeNamespace.API.Service2SoapClient


Turning to google, I found many suggestions to add a dll with the
orginal type to the project, and that the services would reuse this
type. They didn't. I found tip after tip referring to WCF, or
DataContact and various attributes, but that didn't work either.

I fould suggestions to use commands like :

svcutil /r:servertypes.dll /out:Service1.cs http://localhost/Service1.asmx
svcutil /r:servertypes.dll /out:Service2.cs http://localhost/Service2.asmx

which would reuse types. It didn't. I'm putting it down to not using
WCF on the server, but that's out of my hands.

But I figured it out. And the answer is fairly simple.

svcutil http://localhost/Service1.asmx http://localhost/Service2.asmx
/out:api.cs /namespace:*,SomeNamespace.API

Now, when the code is generated, you'll get a error that Product is
already defined, but it's more of a warning. But because the output is
combined, it works! Unlike calling it once for each service. Perhaps
I'll look at newer solutions for newer projects, but thankfully, the
annoyance is less for now.

Filed under  //   .net   c#   csharp   programming   svcutil   web services