Posts archived in .NET

Today I spent about half an hour banging my head against this problem:
Whenever I would try and return a business object, I’d simply get no response from my WCF Service. Litterally nothing.

The problem turned out to be that I had accidentally specified the DataMember Name of a property in a sub object twice.

So, I had my broken class set up like:


[DataContract(Name = "MyClass", Namespace = "Example")]
public partial class MyClass
{
[DataMember(Name = "property1")] public int Property1 { get; set; }
[DataMember(Name = "property1")] public string Property2{ get; set; }
}

An instance of this class was used as a property in another object, which was being returned from WCF.

.NET didn’t throw any sort of error unless I tried to return just “MyClass”.

Sure, it was my fault, but if you have a complex data structure, this could get awefully difficult to find without some sort of message from WCF.

Yes, this is part of that ultra nifty WCF JSON .NET 3.5 Flex project at work. :)

(A note to readers: This is all pure geek/coder content – Please skip this if nothing in the subject line makes sense)

I started on a new project at work for a client a bit over a week ago, by virtue of the requirements, we decided to investigate the use of new version of Microsoft’s  .NET Framework, Version 3.5, for all of the server-side services.

Microsoft have been quite strongly pushing the benefits of the new features of .NET 3.5. There’s been a few key features which are particularly interesting, and if all goes according to the marketing hype, should end up saving a huge amount of time and effort, whilst ensuring that we use well known and standardised interfaces.

What features?

Windows Communications Foundation (WCF) is particularly interesting because it promises to let you (mostly) remove the whole ‘how’ and ‘where’ portion of communications between tiers, and let you focus on the ‘what’ and ‘when’.

In essence, WCF should let me state that I want to create (say) a Web Service, that accepts information in format X, and outputs responses in some other format. It doesn’t have to be a Web Service either, it could be a Peer to Peer network speaking in straight binary streams.

For this project the client-functionality is all in Flex, so we need to ensure that the Flex guys can quickly decode all the responses and turn them into Action Script objects. Through a bit of experimenting and application prior experience – Web Services speaking JSON appeared to be the easiest and most light weight method of doing this.

Language Integrated Queries (LINQ) is another particularly interesting technology, particularly because it lets me focus on what I want to do with the data I have, rather than spending time transforming it from the Database tables, rows, and procedures, into .NET objects and methods.

There are a number of implementations of LINQ, which enables you to query a variety of sources – the one that I’m most likely to use is LINQ to SQL (talking to SQL Server). Regardless of what I’m accessing however, the syntax is identical – again, removing the need to modify my code if I need to query an XML file, Oracle or MySQL Database, or even native .NET objects.

You can probably see a common theme here – WCF lets me focus on communication with the outside world without needing to write that interface or conversion functionality, and LINQ lets me access and manipulate data, without needing to write that interface either.

So, it’s all plug and play?

Well, that depends entirely on what you’re doing with your data. If you’ve got something like a CRM application where the client is responsible for managing (most of) the data, then yes it can quite possibly be almost plug and play if you’re going with a “CRUD” interface.

If your data structure is more complex, then you need to determine exactly where the split is. In this specific project, I’m presenting an abstracted view of the data that the client needs, and doing all of the business logic to manage data management in the SQL and Web Services Layer.

So far, the whole WCF and LINQ combination looks good. I’m hoping to post some more detailed posts later on.

Further Reading

I highly recommend Scott Guthrie’s LINQ to SQL series of posts. Start with Part 1: Introduction to LINQ to SQL

These resources have also been of a great help in getting my head around the whole LINQ thing:

Those following me on Twitter have had the joy of seeing random messages about the ongoing issues I’ve had getting my ADSL2+ connected.

Since the last post on this (on the 13th of Feb) I basicly gave up on calling iiNet – I’d already spent a fortune in mobile costs listening to their hold music, and was just waiting for them to get back to my support-enquiry email. (I never did get a response to that)

