PAGES

  • My Twitter Feed

    • No Tweets Available

24

May 11

Debugging partial classes for WCF proxy classes



This is one of those posts that I’m partially putting up here so I don’t forget this later.

I’m currently working on a data integration project that involves the basic process of sending and retrieving data from a third party web service.  When retrieving data, the Service Reference creates proxy classes for the objects being returned.  So far, nothing special.

Before using this data, I needed a clean way to turn the web service objects into my own business objects so that I can manipulate and save the data using our normal application business/data layer code.  One of our partners, Jerry Brunning, suggested partial classes would be a good approach for this and it worked great.  Basically  I just have a partial class for each web service data object I’m consuming and they typical have one method: ToMyBusinessObject, although there are some helper classes scattered in there as well.  So far, still a pretty typical way to do it.

The problem came when I started debugging and needed to step into the partial classes to make sure my mappings were working properly.  I would be stepping through my consuming code just fine and then all of a sudden the next use of F10 or F11 resulted in skipping whole chunks of my partial class code. The debugger would stop if there was a breakpoint in the partial class.  Baffling behavior.

I thought my development environment had gotten messed up, so I messed with some settings and other stuff.  Tried on someone else’s computer, but same behavior.  About that time, Mike Frank suggested checking the attributes of the automatically generated code in the Service Reference classes, specifically the Reference.cs file.  Sure enough,there was an attribute on each class that looked worth checking,the System.Diagnostics.DebuggerStepThroughAttribute.  When I looked it up, the purpose of this attribute is “Instructs the debugger to step through the code instead of stepping into the code”.  I guess I get why Microsoft decided this should be the default for IDE generated code, but it certainly wasn’t very discoverable.  You also can’t put a different attribute on your partial class, so the only way around it is to edit the generated code and remove the attribute.  And you have to remember to do this every time you update your service reference.  Still, since this is really only something you need during development for the most part, it’s not too bad.  Just hard to diagnose.

Comments Off , permalink


27

Jan 11

Playing around with Orchard CMS



Had a little time today, so I decided to check out some of the new stuff that’s been coming out in the Microsoft web space lately.  Was going to play around with the Razor view engine in MVC3 a little (and probably still will), but got sidetracked checking out Orchard.

Orchard is a free, open source (BDS license) CMS.  Really more of a content framework or a way to build simple web sites quickly.  It uses the typical modules/themes/widgets approach made popular by both simple and complex CMS platforms as well as blogging platforms like WordPress.  There are Microsoft people involved, but it’s not an official Microsoft product, at least not a supported one.

Here are just some random thoughts after less than a day of playing around with it.

  • Installation process is nice.  I installed using the Web Platform Installer and was pretty much up and running almost as soon as the installer finished.
  • The setup screen reminds me of a WordPress type experience, you really just create an admin account and decide on database options and you’re good to go.
  • You can use SQL Server Compact or choose the full SQL Server stack to run on.  I chose Sql Server Compact just because I want to play with it a bit.  I think there are some people already trying to get this running on MySql or maybe they have already.
  • They have been working on this for awhile, but it just went to version 1.0 and is seeing a lot more interest.  There is a gallery with modules and themes available.  There aren’t a ton of options, like you might expect, but there are a lot more than I expected there to be.
  • Source is available.  I downloaded and was able to compile in VS 2010 without a problem.  It took a bit to figure out how to debug since I have it running under IIS Express.  Nothing like trying 5 new things at once.  In the end I was just able to attach to IIS Express and then the debugging experience was normal.  Hint – it helps to make sure your IIS Express site is pointing at your source directory, not the standard Orchard download directory.  Duh.
  • We have some great Sharepoint experts here, but I’m not one of them.  So I was curious how hard it would be to jump into this and get the gist of how to configure stuff.  This is a much simpler product,but pretty intuitive even if you haven’t worked a lot with CMS platforms.  I already understood the basic concepts,but even if you don’t it doesn’t seem like it would be hard to figure this out.  I think it could be great for people who want their own web site that is more than just a blog.  There are probably even some corporate applications for situations where the full power of Sharepoint is overkill.

