You are currently browsing the tag archive for the ‘Enterprise Library’ tag.

I’ve been working with WCF a fair bit lately, and frankly it’s mostly been a breeze. I did run into two head scratchers that I thought I would document since I had a hard time finding a straight answer on the intertube.

The first one has to do with WCF and Microsoft Enterprise Library. If you don’t know what Microsoft Enterprise Library is, it’s basically a collection of code that everybody keeps writing over and over again. Stuff like logging, error handling and database connectivity. If you needed that explanation, then you should quit reading this and go download it. Seriously, this blog will still be here when you get back.

Got it installed? Skimmed the documentation? Good, now you can stopwriting all that code that everybody gets almost right and go back to doing useful work.

So, using the logging block with WCF is fairly straight forward. Just make sure whatever process your service is running under has access to the db, and to the stored procs. I know, I’m an idiot. Of course it will need access to the stored procs. No, giving it access to the tables won’t magically give that login access to the stored procs. I know it’s stupid, but when I was trying to find out why my logging wasn’t working I saw the same question over and over again, and never saw an answer.

Just so you don’t have to look it up, if you ran the standard sql script to add the table and stored procs, then the stored procs are named: AddCategory, ClearLogs, InsertCategoryLog and WriteLog.

The other big, bone headed gotcha I ran into was during integration testing. For some reason, none of the changes I made to the service to fix things seemed to take effect. I restarted the service, I restarted the server, I restarted the computer. I stepped through the tests, I attached a debugger to the service and could never get it to hit a break point. I stopped the damned web service, and still my tests kept coming back with the same results. After reconfiguring the web service reference and making sure it was pointing at localhost (where I was testing) I still couldn’t get a breakpoint to hit, or see any of my changes taking effect in the code.

Yeah, you’ve already figured it out. The web service reference was pointing to the wrong box. Well, to be more accurate, the settings for the web service reference in the app.config for the tests were pointing to the wrong box. Even though the configuration for the web service reference said it was pointing to localhost, a quick look in the app.config showed that it was pointing to the box of another team member who had also been working on this web service.

If you point the web service reference to localhost, visual studio is “smart” and goes behind your back and inserts the actual machine name in there. I changed all the references in app.config to localhost as well, and suddenly all the changes I had made started working. Amazing! It only took me two hours of beating my head against the desk to figure that out.

Hopefully, the spiders find this entry and keep you from having to do the same.

If you liked this, check my other posts at my new site http://www.steverb.com.

Advertisements