However, last Friday (22nd) as I was going to bed at about 1:30am (Okay, so technically Saturday morning) I noticed that my DSL Router was saying it had sync. I normally check the router panel when I get home, so I must’ve missed it that night. I stayed up about an hour setting up a bunch of tests to see how fast/stable the connection was. I left these tests to continue running whilst I slept. When I left home on Saturday at about 9AM it was still running, and I was feeling somewhat optimistic that it might continue to work. Of course, Murphy was listening, and when I got home at around 5pm, I had lost line sync once again.

Sunday I called iiNet again, this time because their Toolbox said there should only be about a 7min wait. The tech guy tried a few things from their end, but once again no success – and said he’d put the request through to their Fault Manager who would try to get VisionStream to narrow down the timeframe.

Come Monday morning, I get a call from Christy at Vision Stream, “Is Wednesday suitable for you?”. Grr. Same situation as last time Christy called me! Looking at the iiNet Toolbox – what do you know, a 45min or so wait on hold, again. Instead of doing that, I try another tact – go straight to the top.

So, I write a pleading email to Michael Malone, the Managing Director of iiNet. He’s quite active on Whirlpool’s forums, and makes his email available there. I give a bunch of possible ways we could try and work together, such as asking for the first/last timeslot on the day, getting a call an hour or two beforehand, and even offering to pay for a Saturday callout if necessary.

Tuesday I get a call from Rebecca at iiNet regarding the email, she’s called VisionStrem and tried getting them to go with any of the options I presented – no luck. I think up one last option – asking the Tech to call me as he’s starting the job before mine. Rebecca thinks it might work, and goes back to VisionStream.

Today, (Wednesday) Rebecca calls back – VisionStream won’t go for it, despite having escalated it up the chain of management there. Apparently VisionStream started quoting sections of the Telecommunications Act to her, and stating that “we treat all customers equally”. However, the VisionStream manager has agreed to commit to a particular timeslot (9AM-12:30PM or 12PM to 6PM), AND to get the Tech to call an hour beforehand.

I ask Rebecca what the chances are of switching to a regular ADSL2 service (and having the line connected as a standard phone again) – apparently it can be done, but I’d be the first to have tried it. And the time it would take would probably be somewhere up around a month, assuming everything went according to play.

So, for now Rebecca is sending the case back to VisionStream, and getting them to commit to providing a 9AM-12:30PM timeslot for this job plus the hour-before call.

Here’s hoping that VisionStream can come through on this!

Side Rant:
VisionStream’s comment to Rebecca that they treat all customers equally, is rather stupid. Yes, they treat all customers equally poorly. VisionStream’s view is apparently that All customers’ time is worth nothing, and they obviously have nothing better to do.

Surely someone at VisionStream can see that doing this just gives them a really poor reputation.

0 comments

Killing with Kindness

We killed Twitter, again.