That’s just some first impressions.  I haven’t really looked into the code a whole lot yet.  Or figured out how hard it is to create my own theme.  Or even tried all the configuration options.  But I know more than I did this morning.

Comments Off , permalink


16

Jan 11

What’s up with HTML 5?



One of the consequences of being on a project for a few years is that you tend to get really good at the specific technologies needed to write the best applications for that project.  And you tend to miss out on some other stuff, unless you want to spend all your weekends keeping up.  There’s nothing wrong with that, but I find that hard to do consistently.  So I wanted to check out some of the new web development technologies coming down the pike and I thought I’d start with Html 5.  Html 5 often seems to be poorly defined or mean different things to different people.  The spec is kind of like that.  It builds on everything that has come before, adds or standardizes some stuff that at least one browser was already doing and in general tries to make certain things about developing modern web applications easier.  I’m not going to go into the standards history here as it’s pretty easy to find that to read about, but I would encourage you to read up on it as it is a rather interesting story.

I grabbed 2 fairly short Html 5 books to read through.  There is also plenty of information online, but sometimes I just want to read through a book on my commutes to and from work.  It allows me to focus in and really get a sense of the whole picture.  So I’ve read through Introducing HTML5 (Voices That Matter) by Bruce Lawson and Remy Sharp and I”m currently reading through HTML5: Up and Running by Mark Pilgrim.  Both books cover much the same territory and give you just enough information to get a sense of the new technologies.  Neither takes long to read.  The nice thing that both books try to do is give you ways to start using these technologies now.

Now my friends on the design team at Clarity are most interested in stuff like the Canvas and some of the SVG graphics support.  I think that stuff is cool, but I’m a web applications developer, not a designer.  So I’m really more interested in what is going to help me write applications that work better for the user, are easier to maintain and most importantly, make my job easier.  Given those parameters, here are some quick hit features and tips that I’m most interested in:

  • Better semantic markup: Finally it’s going to be easier to say this is the header,this is the footer,this is navigation content and so forth.  The concept of headers (H1, H2, etc.) can also be contained with a section element or article element. This sounds like nothing major, but it allows true outlining of content and makes browsing way easier for users with disabilities.  In practical terms, this means you can have a main header H1 for the page, each section of the page can have a header that is also an H1, your blog post or article header can be an H1 and so forth.  And all those H1s actually have semantic meaning based on their position within other elements.

    You can start using the new tags now, but there is one big caveat.  If you want to apply CSS styles to them (which you will so older browsers know what to do with them), you can’t in IE versions earlier than 9 without some extra javascript voodoo.  Basically you have to define one instance of the new tag in the header using javascript. Fortunately Remy Sharp has written a nice little javascript function to do this for you and you can even just reference it in your header

    <!–[if lt IE 9]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"> </script> <![endif]—->
  • HTML5 Storage: This one is interesting to me because there are always good uses for local protected persistent storage in the browser for a particular domain.  Cookies are problematic for a lot of reasons, not least that they are added to the header of every HTTP request.  This feature is actually fairly well-supported in all modern browsers.  It’s basically up to 5MB of storage of name/value pairs of the developers choosing.  This data is never transmitted to the remote web server at all, so it is pretty much a client-side technology, but I can still think of all kinds of uses for this.
  • New form elements: This one is going to eventually make developing web forms both much easier and way more consistent across applications.  There are a bunch of new ones, including input type of number (with min, max, step, etc.), input type of email address or url, date pickers (including the ability to pick a month, a week), input type of search (tells the browser which textbox is for search and allows browsers to add some extra features to the textbox, like clear).  The nice thing about these new types is they degrade just fine in older browsers, but you will have to fall back on your own code for UI and validation (or just keep using what you already have).  But you can start getting the benefits on some browsers immediately, including mobile browsers like the IPhone.

    Here is a good page with full explanations and examples: A Form of Madness: Dive Into HTML 5

  • Web Workers: basically a standardized way to run background javascript on a separate thread to avoid locking up the rest of the UI.  should be pretty helpful in more advanced AJAX and web service call situations.

