Posts

Showing posts from 2008

Nhibernate Fluent => hbm => SQL Schema

What luck for rulers that men do not think.  - Adolf Hitler More experimentation with NHibernate and we’re getting very close to Nirvana. The concept is (once again) – let’s develop our domain model first (similar to the “contract first” paradigm with SOA and WebServices) , create the mappings, and then create the database schema for the persistence mechanism (SQL Server, whatever) last. The Fluent.NHibernate project   API allows you to map entities in NHibernate in a more expressive and more testable manner than you are typically able to do. What it does is to give you a clear path to take your POCO s (Plain Old CLR Objects) –- without any of the “glop”  attributes or dependencies – just standalone objects – and turn them into NHibernate  .hbm XML Mapping files. This is very cool because it means your objects can be marked [Serializable] and you can send them over the wire via WCF, etc. without the – “[VendorNameHere] Baggage?” getting in your way, because the...

IIS / ASP.NET Recycling “Deadlock Detected”

I like long walks, especially when they are taken by people who annoy me.    - Noel Coward For some time I’ve been working on an ASP.NET web site issue where almost like clockwork, once an hour, the app recycles and then once again about six minutes later, it recycles again. It took a long time to find it, but it turns out that “we’re our own worst enemy”. No, it wasn’t some external process like Task Scheduler on the box, running once per hour and hogging threads. It was me having so much fun doing FireAndForget pattern RPC server pings on every search that I was shooting myself in the foot! This is what happens when we put in some new cool “thing” and then six months later, when we start to see problems, we can’t remember what we did! The ASP.NET “Deadlock detected” shows up in your Application Event log. It’s kind of cryptic, but here’s the general cause: You have a Threadpool per AppDomain. You may have a number of different operations going on (including just servin...

Referencing a non-Silverlight Assembly in a Silverlight Project

“Bailout? Hey! I’m having trouble paying my bills. How about it?” -- Me This one comes up a lot, and the bottom line is, you can’t do it. But - I think it is important to understand why it won't work: You cannot reuse non-Silverlight assemblies since the desktop CLR and Silverlight CLR are based on two different Frameworks. They are similar, but they aren’t “the same”. The BCL’s (Base Class Libraries) that are referenced in each type of project may have similar names but they are completely physically different files . But you can reuse the original code if it's compatible and available to you in source code form. In Visual Studio, you can create a new Silverlight class library project, then right click to add an existing item. You can click the arrow on the right side of the Add Button, and choose "Add As Link". This will not copy the .cs file to your new project, so when you modify the .cs file in one place, the other place will be automatically updated. You...

Silverlight 2 / Visual Studio 2008 “The project type is not supported” error.

  Recently I managed to discombobulate my Visual Studio 2008 Installation, and had to remove and reinstall the little booger. Everything went pretty much OK except after reapplying the Silverlight_Tools.exe (the combined developer installer), I tried to load an existing Silverlight 2.0 RTM project and got “The project type is not supported by this installation” dialog. I’m like, “Huh? The installation went perfectly with no errors”.  One fix I found that seems to work perfectly is to run “Devenv /setup”. For some reason this resets all the package loads and Silverlight Tools will be happy ever after. In my short happy life as a .NET developer, I’ve seen several products where MSIEXEC ends up just sitting there in memory at the end of an install session, all dressed up with no place to go, and it just hasn’t quite finished the job. While I’m on this subject, it might be appropriate for a quick review of all the DEVENV.EXE switches (the full documentation is here , alon...

LINQ To SQL / Entity Framework / NHibernate ORM Top-Down, Objects First

People demand freedom of speech as a compensation for the freedom of thought which they seldom use . – Soren Kirkegaard In the process of stumbling through LINQ To SQL to see if I would be able to represent a SQL Server database schema I created to provide storage for a hierarchical well-defined XML Schema for a commonly used utility object, I came to the realization that I was indeed doing everything completely backwards ! What I am saying is this:  ORM should be done by focusing on the OBJECTS FIRST, not the Database Schema! Unfortunately, most of the tools we have are data-centric, not object-centric.  Scott Allen has a post that clearly describes the debacle . To my knowledge, there will not be any plain old CLR objects (POCOs) in Entity Framework. LINQ to SQL doesn’t yet have all the mapping capability to really separate the object model from the underlying database schema – and of course, you can use it with SQL Server only. Now, this situation may imp...

One morning, I shot a Chevrolet in my pajamas…

Government does not solve problems; it subsidizes the m. – Ronald Reagan The White House said today that "The legislation crafted in recent days aimed at helping the ailing U.S. automakers is an effective and responsible approach".  I strongly disagree. It was hard enough to get policymakers to finally utter the word "recession." The Treasury just issued 4 week T-Bills at ZERO percent interest, for the first time in history. In the secondary markets, T-Bills were trading at a premium (meaning negative yields). You want to talk about deflation? People are so fearful that they’re willing to let the US Treasury hold their money and earn no interest at all.  The next challenge may be to get them to say "nationalization"  -- because that’s exactly what’s happening, baby! That's pretty much what the government takeover of big chunks of the economy amounts to, in my opinion. Welcome to the USSRofA, Comrade! Actions taken by the Democratic-le...

A Time to Reflect

"Everything you can imagine is real" -- Picasso As we approach the end of another year, most people begin a period where there is more introspection and reflection about their inner feelings and aspirations, making donations where appropriate to favored causes, hopefully spending more time thinking about the family unit and the blessings that it provides. I’ve already given thanks to my Twitter brethren for the enlightening 140 character or less pearls of wisdom and links they’ve provided. And I would like to extend the same thanks to readers here. I want to wish great peace to anyone who reads or has read my UnBlog, a happy Thanksgiving and Holiday season, and don’t forget – work isn’t everything. Take time to nurture your family and loved ones, and make an effort to do good in your community. Not only now – but all year. Commune with your family and friends, support those who need help with whatever resources you may have available to you, and – above all – be confident in ...

Silverlight vs. Flash – Where’s the Fire?

Is fuel efficiency really what we need most desperately? I say that what we really need is a car that can be shot when it breaks down. –-Russell Baker I had a chance to reflect a little bit today on Silverlight and Flash and I’d like to offer these observations. I have some not insignificant experience with Flash. Many developers are too new to remember FutureSplash – but I remember it very well, and I used it when it first came out, circa 1995. That was the predecessor of today’s Flash, which was ultimately purchased by Macromedia, and now of course subsumed into Adobe. A lot of the stuff you read today revolves around “Flash vs. SIlverlight”. The media loves controversy, and they’ll hammer on this subject ad-infinitum – often to the extreme detriment of any real content.  If you are on Twitter, the latest volley was about MLB (Major League Baseball) dropping Silverlight and going back to Flash for their video coverage. Its seems like every Tom, Dick and Harry Blo...

Why ASMX-Style WebReferences to WCF Services Don’t serialize Numbers

  Based on a casual googling of this problem, it appears that some developers have spent days trying to figure out why an integer they set on the generated proxy field comes over the wire into the actual WCF service as ZERO.  I didn’t spend days figuring it out, but it certainly did cause no end of annoyance and cursing until I  did. Let’s say you have a WCF service and for one reason or another (maybe your app is on a Handheld device and you cannot use “Add Service Reference”) you’ve set an ASMX – style “Add Web Reference”.  Your code in the generated proxy Reference.cs class may look like this:   public int Quantity {             get {                 return this.quantityField;             }          ...

Does Web Censorship Software Make Sense?

Like many other .NET Developers, I try to work as efficiently as possible for the benefit of my employer and clients. I don’t take smoking breaks, I usually eat lunch at my desk in about 10 or 15 minutes, and I don’t waste my employer’s time needlessly surfing the net. But many employers don’t seem to appreciate that. They look at what they see as a problem, and use web filtering software like WebSense to block employees from “doing bad things” under the guise of “improving productivity”.  You know what I say to that? Bull! Look, there are always going to be a small minority of employees who are irresponsible and don’t have good work-ethic values who will spend hours of their employers’ time surfing “unacceptable” web sites. But to punish everyone for the offenses of a few is like using a sledge hammer to swat a  gnat. If you block people from web sites, what do you think they’ll do instead? Their productivity won’t increase – the “Baddies” will just do something else, ...

Uninstall Internet Explorer 8 Beta 2 on Vista When not found in Programs And Features

Image
“Code is read a lot more times than it is written.” – Anthony Moore, Framework Design Guidelines 2nd Ed Can’t find Windows Internet Explorer 8 Beta 2 to uninstall in Programs And Features, or affter checking “View Installed Updates”? No problem! To uninstall Internet Explorer 8 Beta 2 in Windows Vista or in Windows Server 2008, do this: 1.Select and then copy the following command to the Clipboard: FORFILES /P %WINDIR%\servicing\Packages /M Microsoft-Windows-InternetExplorer-8*.mum /c "cmd /c echo Uninstalling package @fname && start /w pkgmgr /up:@fname /norestart" 2. Click Start , and then type cmd.exe in the Start Search box. (If you have Start / Run enabled, just type cmd.exe in the “Run” Textbox). 3.In the list of programs, right-click Cmd.exe , and then click Run as administrator . ( If you are prompted for an administrator password or for confirmation, type the password, or click Continue .) 4.Right-click inside the Administrator: Command Promp...

Global Crisis: Advice for Developers

Image
At this point, there is no question in my mind that we’ve entered into a global financial crisis of epic proportions such that you will (hopefully) tell your grandchildren about the “Global Meltdown of 2008”. I kid you not . Although over the years I have been a very diligent student of economic cycles and trends, I do not purport to hold some sort of “crystal ball” that makes me the Edward Cayce of global economic trends. But one thing is sure: long term economic cycles of boom-and-bust have turned decidedly negative, and this has broad, long-term implications for you and me as software developers. This is not a “US phenomenon” – this is truly global and touches every economy on the face of the earth. WHAT IS HAPPENING IN 2008 WILL REWRITE HISTORY . I’m not going to bore you with economic theories and say who is to blame or claim to have a solution to the problems that face us. Rather, I want to take a few paragraphs to give my read on what is happening and how you can protect yo...

Sunspots. Ready to Chill Out?

Image
Not only is the universe stranger than we imagine, it is stranger than we can imagine.   - Sir Arthur Eddington You probably haven’t heard much about Solar Cycle 24, the current cycle that our sun has just entered. However if Solar Cycle 24 becomes a household term, our lifestyles could be taking a dramatic turn for the worse . Solar Cycle 24 could mark a time of dramatic long-term change in the climate. According to geophysicist Philip Chapman , a former NASA astronaut, scientist and former president of the National Space Society, "It is time to put aside the global warming dogma, at least to begin contingency planning about what to do if we are moving into another little ice age." In recent months the sun has lost its spots. By this point in the solar cycle, sunspots would ordinarily be present in significant numbers.  If the sun does not soon revert to its "normal" behavior, and the speculation in the scientific community is growing that it ...

Silverlight 2 RC0 : Important Considerations for Developers

There are hundreds of “Me Too” blog posts about this, so I won’t bore you with more of the same. There are, however, two of what I think are very important considerations about Silverlight 2 RC0 that developers need to know about. You can only find out about this stuff if you take the time to RTFM carefully. In this case that would be the info on Scott Guthrie’s blog and possibly on Tim Heuer’s blog as well.  Pete Brown also does a great job of covering details, and he writes well. Finally, another smart person to follow would be Mike Snow , who is a Senior Software Design Engineer in Test (SDET) for Visual Web Developer Tools.   1)   RC0 is a developer release only . You cannot deploy RC0 applications to the web. They won't work. It's only for test environments where you want to ensure that existing or new applications will work with the final Silverlight 2 release. To repeat: there is no end-user installable runtime for RC0, only the developer runtime with the ...

Learning Experiences: What Developers Want

“The last update to the Hypertext Markup Language — the lingua franca of the web — was the 4.01 specification completed in September, 1999.” – Digg Post Recently I read a post on Jesse Liberty’s blog about getting flamed by some commenter who didn’t like what he was publishing. I responded in a comment that I thought he was doing just fine, and that you cannot expect to please everybody. But I also recommended that he put up one of those free poll “thingies” that would allow his visitors to vote on what they did want to see, and Jesse took me up on it. He put up a comprehensive poll that allowed write-in suggestions. I thought it was very well designed. The preliminary results of some 250 responses (including mine) is quite revealing, I think: “The results have held steady from the very beginning – Webcasts have overwhelmingly been the "last choice" for over 2/3 of users and in-depth tutorials have been the first choice; with short videos and short tutorials splitting t...

Virtual PC (VPC) techniques for developers

I’m starting my studies of Sharepoint and MOSS, so it occurred to me that creating a Microsoft Virtual PC image of Windows Server 2008 along with SQL Server 2008, Visual Studio 2008 SP1, and other useful tools would be a good idea. I’ve used VMWare and it’s great. But for a single developer who just wants a portable image that you can zip up and store on a USB stick, where you don’t need a whole virtualization infrastructure, VPC is ideal. One of the reasons I like it is that VPC doesn’t install a bunch of network drivers and Windows Services like VMWare Workstation or the free VMWare player.  VPC is nearly 100% “Self contained”, and doesn’t install any baggage at all on the host OS. Also, Shawn Wildermuth told me that VPC runs faster, so I took him at his word. The nice thing about all this is that the entire VPC control file and VHD expandable hard disk, with all of the software enumerated above,  7Zips down to just about 3GB – small enough to put on my  $7.99 King...

DON'T FORGET

Image

Silverlight: Handy Dynamic Javascript Debugger Favorite

Often you need to be able to View Source on a page that has injected dynamic javascript to see what you did, and,surprise – it’s not there. Here is a neat way to view source (including any dynamically generated elements or script):     javascript:document.write('<xmp>'+document.documentElement.innerHTML+ '</xmp>');   What this does is simply using the <xmp> (“example”) tag to literally render  your “stuff” without parsing. You can add this to your browser’s favorites as an A-HREF link and that way you can simply choose the favorite to view the complete source on any page.  This is extremely useful when using the Silverlight Browser classes to manipulate the DOM of the underlying Page. Here’s a sample like (this may not work as Blogger does funny stuff, but you can still mouse over it): Debug Js

Twitter - Social Microblogging Experiment (and Google Chrome)

Image
I started out on Twitter maybe a year ago, then decided it was a waste of time. Then, for some reason maybe 4 months ago I picked up again. It might be that  Witty (a very nice WPF Twitter Client) came out, then I found the JAVA TinyTwitter app for my virtually prehistoric AUDIOVOX SMT5600 smartphone (which only runs compact framework 1.0) . At any rate, I currently follow some  88 active Tweeters (Twitterers? Twitterinoes? Twitterheads?)  and have some 62 or so following me. What I've done from the start is try to concentrate on following only people who I know (either personally or through other communications) plus some extras whose work I am familiar with and who may or may not necessarily be familiar with me. I've found that a good many of the people I follow return the favor by following me. I've focused mainly on the .NET developer crowd. If you cast too broad a net, you are likely to be disappointed with the incredible amount of noise you've generated for yourse...

Why Podcasts Suck, Redux!

Image
  I weighed in on this subject some time ago here and I think it's high time for a rehash. Why?  Because they just won't give up! I'm putting links to Silverlight stuff into IttyUrl.net , which finally has a good, fast  new home (hasta-la-vista gate.com -- useless hosting company!)  -- and now I keep coming up with these podcast promotions.  NO, NO, NO! Podcasts are linear, they are like TV, which has become virtually prehistoric for us Internet Geeks! A podcast cannot be indexed by Google, you cannot "Search" it to find the part you are interested in (if there actually is one!) , and, except in rare cases, it's not professionally produced media - not by a long shot. And you certainly cannot copy code samples from a FYOOKIN' PODCAST! I mean, if I want to listen to the BBC audiobook narrated edition of Ernest Hemingway's " The Short Happy Life of Francis Macomber " , that's professional media! Podcasts, "NOT"! As I opined ...

Internet Explorer 8 Beta 2 out, and compatibility tags

Image
Internet Explorer 8 Beta 2 was released today in multiple languages, with more to come in the next 30 days. So, this represents a move beyond the "BETA 1" developer preview stage (possibly by a longshot). As can be expected, there will be a lot of pages and sites that want to opt-out of IE 8 “Standards” mode rendering. There are two ways to do this: On a per-site basis, add a custom HTTP header X-UA-Compatible: IE=EmulateIE7 (IIS 7.0 example:) On a per-page basis, add a special HTML tag to each document, right after the <head> tag <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> Implementing the HTTP header is useful if a site owner wants most of their site to render as it did in IE7 or if there are no plans to update site content. Inclusion of this header honors any Quirks mode pages that belong to the site. Using the meta-tag on a per-page basis is beneficial when you want to opt-in specific pages to render as they did in IE7. ...

Bugs in Silverlight?

Dr. Evil: Right, people you have to tell me these things, okay? I've been frozen for thirty years, okay? Throw me a frickin' bone here! I'm the boss! Need the info. I've seen more than a few posts on the Silverlight Forums where people are complaining (or sometimes just asking for help / guidance) on issues where they appear to be attempting to "tax the system"  and thus expose what they believe is "a bug".  Hey - Silverlight has bugs - even release software does -- that's not the issue. But creating artificial programming situations where one can claim "It's a bug" is not always a  legitimate effort. More often than not, this revolves around issues like "memory leaks" when attempting to set up some sort of "test" code that does some operation in a tight loop, or some similar operation that does not necessarily relate to what would likely happen in a "real world" Silverlight application. The poste...

Visual Studio: Enable / Disable IE Script Debugging Tool

Image
Rocky: There has already been two attempts on your life. Bullwinkle: Don't worry, we'll be renewed. If you are like me, you are always keeping your eye out for shortcuts and ways to make your life easier. One of the little annoyances of working with Visual Studio .NET is that it has no option to turn Client Script Debugging on or off – you have to open up Internet Explorer, go to Tools/Internet Options/Advanced and either check or uncheck the checkbox option. All this checkbox does is control a Registry entry, so why not just make a little .vbs script and register it as an External Tool in Visual Studio? The steps to do this are very simple. But first, you need to find out what Registry Key has your value. The key is located at HKEY_USERS\XXXXXX\Software\Microsoft\Internet Explorer\Main\ where “XXXXXX'” could either be “.default” or one of the machine user identities such as “S-1-5-19”. Once you have identified where your actual ...

Silverlight 2 Beta 2: ConfigUnrecognizedElement issue and Fix

  When you create a Service Reference in a Silverlight App to an ASMX WebService, you may get the:  "An unhanded exception ('Sys.InvalidOperationException: ManagedRuntimeError error #4004 in control 'Xaml1': System.InvalidOperationException: ConfigUnrecognizedElement at System.ServiceModel.Configuration.BindingsSection.ReadXml(XmlReader reader)" Exception. This "is a real bug".  When your Visual Studio 2008 Silverlight app generates the ServiceReferences.ClientConfig file, it creates a customBinding section that it cannot parse. In fact even the IDE marks the customBinding tag with squiggles saying "The element 'bindings' has invalid child element 'customBinding'. List of possible elements expected: 'basicHttpBinding'." This is because SIlverlight doesn't understand SOAP 1.2, which is the default for ASMX webservices. DUH! To fix, you can do this with WCF: <customBinding> <binding name=...

When Hosting Plans Go Bad...

Talk sense to a fool and he calls you foolish.   -- Euripides When I started using paid hosting for ASP.NET sites, I started out with CrystalTech and they were very good. Then I found Gate.com and they seemed like they had a pretty good deal going - SQL Server 2005, plenty of bandwidth (200GB), plenty of space, ASP.NET 2.0 and a control panel that would let you create custom subfolder IIS applications, set mime-types in IIS, and even your own custom 404 page - which I instantly turned into a custom UrlRewriting handler. All this for like $9.95 / mo, and a 25% discount on additional sites. Sweet. For an extra $5.00 I could go up to 500GB bandwidth. Then, about a month ago, I got an email from gate.com promoting how they were going to have a new "improved" control panel page, new features, more this, more that -- you get the idea. Turns out that they REMOVED features. They blew away my custom 404 handler and removed the ability to specfy "my" page for HT...

Silverlight: Some HttpWebRequest Headers don't work

Parents: Talk to your kids about Linux. Before somebody else does. -- XKCD I saw a couple of posts where people were attempting to make GET or POST requests to some service (which, if not same-domain, had the required crossdomain.xml or clientaccesspolicy.xml file) and this service required BASIC authentication credentials. Normally, you would add an "Authorization" header with the value "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" where the gobblydegook after the word BASIC is username:password converted to a Base64 string.  That's standard W3C Header protocol . Unfortunately, even though there is sample code illustrating this from Karen Corby here , it does not work (she does not actually add an Authorization header, just illustrates how to add a header). It turns out that the "Authorization" header is on the "restricted list". See here for a complete listing .  So, if you have been trying to do this, or any similar header that is on th...

Visual Studio 2008 Service Pack 1 (release) now available

"In all recorded history there has not been one economist who has had to worry about where the next meal would come from." -- Peter Drucker Here is a page with a bunch of related stuff, including a prep tool that will set you up in cases where you had a beta Service Pack installed: http://www.microsoft.com/downloads/Results.aspx?DisplayLang=en&nr=50&startDate=7/12/2008&period=30&sortCriteria=date   The actual Service Pack link is about the 10th one down in the list, here: http://www.microsoft.com/downloads/details.aspx?FamilyID=27673c47-b3b5-4c67-bd99-84e525b5ce61&DisplayLang=en I use UltraISO to extract this to the file system, and then you can just execute the "SPInstaller.exe" to start the install. A lot easier than burning a DVD. You can also mount the ISO using the VCD Control Tool or a similar utility such as Daemon Tools. But don’t forget if you ever need to do update or repair, you need to do so from Control Panel , ...