This time it was from an excess of Love – Of the less-than-three (“<3") variety.

My screen was filled with hundreds of messages like these two:
Less than Three’s for everyone.

For the non-Twitter’ers out there, the Twitter folks added a way to send a special type of tweet. By entering “@username <3" - it would transform the ordinary tweet, into this special type of message.

It also results in that person getting a "Do you love (sender)?" prompt, with a button to quickly reply.

This novelty, combined with the easy reply, lead to a major increase in the number of Tweets for valentines day, and thus Twitter slowing down / refusing to respond for many people (including me).

Edit: Here's a better screenshot of what was/is going on (read from bottom up)

Less than 3 (more)

Someone asked me recently what my opinion of Dreamhost was. They knew I use Dreamhost for a variety of sites, and were looking to sign up.

The short answer is that Dreamhost are “variable”.

I’ve been a Dreamhost customer for about 3 years now, and I’ve seen some pretty wild thing happen.

They’ve had several major power outages which took down their entire datacentre. They’ve had significant network issues for a period of months. They had a major data security breach where someone managed to get several thousand usernames and passwords. And, to top it all off – they recently overcharged about half of their customers by several million US peso dollars. (It would have been up around 10 million, if it wern’t for a bug in their software).

Oh, and it’s probably worth mentioning that as I write this, all my sites are down, because the servers they’re on are being driven from one side of LA to the other.

Given all of the above, most ordinary, sane people would probably be shouting “run for the hills!” at the top of their lungs. And, in many cases people would be  quite justified to run as far as they could from Dreamhost.

Here’s the thing, however – apart from the power issues (and the scheduled cluster move mentioned) my sites have worked just fine for the most part. 

Yeah, there’s been times when a server has been down, or when some sort of glitch has slowed things down – but lets look at the big picture here for a second.

Dreamhost’s business is to sell reasonable quality webhosting, with large gobs of disk space and bandwidth, at a very cheap rate.  I pay something like USD$20/month (on the old plans) for my Dreamhost service. 

What do I get for that USD$20/month?  I get to host 30-something sites, occupying 20GB of disk space, and transferring about 150GB per month. No, that’s not the limit, that’s what I’m actually using. This month. Dreamhost have absolutely no issue with me using a lot more than that – even if I went to TWENTY times that, I’d still be well under the limits of my account.

I also get the security that someone else will take care of the servers, and keep them patched and secure. In the event that something goes wrong, I can lodge a ticket and have someone else fix it at 3am.

So, does that mean I’d recommend Dreamhost to everyone? Heck no – there’s heaps of situations where I wouldn’t recommend Dreamhost.

Any time you answer “yes” or even “maybe” to the question “Will this being unavailable impact my business?”, you need to be looking at a managed hosting solution with a proper contract/service level agreement.  Don’t pass go, don’t collect $200, and definitely don’t try reselling this to your customers.

Dreamhost are also not suitable for a variety of “big” applications/sites – despite the label saying you can get 5TB of bandwidth and 500GB of disk space, actually using all of it is possible only under very specific conditions. Most of the time, anyone running a site that is that popular is going to be using so much of the resources on their server that they’re going to be causing issues for other users on the same server.

It’s like the speedo on your car, if you’re actually hitting 240KPH or 30,000RPM, something is going very very wrong, or is about to.

So, with that out of the way – I am actually starting to look for some dedicated server options – not because I don’t like Dreamhost (I do) – but simply because I want to do other things that I simply can’t do with Dreamhost.

My options are limited, because I want to be able to manage the server myself, I need a reasonably large amount of disk space and bandwidth quota, and I need to run Windows.

What are your experiences with Dreamhost, and/or dedicated hosting?

I’ve been frustrated for a while trying to use various products and services. I thought I’d compress all of them into a single post.

Click through to read this collection of rantings…

Read the rest of this entry »

For over five years, I’ve held a bit of an open secret: I’m an alien from fluidic space.

Err, wait, let me start that again.

For over five years, I’ve been working for Telstra. I started off “on the phones”, working in a service call centre. Due to me being a smart-ass (and critical of some very inefficient systems) I was taken off the phones after about two weeks, to write some reporting tools.

From that first app in Excel 97 using VBA to generate charts, I converted to a full-time employee, and went on to bigger and better things. When I wrote that there’s a reasonably good chance of my code having touched your life in some subtle way, I wasn’t joking. The software I wrote helps people in Telstra do their jobs: Routing messages, generating reports, storing data, and keeping an eye on other applications.
I’m proud of the work I’ve done, despite it not being world changing or highly visible. Sure there’s some icky bits (VBA, Oracle, MS Access, Classic ASP), but overall I hope that it’s made people’s lives better, and/or their jobs easier, in some small way.

Today, I resigned from my position at Telstra. It’s not something I did lightly, but, after consideration I’ve decided I need to move on.

For those that are curious, I’m not going to be unemployed – Today I’ve also accepted a contract role to a digital media company in Sydney. I won’t say who, yet, until I’ve had a chance to speak with them some more, but suffice to say it looks like a great company to work for, doing interesting things and meeting interesting people.

Oh, and yes, this means that I’ll be moving from Newcastle / Toronto. I’m still at Telstra until the 26th of October and then I’ll be off to Sydney and new things.

I’d also like to throw a quick shout-out to Nick Hodge for putting in a good word for me, and listening to me rant a little about work; Jack Greenrich for plenty of coding advice and guidance; Ian Ward for getting me hired at Telstra and started down the software development path; and both Markus Hafner and Greg Dwyer of Happener Recruitment for helping me to get this new position.

Exciting times ahead, for sure…

Last weekend I installed Windows Mobile Device Centre, and it asked me if I’d like to download some additional updates/applications.  I said yes, and was asked to create an account and fill in a survey about where and when I got my Windows Mobile powered device. 

Obviously Microsoft’s improved their user tracking technology, and know I’m actually a time-lord in human form (Those Chameleon Arches are really something!).  

microsoft-2015

For those wondering why Microsoft chose to stop at 2015? Well, lets just say that after the great Mobile Device Wars between the Googlites and Microsoftians, many lives and OSs were lost.

PS: WTB, 1x [ TARDIS ]  Pref. with Chameleon Circuit active. You know where to contact me.

I’m currently working away on improving Smitter R3, and part of that is improving the way proxies are handled.

Currently, there’s four situations it supports quite fine:

- No Proxy
- Proxy, without Authentication
- Proxy, with BASIC Authentication (using specified username/password)
- Proxy, with NTLM Authentication using your current Windows Account (aka Windows Integrated Authentication).

The problem comes you’re in this fifth situation:
- Proxy, with NTLM Authentication using a specified username, password and domain.

Initially, I was using code like:

WebClient client = new WebClient(url);
client.Proxy = new WebProxy(proxyurl, true);
// if proxy-auth required:
client.Proxy.Credentials = new NetworkCredential(proxyusername, proxypassword, domain);
// ...etc

But, this fails with “407 Proxy Authentication Required”
The crazy part is that it actually is doing NTLM authentication, but it appears to be attached in the headers for twitter.com (!?).

So, I tried using WebRequest, and also HttpWebRequest and specifying proxy-keep-alive.
I also tried setting the .NET Default proxy to my specified proxy or just adding authentication credentials.
But, still nothing appears to be working.

Almost all the solutions online are using the DefaultCredentialCache – but that really doesn’t help (I tried), because I’m not logged in as the user that I want to authenticate as. Cretaing a new CredentialCache and adding the details to that – still no help.

All in all, very frustrated!

If you want to have a crack at solving it – download the SmitterR2 source and check out Smitter.Core.TwitterService.GetStatuses (in SmitterClasses\SmitterCore.cs).

There’s currently a line like:
using (WebClient client = BuildWebClient())
Ignore/remove it and create your own WebClient/WebRequest/etc to test on. That’s the first (network) function called when Smitter starts up, and is pretty quick to return a result one way or another.

Just make sure you’re using a proxy which requires NTLM / Kerberos Auth, and isn’t on the same domain as your current account. Any other situation seems to work A-OK.

If you can solve this, I’d be much in your debt.

4 comments

Smitter R2

Smitter, Release 2  is out now.

Changes

  • Better error handling (please report any bugs)
  • Proxy Support
    (NB: ClickOnce deployment may not work with Proxies requiring authentication!)
  • More efficient posting (no refresh necessary)

Requirements

  • Microsoft .NET Framework 2.0

Installation

ClickOnce Notes (updated!)

  • By Default, only works with Internet Explorer 6 and above, with the .NET Framework 2.0 installed
  • Does not work correctly if you have Internet Explorer configured to use a proxy requiring Authentication (eg: Corporate Firewalls)
  • Firefox users can run ClickOnce applications by installing the FFClickOnce addon, and then going to the normal installation page.

Upgrades

Source Code:

Application and Source Code Licence

 Creative Commons License
This work is licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License

Please give your feedback in the comments, or add me on Twitter.

Features Confirmed for R3 (updated)

  • Minimise to Notification Icon (“System Tray”)
  • smitterPopupBalloon Notifications (optional)
    If Smitter is minimised or not visible, and your @Username is mentioned in a new tweet. 
     
    Note:  To deploy the above two features, I need an icon for Smitter.  On the screen-shot above, I am using an icon borrowed from Iconfactory’s Twitterific client icon in the   Litho Extras Volume 5 collection.   Due to licensing rules, I can’t distribute this icon, so it’ll remain for internal testing at the moment
  • Minor bug fixing (removal of the “Loading” messages if it errors, and fixing of the hammer-prevention so that it allows you to refresh)
  • More?