There is a lot of other stuff of course, but these were some things I found interesting.  One tip that I think I will end up using right away is a little open source javascript library called Modernizr, that wraps up detection of most of the new HTML 5 features, including stuff like Canvas functionality.  This provides a nice consistent way to check for the new features and use them if the user’s browser supports it and otherwise do something different.

The main takeaway I got from these books is that I can start migrating some of the new features into my web applications now.  No need to wait on a lot of this stuff.  And there are some pretty compelling reasons to move ahead for some of these features, particularly in scenarios where you can lock in a particular browser (such as internal or intranet applications).

1 comment , permalink


7

Jan 11

Migrating Clarity Blogs to WordPress



After quite a long time using Community Server, we decided to look for a different option. There were a number of reasons. We have been running on Community Server 2007 for a couple of years now and the latest products from Telligent weren’t really going in the direction we wanted. We were also looking for something with a lot of community support and relatively easy way to customize. Even though we all write code, we would all rather spend time writing blog posts than customizing our blog engine. WordPress offers a rich user community with hundreds of plug-ins to choose from and relatively easy theme support. We are mainly a Microsoft shop though, so many of us aren’t as comfortable with PHP and MySql as we are with ASP.NET and Microsoft Sql Server. When we found out about a group at Microsoft that had gotten WordPress working on Sql Server, we decided to take the plunge.

It wasn’t super hard to get WordPress up and running. The regular WordPress branch boasts a 5 minute install and they aren’t kidding. It took a little more time to get the Sql Server branch working, but that was mainly figuring out which build to use and that sort of thing.

The harder part was migrating a ton of content from Community Server. Fortunately some brave souls had gone before and I found some good blog posts on how to do it. I still found the process to be rather tricky and it required a lot of trial and error. The best approach seems to be using the standard BlogML format, which WordPress DOES NOT support natively as an import format. I ended up using Keyvan Nayyeri’s Community Server 2007 BlogML converter code. It didn’t quite work for all of our posts out of the box, mostly due to a lot of code samples and that sort of thing, but fortunately he provided the source code and with a few minor tweaks I was able to get it working for 99% of posts. This converter exports all posts and comments for a particular blog, including author information.

Once I had that working, I was able to use the great instructions from Aaron Lerch, who wrote a WordPress BlogML import module. I ended up using the revised version from Rob Walling, who also has a great post describing his blog migration. Thanks to all these developers for building these tools and providing insight into their experiences.

Once the basic process was figured out, it was basically just a matter of setting up WordPress. This took a decent amount of time because a) we have a lot of bloggers and b) I didn’t know much at all about WordPress when I started. Like I said before, there are so many people using the platform that you can find information on almost anything, including the best plug-ins to use or how to do various administrative tasks. We also had to figure out how we wanted to structure things from a navigation standpoint. We have a mix of a main Clarity blog along with some individual blogs for more prolific bloggers.

Special thanks to John Regan from our design team for doing a lot of work on our custom theme. Michael Greenlee also provided some PHP and WordPress knowledge when I was lacking, which was often.

Comments Off , permalink


7

May 09

Web Platform Installer Review



Earlier this year Microsoft released the Web Platform installer, currently available in version 1 or as a version 2 beta. I”ve been playing around with it for a few days and I think it is generally a step in the right direction.  If you are doing web development on the Microsoft platform, it”s well worth it to install this on any development machines you are using.

It”s basically a “one stop shopping” to download and configure all the various pieces of software you might want on a Microsoft web development machine.  With frameworks, IIS extensions, beta tools and sample applications seemingly appearing from every direction lately, this tool gives you a great way to keep track of everything, including what you already have installed and how it is configured.

