vs, net comments edit

If you’re using third-party plugins with DXCore (CodeRush/Refactor) fromDevExpressand you’re moving to Windows 7 or Windows Server 2008, this will affect you.

I had an issue filed recently on CR_Documentor where a user was correctly deploying the plugin but DXCore wouldn’t load it (and, thus, the user couldn’t see the CR_Documentor tool window link or anything).

Looking in the DevExpress message log, the exception message seen was like this:

Exception occurred while attempting to load assembly at "C:\Users\USERNAME\Documents\DevExpress\IDE Tools\Community\PlugIns\CR_Documentor.dll". (System.IO.FileLoadException)

Following inner exceptions down the stack, we finally saw the true reason the plugin wasn’t loading:

System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.

I filed an issue with DevExpress (who, by the way, has a great support team) and we found one solution by modifying the <loadFromRemoteSources> element in devenv.exe.config (as mentioned in the exception message), but changing your config just for one plugin doesn’t make sense, and that’s when the real solution hit me.

You need to unblock DXCore plugins. Windows knows you got them from a remote location (e.g., Google Code) and limits their permissions. Sort of like how you have to unblock .CHM files so you can read them.

These instructions should work in any version of Windows from WinXP SP3 and up.

  1. Close all instances of Visual Studio.
  2. Right-click the plugin assembly and select “Properties.”
  3. On the “General” tab, click the “Unblock” button.
  4. Click “OK” to apply the changes and close the properties window.

Everything should work correctly now.

Click the "Unblock" button to enable the
plugin.

media comments edit

The folks over at Tested.com have created a nice guide to show you how to rip your DVDs to play on any device. Basically they walk you through the preferred settings in Handbrake for each device and explain what each device supports.

To me, it looks like you’ll end up with a different copy of the movie for just about every device. It also won’t work for my purposes since part of the goal of my media center/DVD library is to use the library as a backup for the discs in case they go bad; recompressing, removing the extras/menus, etc. sort of defeats that purpose.

Nevertheless, a good guide, especially if you’re just looking to stream the movie content.

net, process comments edit

Around the middle of last year I reviewed ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008. In a nutshell, I thought it was a good entry level book to multi-tier app development, but I didn’t think it really showed what “enterprise” dev should be.

Since then, I’ve gotten a lot of questions asking what book I would recommend to learn enterprise application development. Unfortunately, I didn’t really have an answer at the time… and I still don’t.

The problem is that, for a dev who’s never done anything much larger than a fairly simple web site or some console/WinForms apps, after reading this book it looks like “all you need to do” to get into enterprise dev is start separating things into tiers, and that’s not really accurate.

Really, you need to consider different technologies; different architectures; how the system you’re building needs to interact with other systems (if at all); who’s going to maintain it when you’re done; how the system should be extended; and so on. It’s more than just throwing a three-tier web app out there.

Because there’s so much to it, you really can’t just pick “a book” and call it good. You sort of need to pick several books, but even then, it’s not enough.

Think of it in terms of those “Learn to Program in 24 Hours” books.Say you read one of those and work through the exercises and do everything it says you should do. When you’re done, are you a programmer? No, not really. You might be able to put a simple program together, or even a complex one, but you’ll be missing a lot of the things that you’d get with experience - knowing which algorithms to use in certain situations, understanding the benefits and drawbacks to the tech you’re working with, and so on.

Same thing here: Can a book, or even several books, teach you enterprise development? I’d say no. You’ll never be able to just read a few books and throw “enterprise development” on your résumé. Can books give you a few building blocks that you can use, along with experience, to do enterprise development? Sure.