Although it works great as a basic way to pave your machine with the standard tools in production release, another nice plus is the ability to see all the peripheral tools and features the various groups are developing.  Some are in beta or various stages of RC, but I definitely immediately saw some stuff that looked interesting that I was previously unaware of.

One such tool is the IIS Database Manager plug-in, which allows you to do basic management of SQL Servers referenced by your web.config file.  The tool is extensible, which means support for non SQL Server databases is possible in the future.  The tool uses some of the objects/assemblies from SQL Server 2008 and the Web Platform Installer will download and install any of those bits you need to get the Database Manager up and running.  This tool is currently in Release Candidate status and more information can be found in the IIS forums.

Here are a couple of screenshots from my local machine connecting to a database up on the hosting site where I have my personal site.

IIS_DatabaseManager

Database Manager as it appears in IIS Manager

TableData

Looking at data from the Book table in my database

TableDefine

You can even edit table definitions.

Pretty versatile tool, particularly if you just need to make some quick adjustments or if the right ports aren”t open to use Sql Management Studio.

Comments Off , permalink


7

Oct 08

Commerce Server 2007 MSDTC errors and NetBios



So i”m working on an e-Commerce project with Commerce Server 2007 and we had one developer machine that was having issues with the MSDTC transactions used by the pipelines. We took a look at all the obvious stuff like the DTC settings on each machine, turning off the local firewall (at least for development) and so on. We couldn”t really find any differences between my working machine and the problem machine. We are running SQL Server on a remote box, so obviously the distributed transactions get a bit more complex than when everything runs on the same machine.

One thing that gets mentioned when talking about MSDTC, RPC calls and remoting is the NetBios name resolution. So I decided to see if the SQL Server machine could ping the problem machine by name. Sure enough, it worked fine for my machine and another development machine, but failed to resolve and ping successfully to the problem machine. Turns out there was a duplicate computer name on the network. I think the DTC on the SQL Server was trying to bind back to the other machine with the same name (different IP address obviously) and failing. A name change on the development machine took care of the problem. Not sure how often people might run into this, but we couldn”t find anything in the forums or blogs that mentioned this as a trouble-shooting step. So just in case this helps someone else…

Comments Off , permalink


27

Apr 08

Digging into ASP.NET MVC – Part 2



I got a bit sidetracked from the MVC stuff as I didn”t have as much time between projects as expected, but had a chance today to play around with it a bit more at home. I don”t really have any earth shattering things to share, but I did run into a couple of beginner gotchas here and there. Still not quite wrapping my head around certain things.

I had set up my home machine with Visual Studio 2008, but I guess I never finished setting things up. I had copied my MVC projects over and was having trouble getting certain things to work properly until I realized I hadn”t installed the MVC bits yet. Doh. So that helped. I had a couple of the dlls in the bin directory, so a lot of things actually worked, but the Visual Studio tie-ins weren”t there. Also, you really can”t run an MVC project by opening from the file system, you do have to use the MVC project type in order to get everything wired up correctly. That might be obvious, but if you have gotten used to just pointing at a directory to quickly open a web site to play around with, that won”t work.

On my new project we are using LINQ extensively, so when I last played around with MVC I was also trying to figure out LINQ and between the two had a bit of a learning curve. I”m starting to get more comfortable with LINQ, so that helped me get up and running a lot more quickly this time. I figured out how to use the LINQ to SQL objects as a ViewData source for my MVC views,so that is kinda cool. If you want to just spit our html using a for each type pattern,you can even cast the objects back into your LINQ to SQL object and get strong-typing in your view. Not sure if that is kosher or not, but hey I”m still learning. Guthrie does it a bit, so I think I might be safe. You can also use the standard ASP.NET data controls like grid views, repeaters, etc., but that might get you into trouble. More on that later.

My personal web site has a lot of simple pages where I just get and display some data, such as favorite movies, music and so forth. MVC works great for that. In fact, I was able to rewire about 6 pages in an afternoon, including LINQ data access. So that is pretty sweet. Also really like the Html.ActionLink syntax for links, as it gives you a lot of security against moving stuff around. As long as your controllers know where to find the views, the actual view can change as much as you want in location, name, etc. I”m still looking for a good way to use an image rather than text though. People have a few ideas, but this feels like an area that needs improvement.

After getting data display working on a number of pages, the next thing I need to investigate is saving data back to the database. There are a couple of things that are a bit of a paradigm shift here. One, you don”t have server controls, postback, viewstate, etc. So in some ways it is a step back to some older ways of doing things, but it gets you back to a very clean html entry form again, but with all the power of the latest .NET stack working for you. Two (and this is the trouble I was talking about), you can”t have a server form on the page or stuff just doesn”t work. I was trying to follow some tutorials and couldn”t figure out what I was missing. Typically you create a standard html form and set it to post to an action your controller understands. Mine was just posting back to the same view and I couldn”t figure out why until I realized I also had another standard asp.net form (runat = server) on the page that was confusing things. Once I removed that, I started getting the behavior I expected. Unfortunately, I was at a point where I needed to stop so I”ll have to continue that learning curve on another day. Seems reasonably straight-forward now that I”m starting to wrap my head around it though.

Comments Off , permalink


18

Mar 08

Digging into ASP.NET MVC – Part 1



So I just rolled off a project I”ve been on for awhile and I”m taking a few days to dig a bit into the ASP.NET MVC framework, now in Preview 2. Some good material came out of the MIX conference, including a particularly great presentation from Scott Hanselman. If you are starting from scratch, that”s a pretty good place to start. You can either download a WMV or watch it streaming. In addition, there is now a whole section on the main ASP.NET web site dedicated to MVC with resources, forums and so on. A lot of other articles and blog posts are starting to pop up as well, so if you are a little intimidated about jumping in there is starting to be some support.

As I”ve mentioned before, I”ve been working with ASP.NET since the pre-beta and have mostly kept up with the various changes to the framework over the years. There are aspects of ASP.NET 2.0 that I wouldn”t consider myself an expert on, but I at least know the basics for most features and where to find information if I need it. I say that because I expect a lot of ASP.NET developers are in a similar boat with me when it comes to MVC. I”ve worked on a lot of enterprise web projects, including several version conversions. I”ve used a bunch of the betas. But I”ve generally stuck to the Microsoft provided “bits”, partly for client needs for maintainability and understanding of code and partly to avoid some of the risk of a new version breaking a bunch of custom or 3rd party code not controlled by Microsoft. So I haven”t really dug into the ALT.NET side of things. Played a little with stuff like Cruise Control, log4net,some code generators and so forth. Understand the very basics of TDD,but haven”t really found a very good way to do it on the traditional ASP.NET side of things. Anybody out there in the same boat?

So anyway, call me chicken, but now that Microsoft is working on an MVC stack I”m finally willing to take a look. Scott Guthrie has really gathered some good people on his various teams over the past few years and I really think they are trying to do the right thing when it comes to community input, transparency and willingness to try new things. So the MVC bits aren”t really even close to done, but they have accomplished a lot in a short time. I think there is still a lot of question about where this fits into enterprise development and what types of applications are best suited to this approach. The types of applications many of us write involving heavy reliance on viewstate, sessions, event wireup and now AJAX don”t always map nicely or clearly to an MVC approach. That”s not to say they can”t be done, but the best practices jury is still out in a lot of cases. That being said, test-driven development maps so nicely to this approach in a way that wasn”t possible before, so that alone to me makes it worth a serious look when designing a new web application. Because it really isn”t terribly easy to do this with traditional ASP.NET (other than some type of grand automation scheme that still requires a web server), a lot of web developers, myself included, have basically thrown up our hands and haven”t really even tried.

There are a couple of other features of the MVC stack that I like a lot. Maybe not features even as much as a philosophical approach. Here are a few highlights:

  • Separation of concerns, as Guthrie talks about a lot. Real n-tier development. Mockable interface-driven web sites.
  • Extensibility. There is a real effort to include other test frameworks, view frameworks, etc in the flow. Or write your own.
  • Routing. This is super cool, allowing you to separate your view logic (think web pages in traditional sites) from the actual url. Create urls your Mom can remember. Move things around without breaking anything.