Given the constraint that you’ll be looking at .NET-based technology (since the original commentary was on a .NET-based book), here are a few suggestions. It’s by no means all-inclusive; the second I publish this it’ll be out of date (if it isn’t already); and while this is a .NET-centric list, you really need to look beyond just .NET so you can choose the right solution.

  • Design Patterns: Elements of Reusable Object-Oriented Software: Understanding design patterns will help you recognize different ways to implement various functionality as well as giving you a common language with which you can communicate your design. (You may have heard this book referred to as the “Gang of Four” book.) Should you apply every single design pattern in your code? No - it’s not a checklist. Will it help you do things in a standard way and maybe open your eyes to some different ways to solve the problem? Sure.
  • Design Patterns in C#: Less comprehensive (and easier to read) than the “Gang of Four” book, but provides concrete examples of common patterns in C# and helps to solidify some of the concepts.
  • Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries: This book will help you understand various patterns (and anti-patterns) that you should use in your code. It also addresses some issues like naming conventions that will help your source code be more discoverable to other developers who may come in to help or maintain the code. (FxCop analyzes your code for some of these rules. You’ll want to run FxCop on your enterprise app code. However, you may not want to run literally every single rule. I have some recommendations on which rules to run based on my experience.)
  • SOA: Principles of Service Design: If you’re not familiar with service-oriented architecture, this will help you become familiar. Remember, though, that SOA is just one option for separating logic into components. The ASP.NET 3.5 Enterprise Application Development book doesn’t even mention services, and that’s a big oversight.
  • Professional ASP.NET 4 in C# and VB: If your UI will be a web app, you owe it to yourself to get this book. It covers the ASP.NET pipeline and the common providers you’ll need to know about. While it primarily focuses on web forms, it does touch on ASP.NET MVC. Note that there is a lot to ASP.NET. It’s not just throwing a few controls on a page or whatever. This book is a behemoth at around 1400 pages with fairly small text. Be ready.
  • Professional ASP.NET MVC 2.0: A smaller book that focuses on the MVC portion of ASP.NET. This complements the more general ASP.NET book listed above. (At the time of this writing, the MVC 2.0 book is a pre-order; if you’re looking for something right now, get the MVC 1.0 book.)
  • Writing Secure Code: If you’re creating an enterprise app, it probably means you’re going to have a user base larger than one trusted user. You’ll want to make sure what you’re doing has security built-in from the ground up. Security is not an afterthought.
  • Code Complete: If you’re a developer of moderate experience then a lot of what you’ll find in here will feel like review. If you’re not, this book will help you understand some general good programming practices. In enterprise development, you’ll want to be aware of this stuff. It’s not just “jamming some code together.”
  • Code Leader: Using People, Tools, and Processes to Build Successful Software: Part of development of enterprise apps is the process - not just the coding, but how it gets built, how it gets tested, how it’s organized, etc. It’s meta-information about the app, not just the app. This book is a good intro to some of this process information. This one is sort of like gaining some “free experience” - it took a lot of us years to arrive at the conclusions you’re just handed here.
  • The Art of Unit Testing: With Examples in .NET: If you’re doing an enterprise app, you’d best be testing it. “It works” isn’t good enough at this level. While unit testing isn’t the only kind of testing you should be doing, it is fundamental. This book will help you understand how unit testing works and how to make a good unit test.
  • Other technology-specific books: You’ll end up with a lot of books that tell you how to work specific tech in .NET. Depending on your solution, you may or may not need these; or you may need more than this.

Like I said, it’s nowhere near a comprehensive list. For example, you’ll notice I didn’t include a database design book - not because there aren’t any good ones, just that I don’t have a specific recommendation. I also didn’t include a book for every single .NET-based tech; that list could go on forever. Windows Presentation Foundation, Silverlight, Azure cloud services… there’s a lot. I also didn’t get into every technology-agnostic programmer topic that would help - regular expressions, source code branching strategies, refactoring patterns, algorithms and data structures, etc. Again, that could go on forever.

However, all of this stuff is stuff you need to know, or at least be highly aware of, if you’re doing any sort of “true” enterprise development. It’s not just multi-tier development.

What do you think? Do you have a recommended set of books for enterprise application development? Do you think you can learn enterprise app from a single book? Several books? Or is it just something you need to learn with experience? Leave a comment and help out the people who are trying to learn.

media, home comments edit

Busy weekend this weekend, but got a lot done and had some fun, so it was one of the better ones.

Saturday my mom came over early and went with me to my 24th (and, ostensibly, final) laser hair removal treatment. (I’ll blog that in a couple of weeks after I see the results.) We tooled around town most of the rest of the morning, got some lunch, and headed back home.

In the afternoon my dad and grandpa came over and my dad helped me wire up some Cat-6 from my office to my living room. I have a feeling my Netflix issues are strongly tied to wireless network interference and since I’m looking at getting a new receiver with Ethernet built in, I needed to get a wire dropped in anyway. (No, my house wasn’t wired when I bought it. I wasn’t involved in the building of the house or I’d have had it wired to start with. As it stands, now I have to retrofit wires in and it’s not so simple with some of the sound barriers and things they built into my walls.)

Wiring that up meant me belly-crawling my way around in the crawlspace under my house, which sucks, especially when your flashlight burns out and you’re in the furthest corner of the house away from the door out. Feels a little like being in Saw, that. Plus there’s not actually enough room with all the pipes and stuff down there to really crawl so much as do that breakdancing worm move. My back and hips are killing me today.

After the wiring was done, we played Wii for a while and I showed my parents and grandpa how Wii Fit works. I showed them that it’s not just games, but also some different strength and yoga exercises. One of the strength exercises I showed them was the “plank exercise” - basically you hold a pushup position without moving for 30 seconds and it scores you on how stable you are. I’m admittedly out of shape, and when I showed them I got a 47 out of 100 for stability. My dad tried it and he also got a 47, so I didn’t feel too bad. Then my 88-year-old grandfather got up there and got a 96 like it was nothing. We were… suitably impressed.

Sunday I got some chores done, played a little BioShock 2, and then went to see the new Alice in Wonderland movie in IMAX 3D.

Disney's Alice in
Wonderland

I am an Alice in Wonderland freak, so I’ve been looking forward to this movie for a long time. That’s actually one of the reasons I paid the $15-per-seat to get the IMAX 3D.

Unfortunately, I didn’t anticipate this to be quite as huge as Avatar was, so I figured getting to the theater a half hour early would be plenty. I was wrong. Very wrong. So wrong we got stuck literally in the back row in the far right corner.

I was unaware that theaters would sell tickets for seats behind the rear speakers, but those were the seats we were in.

Needless to say, this affected my mood and my viewing experience.

The movie itself was good. It was very visually engaging, as expected with Tim Burton films, and did not disappoint on that front. It was nice to see a bit of a “reimagining” of the story and have a sort of “sequel” as it were. The characters were pretty cool and well acted and I never had that thing where I look at my watch and wonder how long is left in the movie. I wanted it to just keep going.

That’s actually the downfall of the movie, if you can call it that. I wanted more. I wanted to hear more about the White Queen, since you really don’t get much from her. I wanted to hear more about the rivalry between the Red Queen and White Queen. I wanted more background on the Knave of Hearts. I think I could have stood another 20 - 30 minutes to get some of that depth that was missing.

There’s also a bit of dancing at the end - you’ll know what I’m talking about when you see it - that could have been cut. It didn’t add anything to the film and was just silly compared to the rest of it.

Don’t let that fool you, though: I thought it was a great movie and I’ll be picking it up when it comes out on Blu-ray. In fact, I think I’ll like it better when it comes out on Blu-ray because I’ll have the opportunity to actually see and hear it all the way it’s supposed to be seen and heard.

The thing is, I don’t think I really got the full viewing experience sitting where we were. Skewed so far back in the corner, some of the 3D effects were blurry and weird rather than being actual 3D. (This was true even for the trailers, the same trailers I saw when I saw Avatar in IMAX 3D and looked fine.) The worst was the sound. There were times where you could tell that if you were sitting in the middle, you’d get this cool effect of some ethereal sounds floating around you, or some disembodied character speaking that should sound like it was in your head. I didn’t get any of that. Stuff that was supposed to be behind you was right over my head. Stuff that was supposed to be in front of you was way out front. The whole thing was very disorienting and actually detracted from my enjoyment of the experience, something I’d waited months for. Enough that I almost would rather not have seen it and just forfeited the tickets and gone some other time when I could have seen it with a decent seat. Very, very disappointing.

Anyway, definitely go check that out, but if you go for IMAX 3D get there ridiculously early or you’ll have wasted your time and your money like me.

net, aspnet, gists, csharp comments edit

Messing around with ASP.NET MVC 2.0 (in VS2010 RC1), specifically the validation done with DataAnnotations, and created a simple no-op custom validator attribute like this:

[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
public sealed class MyCustomAttribute : ValidationAttribute
{
  public MyCustomAttribute()
    : base("Custom Error Message: {0}")
  {
  }

  public override bool IsValid(object value)
  {
    return true;
  }
}

Similar to the way the sample “PropertiesMustMatchAttribute” is set up - enabled on a class so you attach it to the model, not a property on the model, and set so you can have more than one.

I then created a simple model that used it like this:

[MyCustom]
[MyCustom]
[MyCustom]
public class MyModel
{
  public string SomeField { get; set; }
  public string OtherField { get; set; }
}

Notice I’m using my custom attribute three times there.

I then set up a quick view to edit the model, enabled validation, and put a breakpoint in the “IsValid” method on my attribute.

I ran the editor, hit the “save” button (to post the “edited” content back and get validated) and the call to my custom validation ran only one time.

You know what I missed? I didn’t implement TypeId.

This is documented as being a “unique identifier used to identify two attributes of the same type.” What’s not said there is that if DataAnnotations (or, at least, the MVC validation portion) comes across two attributes of the same type, it’ll only look at one of them. By default, TypeId is just the type of the attribute, so when two attributes of the same type are encountered, they’re considered “the same.”

If you set your AttributeUsage to AllowMultiple, you absolutely must implement TypeId.

You can see this implemented in the MVC “PropertiesMustMatchAttribute” as a new object (so they’re never identical). Updating my simple attribute like this…

[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
public sealed class MyCustomAttribute : ValidationAttribute
{
  public MyCustomAttribute()
    : base("Custom Error Message: {0}")
  {
  }

  public override bool IsValid(object value)
  {
    return true;
  }

  private object _typeId = new object();
  public override object TypeId
  {
    get
    {
      return this._typeId;
    }
  }
}

…causes my custom attribute to run all three times as expected.

What’s the use case for multiple attributes of the same type? In the case of the “PropertiesMustMatchAttribute” sample, maybe you have a model for registering a user - email, email confirmation, new password, new password confirmation. You want to make sure the two email fields match and the two password fields match. Two instances of one attribute, but working on different fields. Without implementing TypeId, only one of the validation checks will happen.

Once you get it working, sure, you can optimize some (for example, the “PropertiesMustMatchAttribute” could store the names of the properties being compared so if someone actually does try to run redundant validation it won’t happen), but that’s left as an implementation detail.