One more thing, if you want to learn the new language features like LINQ, lambda expressions, anonymous types, etc., these things are all over the place in the MVC framework. And for me, the way they are used really helps me understand the power of these features and how you might use them in a real application. Many of the walkthroughs or blog posts point these out, so it”s a good way to introduce yourself to some new stuff.

Comments Off , permalink


4

Mar 08

Breaking IE8 news



In an amazing (and unexpected) about face, the IE team has reversed its previous decision on how to implement standards in the next version of Internet Explorer. I was one of many in the community who decried the original decision as backward thinking and just plain wrong, so I”m very pleasantly surprised that they listened to the community. At least I hope that”s what they did, although there are various vague rumblings of new interoperability initiatives connected with some EU issues and some other reasons listed. No matter why they did it, making a decision to go full speed ahead with standards will be a boon to the web development community, although there are obviously still a lot of legacy browsers to support. At least we won”t have to program for IE8 quirks in 2012 (hopefully).

Comments Off , permalink


5

Feb 08

The IE team should bite the bullet already



I”m pretty disappointed, maybe even a bit angry, at the direction the Internet Explorer team has decided to take with IE 8 and support for standards. In this blog post, the team explains all the issues they ran into and how they decided to deal with them. As you can see from the many comments, they haven”t made many people happy. For awhile now, they have promised to support the ACID2 standards for web design with the next release of IE. Unfortunately, I don”t see any possible way their approach can be considered standards since it relies on a proprietary META tag to force the browser to render according to standards. Otherwise, it either renders in “quirks” mode (I was so over this years ago) or render like IE6 does. Both of these are terrible standards to follow, most if not all web developers would love to see a day when nothing has to be done to work around all the shortcomings of previous IE rendering engines. At any rate, needing a proprietary META tag to pass the ACID2 test is about the furthest thing from standards support imaginable. Just rip the band-aid off already, it”s never going to be a good time to undo all the previous bad decisions.

A couple of the commenters rightly declared that they write web pages according to standards, not browsers. This is the right response. As a web developer,I should be able to code to standards and then expect the browser to render in a close enough fashion to standards that I don”t have to jump through hoops to get pages to render properly. I can expect this for Firefox,Opera and Safari for the most part, but not IE.

The IE team”s excuse is that web developers expect IE to work a certain way and already code their pages with that expectation. Maybe so, but in what universe is that a good thing? I don”t think any of us want to do things that way, we are forced to because of the terrible rendering flaws in Internet Explorer. Honestly, most of the pages that would “break” are not being regularly updated anyway, so who cares? Or they are still using tables for layout, in which case IE”s problems with the box model have a lesser impact anyway.

I have a couple of alternate approaches (neither of which are original with me). First of all, if you want to use a META tag, have it turn off the full-standards support, not turn it on. The default should be that the rendering engine attempts to render the page according to standards. Maybe if most pages start breaking in older versions of IE, people will stop using them. Sure there are folks who for one reason or another can”t upgrade, but those aren”t your power users anyway. Technology runs on progress, deal with it. Second, why not check for a valid RECENT DOCTYPE instead. Most developers using a DOCTYPE are using it intentionally to force IE out of quirks mode. So this type of page is probably already going to render in a standards-based browser without too much problem. If the page doesn”t have a DOCTYPE, fine, go ahead and render it with all the IE rendering issues intact. But otherwise, render it correctly.

I don”t have much faith that the IE team is going to do the right thing. I”m beginning to think that most of the web developers complaining about Microsoft”s arrogance around standards is right on the money. Still, there are definitely people at Microsoft that care (Guthrie, I”m looking at you) and there are certainly enough developers that care. So do the right thing and finally fix IE so our children can live in a world where web design is full of happy little clouds and strawberry fields.

Comments Off , permalink