2005 2006 2007 2008 2009 2010 2011 2015 2016 2017 2018 aspnet azure csharp debugging docker elasticsearch exceptions firefox javascriptajax linux llblgen mongodb powershell projects python security services silverlight training videos wcf wpf xag xhtmlcss

User Control Error: The base class includes the field 'xxx', but its type (yyy) is not compatible with the type of control (zzz).



I'm not a huge user of user controls, but today I was porting an ASP app over to the real world and I figured the particular scenario I was working with didn't really warrant the power of a server control. So after I went an took the 12 seconds out of the day to create a user control all was well. It was working beautifully and all that jazz…until I published the website to the test server!

The base class includes the field 'cltFemaleItems', but its type (Items)
is not compatible with the type of control (ASP.items_ascx).

WHAT!!!! I'm marking this one as an ASP.NET 2.0 bug. After a bit of searching online I realized that there aren't really ANY workarounds to this online.

I went back and read the message again and noticed this small hint: "( ASP.items_ascx)". Below is what my user control class declaration looked like and what the declarative directive looks like. Everything looks fine...

<%@ Control Language="C#" AutoEventWireup="true" CodeFile=" Items.ascx.cs" Inherits="Items" %>


public partial class Items : System.Web.UI.UserControl

Based on the error message hint, however, changed the name of the contro. Here is what I changed the above code to...

<%@ Control Language="C#" AutoEventWireup="true" CodeFile"Items.ascx.cs " Inherits="items_ascx" %>


public partial class items_ascx : System.Web.UI.UserControl 

Then I republished and viola! All it well... That's one really weird ASP.NET 2.0 bug. Anyhow, this workaround seems to work well.

Update



Here's a quick update on a few things…

First off the primary feed for this site is now at the below link:

Please change all your references to point to the new link. I'll be removing the old one in a few months.

Secondly, since someone had an aneurysm and decided it would be a great idea to confuse the entire planet, WinFX is now called .NET 3.0. Ergo, I'm changing the name of this blog to NetFX Harmonics for the time being.

Thirdly, I'll probably be posting much more content in the near future. Recently I was at an MSDN event and I was amazed at how little everyone (including the presenter) knew about new technologies. There were people who actually asked what SOA event was. I assumed everyone in the Microsoft technical community would be at least somewhat up to date with WinFX (Uhhhh duhhh .NET 3.0) information. Clearly I was wrong. I guess I should start publishing again!

New Design/New Name



For all you getting this via Atom/RSS (btw, thanks for subscribing), come on by and check out the new blog design. This time I went for a darker design giving a bit of a Vista-ish feel. Also, you will see I finally formally changed the name to NetFX Harmonics to agree with the INSANE decision to rename WinFX to .NET 3.0.

Finally, if you haven't done so already please start using the new feed at http://feeds.feedburner.com/FXHarmonics/ to replace to old one. I will soon be discontinuing the old feed.

Constrainted try with retry mechanism for .NET 2.0



Lately I've been working on building a framework of abstractions and features that I feel are rather missing from my daily life. One of these features is a try/retry. In the past I used gotos and a ton of code to do this…but such extra coding was the nature of .NET 1.x. This is the world of .NET 2.0 and therefore I can take it to the next level! My new ExceptionFramework includes a few items to help me with exceptions and I figured I would share the following bit with the world.

using System;

public static class ExceptionManager { public static void TryWithRetryConstraints( Int32 retryCount, Int32 sleepTime, ExceptionConstraintCollection constraints, ExceptionTryBlock tryBlock, ExceptionCatchBlock catchBlock) { Int32 n = 0; retry: try { tryBlock.DynamicInvoke( ); } catch (Exception ex) { if (++n < retryCount) { foreach (Object constraint in constraints) { if (constraint is Type) { Boolean isException = false; if (((Type)constraint).Name == "Exception") { isException = true; }

                    <span style="color: rgb(43,145,175)">Type</span> parent = ((<span style="color: rgb(43,145,175)">Type</span>)constraint).BaseType;
                    <span style="color: rgb(0,0,255)">while</span> (!isException &amp;&amp; parent.Name != <span style="color: rgb(163,21,21)">"Object"</span>) {
                        <span style="color: rgb(0,0,255)">if</span> (parent.Name == <span style="color: rgb(163,21,21)">"Exception"</span>) {
                            isException = <span style="color: rgb(0,0,255)">true</span>;
                        }
                        parent = parent.BaseType;
                    }
                    <span style="color: rgb(0,0,255)">if</span> (isException) {
                        <span style="color: rgb(43,145,175)">Exception</span> thrownException = ex;
                        <span style="color: rgb(0,0,255)">while</span> (thrownException != <span style="color: rgb(0,0,255)">null</span>) {
                            <span style="color: rgb(0,0,255)">if</span> (thrownException.GetType( ).ToString( ) == constraint.ToString( )) {
                                Thread.Sleep(sleepTime);
                                <span style="color: rgb(0,0,255)">goto</span> retry;
                            }


                            thrownException = thrownException.InnerException;
                        }
                    }
                }
                <span style="color: rgb(0,0,255)">else</span> <span style="color: rgb(0,0,255)">if</span> (constraint <span style="color: rgb(0,0,255)">is</span> <span style="color: rgb(43,145,175)">String</span>) {
                    <span style="color: rgb(0,0,255)">if</span> (ex.Message.Contains((<span style="color: rgb(43,145,175)">String</span>)constraint)) {
                        Thread.Sleep(sleepTime);
                        <span style="color: rgb(0,0,255)">goto</span> retry;
                    }
                }
                catchBlock.DynamicInvoke(ex);
                <span style="color: rgb(0,0,255)">return</span>;
            }
        }
        <span style="color: rgb(0,0,255)">else</span> {
            catchBlock.DynamicInvoke(ex);
        }
    }
}

}

Here are some of the support items...

public delegate void ExceptionTryBlock( );
public delegate void ExceptionCatchBlock(Exception ex);


public class ExceptionConstraintCollection : Collection<object>
{
    public ExceptionConstraintCollection( ) {
        // Always declare default constructors!
    }
<span style="color: rgb(0,0,255)">public</span> ExceptionConstraintCollection(<span style="color: rgb(0,0,255)">params</span> <span style="color: rgb(0,0,255)">object</span>[] constraintSet) {
    <span style="color: rgb(0,0,255)">for</span> (<span style="color: rgb(0,0,255)">int</span> n = 0; n &lt; constraintSet.Length; n++) {
        <span style="color: rgb(0,0,255)">this</span>.Add(constraintSet[n]);
    }
}
}

This version allows me to retry only for certain types of failures. There is a simplified version which doesn't take the constraints, but this is one is a bit more useful for my scenarios (I actually think it's a good idea to always constrain it!) I found that the times I wanted to retry involved cases where I either wanted to retry based on a certain type of exception type or based on some text in the string.

Here's is how I use this version of the try/retry in one of my WPF applications. This is my little way of testing my laptop's RAM speed (as well as the CLR speed). I would grab 1GB of ram, free it, and quickly try to get it again (won't work). The below try/retry helps me get a feel or how fast .NET 2.0 can free up the memory and get it again (sometimes it CAN get the 1GB back).

First, I set up the constraints collection which holds the types and strings to which retries will be constrained to. This could of course be inline with the primary call.

ExceptionConstraintCollection constraints = new ExceptionConstraintCollection(
        typeof(OutOfMemoryException),
        "invocation");

Here is the actual call to the try/retry. I tell the try/retry manager how many times to retry (6), how many milliseconds to wait between each try (1000), what constraints to put on the try/retry (the above constraints collection), the logic to run as the try block (a delegate; anonymous in this case), and the code to run as the catch block (also a delegate; also anonymous in this case) and then let it do all the work for me.

ExceptionManager.TryWithRetryConstraints(6, 1000, constraints,
    delegate {
        group = new MemoryGroup();
        MessageBox.Show("Success");
    },
    delegate(Exception ex) {
        ExceptionManager.Report("Unable to allocate memory group.", ex);
    });

Now there are some obvious issues with this. The first: speed. Well, that's the nature of abstraction. You get ease of use and simplicity to life, but it costs a bit. The second is...this just seem weird, doesn't it? It just seems like there's a whole new bag of issues associated with this. Actually, this doesn't really bother me either. I'm keeping my code small enough so that I don't break the Ritcher anonymous delegate rule (never more than 3 lines of code in an anonymous block including comments) and I'm keeping in my mind that top level exceptions will really have the text of "Exception has been thrown by the target of an invocation." (which is, of course, true, but this means I better not be doing this stuff straight with COM interop!) As long as I keep that last one in mind I should be fine.

In any case, this has really been helping me out and have been proving to be a very powerful solution to the lack of a try/retry in the CLR.

Indigo Girl



OK, everyone interested in WCF needs to stop what they are doing and head on over to http://www.thatindigogirl.com/. Michele has posted chapters to her up amazing, soon-to-be-released WCF book up there. Not just that, but there are a few things that really impress me.

First off, she has to be my new technology role model (move over Brad Abrams and Andrew Trolsen) as she to be the highest ranking MVP in the world. Sheesh, just go look at her profile at http://www.idesign.net/.

Secondly, she's probably the best writer I've ever read. Picky doesn't even begin to describe me. If I don't consider the author absolutely outstanding, I don't bother flipping the pages. She is one of the very few people I can actually put up with. Her bypassing of the silly Hello World example for a more useful one was very respectable and it demonstrated to me that she wants to get right to the point (in turn this shows technical security; insecure writers have SO padding and PCness!)

Third, she seems to be a bottomless pit of powerful and useful training. Today was the first time I read her work and in the first 30 pages of her book I was able to overcome a load of WCF obstacles I was hitting with the go-live version.

Fourth, she has a very beautiful website. Not that she did it, but it does show that she cares about her environment. It rather bothers me when my fellow architects feel the need to go all hardcore and boring on me. She seems to be immune to that. Um...yes, I rate my favorite architects by more than their technical skills!

I swore to only buy book from Abrams and Troelsen, but I'm going to pre-order her book...something I've never done before. I'm extremely impressed with her work. Seriously, go check her blog, website, and book out!

Video 2 (FWD) - "Introduction to the Firefox JavaScript Console"



Firefox comes with many incredible utilities right out of the box. One of these tools is the JavaScript console. Most developers who have done any web development at all utilizing Firefox has used this great tool, but few know of some of the more powerful features. In this video I touch lightly on a few features that you may have overlooked.

In the next video we will dive hard core into some code to see the Firefox Web Development suite in action.

Video 3 (FWD) - "Introduction to the Firefox Console"



Here's the next video in the Firefox Web Developer series: Using the Firefox Console. The Firefox Console is a tremendously underused tool built right into Firefox. It allows for safe and efficient JavaScript development that may otherwise be a complete nightmare. This tool is also an absolute must for remote scripting developers (yes, I still refuse to call it "Ajax"). You can think of this tool as being much like a service tracer. C# programmers will feel right at home with this guy.

I say it in the video as well, but let me emphasis it here: the Firefox console is not the JavaScript console. Firefox is a complete standalone Web Development Suite -- not just a web browser. These tools are not addons, plugins, or extensions, but rather are natively built-in tools in Firefox. In later videos I will discuss other tools also built right into Firefox.

OK, so here ya go...

WCF Beta 2 and Go-live license!



At last! We now have beta 2 of WCF and a corresponding Go live license! This is incredible news for architects and developers alike. We can finally use the foundation to help unite our current (and future) component services, web services, and MSMQ applications in production

Just the other day I was designing an architecture and I was thinking "Gosh, this would be so nice in WCF. I *REALLY* don't want to do this in the old school way...if only the beta 2 and the Go-live license would be released!" Three days later...BAM!

Woohoo!! Not only that but beta 2 of WWF with a corresponding Go-live license is also available. I haven't been this excited since Firefox 1.5 came out!!!

Here's the Go-live license and the WCF beta 2 download (as well as WWF beta 2).

WCF Relative Binding Speeds



My latest infrastructure design consists of a few services spread over various servers and with many clients in various locations. Some of the clients will be on the same machine as the service, others will be on the same NT-based network, others will be WSE3 services, and even others will be PHP based. I wanted to provide the best solution for each, ergo my love for the Go-live of WCF! With WCF I can have the services expose multiple endpoints to allow a diverse number of clients each with their own maximum efficiency (remember, if you aren't measuring, then you aren't engineering!) PHP clients for example will get a BasicHttpBinding endpoint, while clients on the same machine as the service will use the NetNamedPipeBinding.

What do the speeds look like for each of these bindings? I went ahead and wrote a quick test harness to see the relative speeds of each binding. These are very simple tests, but they do demonstrate how the speeds of the bindings compare with each other. Without a ton of needless talk, let's get right into what's going on…

Here is the service configuration file…

  <system.serviceModel>
    <services>
      <service type="WcfDemo.DemoService">
        <endpoint
          address="WsDualHttpBinding"
          contract="WcfDemo.IDemoService"
          binding="wsDualHttpBinding"
          />
        <endpoint
          address="WsHttpBinding"
          contract="WcfDemo.IDemoService"
          binding="wsHttpBinding"
          />
        <endpoint
          address="BasicHttpBinding"
          contract="WcfDemo.IDemoService"
          binding="basicHttpBinding"></endpoint>
        <endpoint
          address="NetTcpBinding"
          contract="WcfDemo.IDemoService"
          binding="netTcpBinding"
          />
        <endpoint
          address="NetNamedPipeBinding"
          contract="WcfDemo.IDemoService"
          binding="netNamedPipeBinding"></endpoint>
      </service>
    </services>
  </system.serviceModel>

Here is the significant portion of the service code...

Uri netTcpAddress = new Uri("net.tcp://localhost:8080/");
Uri httpAddress = new Uri("http://localhost:8081/");
Uri netPipeAddress = new Uri("net.pipe://localhost/");
using (ServiceHost service = new ServiceHost(typeof(DemoService), new Uri[] { netTcpAddress, httpAddress, netPipeAddress })) {
        service.Open( );


        Console.WriteLine("Listening...");
        Console.ReadLine( );
}

Notice the netPipeAddress is using "net.pipe" as the address scheme and doesn't have a port. This is actually for the netNamedPipeBinding binding which is for inner process communication on the same machine, so there wouldn't be a port for that. The netTcpBinding binding does however have a port as it would really be out on the network somewhere. Also keep in mind that you add a URI for each address scheme, not each address.

Here is the client configuration file...

<system.serviceModel>
    <client>
      <endpoint
        address="http://localhost:8081/WsDualHttpBinding"
        binding="wsDualHttpBinding"
        name="WSDualHttpBinding"
        contract="IDemoService" />
      <endpoint
        address="http://localhost:8081/WsHttpBinding"
        binding="wsHttpBinding"
        name="WSHttpBinding"
        contract="IDemoService" />
      <endpoint
        address="http://localhost:8081/BasicHttpBinding"
        binding="basicHttpBinding"
        name="BasicHttpBinding"
        contract="IDemoService" />
      <endpoint
        address="net.tcp://localhost:8080/NetTcpBinding"
        binding="netTcpBinding"
        name="NetTcpBinding"
        contract="IDemoService" />
      <endpoint
        address="net.pipe://localhost/NetNamedPipeBinding"
        binding="netNamedPipeBinding"
        name="NetNamedPipeBinding"
        contract="IDemoService" />
    </client>
  </system.serviceModel>

Again notice there is no port on the netNamedPipeBinding binding and there is a port on the netTcpBinding. Also notice that each of the addresses end in the name of the endpoint specified by the server; the endpoints also have a name attribute to be accessible by the client-side code as seen in the next code block.

Here is how I start my client code...

DemoServiceClient wSDualHttpClient = new DemoServiceClient("WSDualHttpBinding");
DemoServiceClient wSHttpClient = new DemoServiceClient("WSHttpBinding");
DemoServiceClient basicHttpClient = new DemoServiceClient("BasicHttpBinding");
DemoServiceClient netTcpClient = new DemoServiceClient("NetTcpBinding");
DemoServiceClient netNamedPipeClient = new DemoServiceClient("NetNamedPipeBinding");

My actual benchmarking code consists of a simple timer that look like this...

Person person = new Person( );
DateTime a = DateTime.Now;
int i = 0;
while ((DateTime.Now - a).Seconds < 10) {
    wSDualHttpClient.RecordPerson(person);
    i++;
}
Console.WriteLine("WSDualHttpBinding: Processed {0} calls in 10 seconds", i);

That basically just means I want to run as many tests as possible in 10 seconds.

I actually ordered the tests based on my predictions of their relative speeds and it turns out my predictions were correct. Take a look for yourself...

WSDualHttpBinding: Processed 1602 calls in 10 seconds
WSHttpBinding: Processed 2531 calls in 10 seconds
BasicHttpBinding: Processed 17913 calls in 10 seconds
NetTcpBinding: Processed 39957 calls in 10 seconds
NetNamedPipeBinding: Processed 48255 calls in 10 seconds

This isn't really that surprising. The more complex web services protocols are slower than the most basic ones, which are in turn slower than a direct TCP connection, which in turn is slower than the named-pipes binding connection for use on the same machine.  So, if you are going to be doing something chatty, you may want to think twice before using SOAP.

That was actually an out-of-the-box benchmark; that is, I didn't customize the bindings in any way. In another test I turned off security for the WsDualHttpBinding and WsHttpBinding bindings.

First, I added the following binding sections to both the service and the client configuration files.

<bindings>
  <wsDualHttpBinding>
    <binding name="noSecurity">
      <security mode="None"></security>
    </binding>
  </wsDualHttpBinding>
  <wsHttpBinding>
    <binding name="noSecurity">
      <security mode="None"></security>
    </binding>
  </wsHttpBinding>
</bindings>

Then I altered the endpoints to point to the appropriate binding. Here is the service configuration alteration.

<endpoint
    address="WsDualHttpBinding"
    bindingConfiguration="noSecurity"
    contract="WcfDemo.IDemoService"
    binding="wsDualHttpBinding"
    />
<endpoint
    address="WsHttpBinding"
    bindingConfiguration="noSecurity"
    contract="WcfDemo.IDemoService"
    binding="wsHttpBinding"
    />

here is the client configuration alteration.

<endpoint
    address="http://localhost:8081/WsDualHttpBinding"
    binding="wsDualHttpBinding"
    name="WSDualHttpBinding"
    bindingConfiguration="noSecurity"
    contract="IDemoService" />
<endpoint
    address="http://localhost:8081/WsHttpBinding"
    binding="wsHttpBinding"
    name="WSHttpBinding"
    bindingConfiguration="noSecurity"
    contract="IDemoService" />

The results for both WSDualHttpBinding and WSHttpBinding were much faster!

WSDualHttpBinding: Processed 5773 calls in 10 seconds
WSHttpBinding: Processed 17257 calls in 10 seconds
BasicHttpBinding: Processed 19528 calls in 10 seconds
NetTcpBinding: Processed 39756 calls in 10 seconds
NetNamedPipeBinding: Processed 47457 calls in 10 seconds

So as you can see you can get really different levels of performance based on the different binding you use. The ability to have these various endpoints provides a great mechanism for my services to reach all kinds of different clients with great interoperability and maximized speed for network and local communication. Best of all, it's all free...no extra coding! All I had to do to add the new binding was add the endpoint to the service configuration file. WCF takes care of all the rest for you...

Supplemental material - Sample Projects

WCF: A self-hosted service with multiple endpoints



Last night I started playing with more more interesting things in WCF (multiple endpoints) and I kept running into a wall: how do you set more than one http endpoint on the same service!? Nothing I was doing was working, then I ran into Indigo Girl's WCF book chapters online (see my next post). Her examples clearly explain what I was doing wrong. Let me explain how to do what I wanted to do in my own words…

Instead of having a different "server" for each endpoint of the same address scheme (i.e. http), you have a a base address for and then give each a name. There is one WSDL for all the endpoints of a service. That is: one service, one WSDL; not one endpoint, one WSDL. This stems from the fact that by default there are two endpoints repackages: mex and HTTP Get. The HTTP get one is the one that will help out with the WSDL.

Here is the fixed up code. By running this up and generating the proxy, we are able to have the complete mechanism for communication from the client to the service, including the configuration file (below).

Program.cs
Uri httpUri = new Uri("http://localhost:8081/");
using(ServiceHost hService = new ServiceHost(typeof(DemoService), httpUri)) {
 hService.AddServiceEndpoint(typeof(IDemoService), new BasicHttpBinding( ), "BasicService");
 hService.AddServiceEndpoint(typeof(IDemoService), new WSDualHttpBinding( ), "DualHttpService");


 hService.Open( );


 Console.WriteLine("Listening...");
 Console.ReadLine( );
}
client app.config


  <system.serviceModel>
    <client>
      <endpoint
        address="http://localhost:8081/BasicService"
        binding="basicHttpBinding"
        name="BasicHttpService"
        contract="IDemoService" />
      <endpoint
        address="http://localhost:8081/DualHttpService"
        binding="wsDualHttpBinding"
        name="DualHttpService"
        contract="IDemoService" />
    </client>
  </system.serviceModel>

Even when using entitely different protocols (the higher level http and say the lower level tcp), you have one WSDL. Of course in this case, since there are more one address scheme (http and net.tcp), you have more than one base address; one per scheme.

Program.cs
Uri netTcpAddress = new Uri("net.tcp://localhost:8080/");
Uri httpAddress = new Uri("http://localhost:8081/");
using (ServiceHost service = new ServiceHost(typeof(DemoService), new Uri[] { netTcpAddress, httpAddress })) {
 service.Open( );


 Console.WriteLine("Listening...");
 Console.ReadLine( );
}
server app.config


  <system.serviceModel>
    <services>
      <service type="WcfDemo.DemoService">
        <endpoint
          address="NetTcpService"
          contract="WcfDemo.IDemoService"
          binding="netTcpBinding"
          />
        <endpoint
          address="DualHttpService"
          contract="WcfDemo.IDemoService"
          binding="wsDualHttpBinding"
          />
      </service>
    </services>
  </system.serviceModel>
client app.config


  <system.serviceModel>
    <client>
      <endpoint
        address="net.tcp://localhost:8080/NetTcpService"
        binding="netTcpBinding"
        name="NetTcpService"
        contract="IDemoService" />
      <endpoint
        address="http://localhost:8081/DualHttpService"
        binding="wsDualHttpBinding"
        name="DualHttpService"
        contract="IDemoService" />
    </client>
  </system.serviceModel>

As you can see WCF really allows for some pretty powerful scenarios...

Brainbench C# Fundamentals Technical Editor



What a week… I finally finished my gig as Brainbench technical editor (they called it an exam "cleaner") for the C# Fundamentals exam. Apparently they were extremely impressed with my work. Where others write a small comment line, I would write a page or so about the question and the answers citing the ECMA standard and anally explaining the improper wording of something.

I'm also rather kicking myself for turning down another gig they offered me. After I finished with this gig, I was offered the gig to write the VB.NET 2005 exam. My initial justification to myself for rejecting it was for the same reason I wouldn't write an Internet Explorer exam: it's no different than devil worship. Now I wish I took that gig, because even though the vbc.exe compiler packs a TON of useless garbage (you ever look at that stuff? A ton of odd Microsoft.VisualBasic references) in the assemblies, it's still IL! .NET is .NET! In any case, I did tell my rep there that I want to be on the list for any C# 2.0, CLR, or .NET 2.0 framework exams! We'll see!

LLBLGen Overview (Special Edition) Video



A friend of mine told me someone tasked him with creating an O/R mapping tool. My first reaction was…well, of course, your company likes to reinvent the wheel, loves useless legacy technology, and is very anti-productivity. He said that nothing is easy to use and everything has useless error messages. So I of course reminded him of the great gift to humanity known as LLBLGen, which is very easy to use and is very clearly designed. I've mentioned LLBLGen to him before, but this time was a real marketing opportunity. (Actually, I'm very annoying about promoting .NET 2.0, Firefox, Gmail, and LLBLGen -- absolute life savers).

Anyways… I told him I would create a quick overview video of LLBLGen as a marketing pitch to his company. Well, the "quick video" turned out to be almost a half hour long. Err, yeah… So, I've decided to share this video with the rest of the world. It's actually not like my usual videos, so I'm marking this version as "Special Edition". I'll probably release the "final" version in the future.

Below is the link to the LLBLGen Overview (Special Edition) video.

Disclaimer: I am in no way affiliated with Solution Design or any Solution Design/LLBLGen product. The above video is in no way endorsed by Solution design and is unofficial in every sense of the word.

Video 4 (FWD) - "Using the Web Developer Toolbar"



One of the most powerful and appreciated extensions for Firefox is the Web Developer toolbar. This is the extension that helped convert me from an independent IEvangelist to a Firefox promoter and standards advocate. This tool puts the keys to client-side web development into the hands of the developer.

With a quick click of the mouse, the developer can now see all elements of a certain type, can disable or enable various portions of development ( i.e. JavaScript), or can view otherwise hidden form information. It's such a powerful tool that you'll never be able to do client-side web development again without it.

I do apologize for being so slow in the posting of these videos. There will be a few more in the future. These videos are from September 2005 and are for Firefox 1.0.x, but are still appropriate for Firefox 1.5.x (and Firefox 2.0)

March 2006 WCF Resources



Heres just an update on the popular resources on WCF on the web.

Some links worth looking at...

Here's a list of the video Mike has up at the MSDN Nuggets website (link above).

  • "Hello World"
  • Type Serialization
  • DataContract Serialization
  • Typed and Untyped Messages
  • Bindings
  • Message Encoding
  • Message Patterns
  • Sessions
  • Instancing
  • Concurrency
  • Exceptions
  • Transactions
  • HTTPS Transport Security
  • Message Security
  • Authorisation
  • Auditing

Shared Source Common Language Infrastructure 2.0



I've been waiting for this one! The public version of the .NET 2.0 source code has been released! Otherwise known as the SSCLI 2.0 (Shared Source Common Language Infrastructure 2.0), this is basically the .NET 2.0 framework source code (among other things). With Reflector you can view the framework code, but this is the original code before any compilation thus leaving the developer comments in tact. It's also a bit cleaner here.

Not only that, but you get a load of unmanaged code. I'm talking about real hardcore CLR stuff. It also includes the C# compiler source code as well as the code for ILASM, ILDASM, and a bunch of other utilities. It's going to be really awesome seeing how generics and anonymous delegates are implemented.

My favorite piece that came with SSCLI 1.X is still here: there C# code for the JScript compiler (yes, the JScript compiler is written in C#). I actually used the original source code for the basis for a brain bender quiz in my .NET class. I highly, highly recommend the use of this SSCLI for your educational endeavors. Either to help you learn more, or to help others out.

Here's the link to download the SSCLI 2.0:

3D RSS XAML Demonstration



Here's a short application I wrote for a demo recently. This is a rather simple RSS application, but I created it in 3D in XAML using the February CTP of WinFX. Also, the code is self-sufficient. That is, you can use the below XAML declaration in XAMLPad.

The first thing to notice about this application is that the data is real. That is, the actually RSS information you are seeing on the screen is from a live RSS feed; this demonstrates XAML's XML data-binding capabilities. The next thing to notice is that the entire thing is on an angle. That's because this is all rendered in 3D. So, this also demonstrates using XAML in 3D. You should also notice the background. This is actually just a JPG on my website. There is no C#/VB.NET anywhere... it's all XAML. This demonstrates the power to skin objects. Finally, you should notice that the rendering has different font styles and sizes. This demonstrates how you can style controls... yes, controls. There's nothing fancy here. There isn't really a "3D TextBlock" or anything. A TextBlock is a TextBlock. I just so happen to be using it in 3D.

So, there are many things this demo demonstrates. I actually recorded a short video lesson on 3D XAML programming and I will be releasing it very soon. In the future I may have an entire series on 3D XAML programming.

<Page
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Viewport3D>
    <Viewport3D.Resources>
      <XmlDataProvider x:Key="xmlData" Source="http://fxfeeds.mozilla.com/rss20.xml">
      </XmlDataProvider>
      <Style x:Key="rssTitle" TargetType="{x:Type TextBlock}">
        <Setter Property="FontSize" Value="24"/>
        <Setter Property="TextBlock.Foreground">
          <Setter.Value>
            <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
              <LinearGradientBrush.GradientStops>
                <GradientStop Color="Blue" Offset="0"/>
                <GradientStop Color="Green" Offset="1"/>
              </LinearGradientBrush.GradientStops>
            </LinearGradientBrush>
          </Setter.Value>
        </Setter>
      </Style>
      <Style x:Key="rssText" TargetType="{x:Type TextBlock}">
        <Setter Property="FontSize" Value="12"/>
        <Setter Property="Foreground" Value="Gray"/>
      </Style>
    </Viewport3D.Resources>
    <Viewport3D.Camera>
      <PerspectiveCamera
        Position="2.5,2.5,5"
        LookDirection="-.5,-.5,-1"
        FieldOfView="45"
        UpDirection="1,0,0"
        >
      </PerspectiveCamera>
    </Viewport3D.Camera>
    <ModelVisual3D>
      <ModelVisual3D.Content>
        <Model3DGroup>
          <AmbientLight Color="White"></AmbientLight>
          <GeometryModel3D>
            <GeometryModel3D.Geometry>
              <MeshGeometry3D
                Positions="-1, -1, 0  1, -1, 0  -1, 1, 0  1, 1, 0"
                TriangleIndices="2 0 1 3 2 1"
                TextureCoordinates="1 1 1 0 0 1 0 0"
                Normals="0,0,1 0,0,1 0,0,1 0,0,1">
              </MeshGeometry3D>
            </GeometryModel3D.Geometry>
            <GeometryModel3D.Material>
              <DiffuseMaterial>
                <DiffuseMaterial.Brush>
                  <VisualBrush>
                    <VisualBrush.Visual >
                      <StackPanel>
                        <ListBox ItemsSource="{Binding Source={StaticResource xmlData}, XPath=rss/channel/item}">
                          <ListBox.Background>
                            <ImageBrush ImageSource="http://davidbetz.net/kansas/xamlimage.jpg"></ImageBrush>
                          </ListBox.Background>
                          <ListBox.ItemTemplate>
                            <DataTemplate>
                              <StackPanel>
                                <TextBlock Text="{Binding XPath=title}" Style="{StaticResource rssTitle}"></TextBlock>
                                <TextBlock Text="{Binding XPath=description}" Style="{StaticResource rssText}"></TextBlock>
                              </StackPanel>
                            </DataTemplate>
                          </ListBox.ItemTemplate>
                        </ListBox>
                      </StackPanel>
                    </VisualBrush.Visual>
                  </VisualBrush>
                </DiffuseMaterial.Brush>
              </DiffuseMaterial>
            </GeometryModel3D.Material>
          </GeometryModel3D>
        </Model3DGroup>
      </ModelVisual3D.Content>
    </ModelVisual3D>
  </Viewport3D>
</Page>

C# Fundamentals Exam Released!



Awesome! The Brainbench C# Fundamentals exam just went public! Why do I care? Well, because I was the technical editor for the exam! I'm rather excited because this was my first publicly shown work as a technical editor of anything.

I think exam takers will find the exam to be fair. It's not too terribly advanced, but it's not a beginners exam either. It should really test if you know what you're talking about. One thing that I will remind everyone of is that C# is a standardized language, not "some Microsoft language". So, this exam tests your knowledge of the official C# (ECMA-334) language, not your slang usages of it. Also, sadly, this exam is on the older C# 1.0, not 2.0, which is my favorite language.

Currently the exam is available for free at brainbench.com. The full link is below. Enjoy!

Breaking the Silence



Well, good news and bad news. I was offered the gig to write the new Brainbench C# 2.0 exam. I've been wanting that for a while, so obviously I took it. Of course three days later I get an offer from an editor for me to write a chapter or two for a soon to be released Ajax book. Ha! The bad news is that they had the exact same time frame (1 to 2 months). That, plus my intensive physical training and skydiving pursuits I found absolutely no time on my (Google) calendar to write a chapter! This is a major lesson in timing for me.

I'm really excited about the C# 2.0 exam though. If you know anything about how I write samples and questions you'll know that I'm BEYOND uptight about strictness to best practices and the official framework design guidelines (thank you Krzysztof Cwalina and Brad Abrams). So, my questions will obviously follow those VERY legalistically.

...and NO I won't have threading questions or web questions on the exam. This is NOT a framework exam! I hate it when test writers put that stuff on those exams. Strictly web people will miss every threading question and strictly Windows people will miss every web question. So, it will be fair... but, no, not easy!

By the way, I know I haven't posted any research in a VERY long time on either of my blogs (this one and my Ajax blog), but I've been rather swamped with non-technical activities for the past few months. I still have many more videos just sitting here that I need to post, but I just need to find the right time.

Exam Update



Well, I'm a month into the ACTUAL writing of the C# 2.0 exam and I'm finding it just as fun as I thought it would be. This exam is more advanced than most people are probably going to want it to be, but I just can't imagine WHY someone would want to take a sissy exam. That doesn't help anyone. On the other end of things, anyone who knows Richter's CLR via C# book by heart should do great on this exam.

The only previews I can give at this time are that this exam is really more of a C#/CLR 2.0 exam as I have a sections for reflection and AppDomain management. I also have sections for more controversial things like COM Interop and unsafe code (not too bad-- I'm not about to ask pointer arithmetic questions!). The other thing I can say is that this complements the 70-* certification exams in that this covers the more technical dimension of the CLR, C#, and the framework. It's more like computer science exams than the certification exams. That is, they are more algorithmic than scenario-based.

As I progress, I'm also setting aside questions for a possible CLR 2.0 exam (for my own exam; probably not Brainbench). I figure this exam could cover things like fusion, assembly loading mechanics, CLR internal memory management, identification of core DLLs ( i.e. mscorwks.dll) and other fun topics. I would really like to see "IT" people think MUCH more like CS people; internals and mechanics are VERY good things to know.

JavaScript Graphics Development Updated



For all those interested in learning some introductory concepts some lesser known features of JavaScript, I just updated my e-chapter on JavaScript Graphics Development. This an introduction to using JavaScript and Ajax concepts to do manual graphics development. It also touches briefly on concepts involving interactive graphics and widget creation.

Anyhow, here's the link:

'+' sign in e-mails



Announcement: Plus signs in e-mail addresses ARE VALID! I can't tell you how many time I went to a blog, a forum, or a (poorly design web…)store and my e-mails didn't pass validation. On some blogs I even get ASP.NET exceptions.

Plus signs in e-mails are commonly used for sub-addressing. When you have an e-mail like help@gmail.com and you don't want to give that to a webstore you can simply hand out help+nospam@gmail.com or help+Amazon@gmail.com or whatever and you're still good.

So PLEASE... if you wrote a buggy application or script that disallows '+' in e-mail addresses, fix your bugs.

The Uncatchable Exception



There's once aspect of exception handling that I've found that many seasoned .NET veterans know about. Take a look at the following code…

class Node {
    private Node node;

<span style="color: rgb(0,0,255)">public</span> <span style="color: rgb(43,145,175)">Node</span> ChildNode {
    <span style="color: rgb(0,0,255)">get</span> {
        <span style="color: rgb(0,0,255)">if</span> (node == <span style="color: rgb(0,0,255)">null</span>) {
            node = <span style="color: rgb(0,0,255)">new</span> <span style="color: rgb(43,145,175)">Node</span>( );
        }
        <span style="color: rgb(0,0,255)">return</span> node;
    }
    <span style="color: rgb(0,0,255)">set</span> { node = <span style="color: rgb(0,0,255)">value</span>; }
}

}

class Program { static void ProcessNode(Node node) { ProcessNode(node.ChildNode); }

<span style="color: rgb(0,0,255)">static</span> <span style="color: rgb(0,0,255)">void</span> Main(<span style="color: rgb(0,0,255)">string</span>[] args) {
    <span style="color: rgb(0,0,255)">try</span> {
        ProcessNode(<span style="color: rgb(0,0,255)">new</span> <span style="color: rgb(43,145,175)">Node</span>( ));
    }
    <span style="color: rgb(0,0,255)">catch</span> (<span style="color: rgb(43,145,175)">StackOverflowException</span> ex) {
        <span style="color: rgb(43,145,175)">Console</span>.WriteLine(ex.Message);
    }
    <span style="color: rgb(0,0,255)">catch</span> (<span style="color: rgb(43,145,175)">Exception</span> ex) {
        <span style="color: rgb(43,145,175)">Console</span>.WriteLine(ex.Message);
    }
}

}

Code Segment 1

What do you figure the output will be? Well, most people say the output is something like "Operation caused a stack overflow." That's a nice guess, but this exception thrown from the CLR is actually not catchable. This is the uncatchable exception. It actually jumps directly outside of your try block and shuts your application down. What you actually see is what's in the below figure.

StackOverFlowException

Figure 1

The CLR does not allow you to have infinite loops in your applications at all. So much so in fact that it will literally kill your entire application to make sure you follow the rules.

Now, if you're thinking about it... you may be think "CLR threw it? Hmm... I wonder... I read something about the ability to throw things that aren't exceptions". So, you may be tempted to try this...

try {
    ProcessNode(new Node( ));
}
catch {
    Console.WriteLine("Unknown exception");
}

Code Segment 2

This actually doesn't help the situation at all. Actually, if you've read my previous blog entry on the RuntimeWrappedException, then you would know about the .NET wrapping plan. Under .NET's default rules, thrown objects which do not inherit from System.Exception are wrapped in an instance of RuntimeWrappedException. So, even if the exception thrown was one of those, it would have been caught by the original code anyhow.

This StackOverFlowException application failure is actually a very helpful rule the CLR enforces. It forces you to go back and make sure you don't have a recursion bug in your code, because this is not really a user-specific exception it's literally a bug in your application. So, before you throw a fit when you see this, just go back and find the bug in your recursion code.

It's important to note however, that there's nothing inherently special about the StackOverFlowException itself. Take a look at this code...

static void ThrowStackOverFlowException( ) {
    throw new StackOverflowException( );
}


static void Main(string[] args) {
    try {
        ThrowStackOverFlowException( );
    }
    catch (StackOverflowException ex) {
        Console.WriteLine(ex.Message);
    }
}

Code Segment 3

This time your output really is "Operation caused a stack overflow.". So, if you throw it yourself you can catch it. The uncatchable exception isn't really StackOverflowException, but rather the CLR's throwing of the StackOverflowException.

There are other ways to completely kill an application. One of the more subtle of ways is via use of System.Environment.FastFail(String message). This static method will immediately kill and application and will not be caught by any catch blocks anywhere. So, if you really want to screw up an application simply do the following...

[Serializable]
public class SalesOrderException : Exception
{
    public SalesOrderException( ) {
        Environment.FailFast(String.Empty);
    }
<span style="color: rgb(0,128,0)">// More constructors go here...
}

Code Segment 4

Now every time your application has a SalesOrderException, it will explode into pieces. There's absolutely no way to recover from this. The above code is something that a disguntled employee would love to check in.

That said, looking at it in another light, Environment.FastFail(String) can actually be a great debugging tool. For example, say you have an application that is just downright giving you some weird output. You have no idea why. You know it's wrong, but there are just no exceptions bubbling to the surface to help you out. Well, if you have access to Visual Studio 2005's Debug->Exceptions... menu item, you can actually tell Visual Studio to allow you to see those first chance exceptions. If you don't have that, however you can put Environment.FastFail(String) in an exception, and use deductive reasoning and process of elimination to find out where your problem in.

You may actually be wondering "What is the point of Environment.FastFail(String)?" It's actually quite useful for anyone severely uptight about security or someone withing really low level in a system. If you're absolutely sure there's an unrecoverable corruption in your system, then you can call this method to kill this application. Basically what you're doing is "blue screening your application". The operating system is untouched, but you application is gone. Another situation someone can use Environment.FastFail in in security situations. If you absolutely need to verify some piece of security for the application to continue at all (i.e. you don't want anyone to catch an exception you throw and continue insecure), then you can use this method to "bluescreen" the app.

Troelsen's COM and .NET Interoperability Book



Now this is cool… Andrew Troelsen's book "COM and .NET Interoperability" is FREE in e-book format at apress.com (click on Free E-Books under one of the headings). I highly recommend this book to anyone who wants to either continue to use their current COM components in the .NET world or for people who want to use their .NET abilities in COM-based technologies.

Many times I hear people say they would have to need for this. Well, let me give you some ideas of what I do at the office. Every now and again the web developer at the office will get overloaded with work and it will bubble up to the architect (me!) Well... the older websites are all in classic ASP and while I spend my share of time in the trenches with classic web application development, there is NO way I'm going to do any VBScript development. (heck, even back then I did most of my work in PerlScript!)

My solution is simple: .NET to COM interop. Most of my work is done in .NET and I just expose the interfaces to COM. You really think I'm going to consume a web service with manual XML structures in VBScript? Uh... think again.

By the way, for those web services I consume and expose to COM I wrote my own web service consuming framework (because so many people expose COMPLETELY INVALID services to the world in pseudo-"SOAP" that .NET won't get near it). I then expose these new "services" to the COM world via component services. Oh yes, the book has an entire chapter just on serviced components (COM+ Interop).

Brad Abram's Presentation



Anyone who knows me knows I'm an architect and designer at heart… every time I see construction work I just stare at it and study how everything is being planned. Heck, I learned much of software architecture from watching Discovery Channel's Extreme Engineering. I love the stuff… ergo, Brad Abrams is my hero. His work is astonishing. As far as I'm concerned he is the glue that kept the BCL together.

Everyone NEEDS to check out his latest presentation on design guidelines. This is some good stuff. Usually I think PowerPoint is a mind numbing waste of time, but this presentation is great. By the way, if you don't OWN the design guidelines book by Krzysztof Cwalina and Brad Abrams, YOU NEED TO. If you never looked at it, please stop writing code today.

Check it out...

C# 3.0 Features at MSDN Nuggets



The MSDN Nuggets website has just released a TON of awesome videos about new C# 3.0 features. Personally I love the stuff they are doing with the LINQ project. It's going to make the awesome C# 2.0 language even more powerful and flexible.

The site also released a cool video about how to get Vista's glass to work in your apps. By the way, if you're interested in the workflow foundation, there are a ton of videos on that as well.

Here are the videos...

New Blog Engine



The other day I got sick and tired of the fact that I didn't have labels on my entires… sure Blogger Beta allows for that, but you have to be on their server to use it (and understandably so). So last weekend I wrote my own blog engine in .NET 2.0. Sure I could have used a pre-built one (like DasBlog), but I kinda like the level of control I get from using things with my architecture and my coding style. Yes, I know that's a ridiculous and somewhat arrogant excuse, but I really do like to have it in my own architecture and design even if own as a training tool I can use in the future.

Anyhow... the new system has been up for a few days and if you see any weird behavior on it (like a blog entry link taking you to the homepage or whatever), please be assured that I get a notification e-mail about the problem and will quickly look into it. I'm still considering it in "beta".

With the new blog engine you can access labels to view various entires at once as well as see articles by month by going to http://www.netfxharmonics.com/year/month/ like http://www.netfxharmonics.com/2006/10/.

There are various other nice internal features too, like the ability for each entry to have more than one URL. Some of my blog entries are actually linked via different links, so that's something that is definitely important to me.

Oh, how did I do that you ask? HttpHandlers! These ASP.NET pieces of goodness are great. My entire blog is really just one public page: default.aspx (plus the internal supporting user controls, masterpage and clientside JavaScript and CSS pages). There isn't really a link called http://www.netfxharmonics.com/2005/12/video-1-fwd-setting-up-your-firefox.aspx. When ASP.NET sees that URL being requested, the HttpHandler parses it and sends the information off to the default.aspx page which then looks up the blog entry data (via an adapter which then accesses LLBLGen) and sends that data back to the client who thinks that's a real page (even Google indexes it as a real page).

Another cool thing is something I mentioned before: each page can have more than one url. So, for example, the following two URLs show the same data (via a simple lookup in a table which contains the URL names).

As far as tracking, I did throw in a simple tracking system so I can log all traffic via IP address, session, and many other things. I really only did that so I can watch myself go through the site for debugging purposes. My REAL tracking is done via the awesome Google Analytics service which I have been using since it's release. I even have it on all the e-commerce sites we host at the office (replacing WebTrends!). Google Analytics is awesome. Google is awesome!

This weekend I'm going to be builtng in a Atom/RSS creation system that will give a feed to FeedBurner for the RSS subscribers to see (if you aren't using FeedBurner to serve your feeds, you really should--it abstracts the URL from your site so you can change your REAL feed location all you want and it gives you great stats as well). I'm actually going to implement my IAP (doesn't really stand for anything) engine which allows developers to dynamically create report templates and RSS feeds declaratively. We also use this at the office... it's actually really cool. It's not only an RSS server, but also an RSS aggregator. So, at the office, we use my IAP engine in the company portal to show blocks of information (they are simply RSS feeds shown via a custom ASP.NET control like ). So... implementing the new RSS system should be really simple.

As far as a client... I think that the web is kind of a hassle for client work. Personally I've grown to hate it. Back in the day I was all about web applications. I thought they were so cool, but I'm all about smart clients now. So, I wrote my blog editing application in WPF which, naturally, communicates with the server via WCF. The interface was rather simple to build in WPF as WPF it has the the advantages of WinForms with regard to simplicity and the power and awesome control tree model of ASP.NET. Great stuff...

The internal database is SQL Server 2005 Express. I swear... that thing is so cool. I've been using it for some time now and I have to say that I SO don't see myself ever needing the standard edition. Even at the office we don't need the standard edition for most of our databases (our CRM system needs standard for it's 60GB database, but other than that... Express works great). Oh... and YES, LLBLGen Pro 2.0 is the data access layer. That thing is so awesome.

As far as hosting. I love abstraction and delegation, so I don't see myself ever doing self-hosting. That said, I'm always looking for the best deal. That doesn't mean LOWEST price. "Best deal" in my situation is a metric of many factors. So, I use CrystalTech's dedicated web hosting for hosting the site (as well as MANY others) and I use the same box for my development work as well. It may just be a Celeron, but I have 1GB of RAM it in with everything I need. I can do anything from WPF to WF to WCF to Atlas on this thing. Granted I have to work with my own DNS and IIS configuration... but, serious, if you can't do that, you shouldn't even be in the biz.

I think that covers most everything. So, if you see something weird in the system, I can almost guarantee that there was an internal exception thrown and that I was notified of it with detailed in information of the failure.

Firefox 2.0 Officially Released!



Firefox 2.0 Officially Released!

The world's most powerful web access system has now been released in a new version: 2.0.

A few of the new features in Firefox 2.0 are:

  • In any text box you now have a SPELL CHECKER! So, if you are typing a comment in a form... you have little red underlines for misspelled words (goodness, I'm seeing them all over this e-mail. I just have to right click and fix it).
  • It's prettier for Mac and Vista people.
  • When you type in the search bar it starts to give you suggestions as to what you may be looking for.
  • Phishing protection -- Phishing is when you go to a website that says "Welcome to eBay! Give us your credit card number to continue service!". Firefox (and well most web browsers now these days) helps protect against that.
  • It handles even MORE powerful websites and intranets (Internet Explorer is finally caught up to 2003).
  • You ever want to restart your computer or just for (some odd reason and hopefully very rare reason) shut your down your computer and want to remember what you were doing? Well, now you can close Firefox and when you reopen it you have the option of continuing right when you left off (thank you Firefox 2.0 spell checker-- I could NOT spell continuing!). So, if you have 9 or so tabs open then you can have them all back when you restart your Firefox 2.0. Opera people have had this for a long time and many Firefox users had an extension that gave them this ability, but now it's finally native.

For those of you who are in a corporate environment (which is just about everyone in my target audience I suppose), to deploy Firefox in your corporate environment you won't want to install Mozilla Firefox directly, but rather, you will probably want to use FrontMotion Firefox. You can get this from FrontMotion's website. As of the time of this writing they haven't released the new 2.0 MSI (how could they... it was JUST officially released!), but in a few days they should have it posted. This Firefox is an MSI version that allows deployment via Active Directory ("AD"), which if very cool and REALLY needs to be native to Firefox anyhow. FrontMotion also provided administrative templates for your Firefox AD deployment. Their mozilla.adm template is a very powerful template allow customization of many aspects of the Firefox internal registry.

As a reminder, you can extend Firefox in any which way you want. I don't mean by using "add ons" in general, but I mean extensions. Don't like something? Fix it... Here are some extensions that I have installed everywhere.

  • All-in-One Sidebar
  • IETab
  • Download Statusbar

FrontMotion will also customize your corporate Firefox to have to extensions that you want in your MSI. What if you want to install Firefox extensions AFTER the MSI install? Well, the way to do that is simple and it does not involve a sissy GUI. Most people think that when you install a Firefox extension it's installed in the entire system. That's not true. Firefox extensions are per profile, not per operating system login nor per system. If you want to install an extension on a system use the following command.

firefox.exe --install-global-extension MyExtensionName.xpi

That will install the Firefox extension globally on the machine. This command is something you can definately package in an MSI yourself and if you know anything about MSI and AD deployment, then you know that you can set prerequisites, which will allow you to deploy the extensions after Firefox 2.0 is installed. Now, as with all properly designed software, Firefox extensions are versioned. Extension are versioned not only to have their own version, but they are versioned to work with specificially tested versions of Firefox (thats actually a Firefox extension development best practice). So, version your Firefox extension MSI packages so that you can tell AD to deploy the new versions as needed.

Given my audience, I think it would be a good idea to make a few statements about about the architecture of Firefox. This week I was at the HDC06 convention and one of the keynote speakers said something to the effect of "COM was never really implemented anywhere else other than in Microsoft operating systems" (that's a super paraphrase). Obviously that's not true... but one place it is definately not true is with Firefox. Internally Firefox has a technology called XPCOM (Cross Platform COM) that looks and feels much like Microsoft's implementation of COM (though a lot cleaner). You have interfaces and you query interfaces... blah blah blah. If you know COM, you know know what I mean.

Firefox also has it's own internal registry kinda like the Windows registry, except it's actually intuitive and it's not yet bloated to the point of complete uselessness. To access the Firefox registry, simply put "about:config" (with out the quotes) in the address bar. This allows you to customize just about anything about Firefox. As with anything, some of the really awesome stuff isn't directly seen in there (i.e. there aren't entries or "keys" for them by default), but the many Mozilla-specific websites have great documentation on how to customize and tweak your web system to your own likings. There's not really any limit to what you can do with the Firefox registry, so any documentation you see will by in some sense be incomplete, though MozillaZine's documenation is great for much of the Firefox registry defaults. You can tweak anything form the lowest geekiest component to something web developer-ish like toggling strict JavaScript mode on (... remember the Option Strict in VB? Same type of thing...) So, you may wanna dive into that depending on your needs (btw, if you see bold entries... that means they have been changed from their defaults or they have been added -- by an extension, by you, or by something else; they just aren't at their default state.) With regard to AD deployment, this Firefox registry type of stuff is what the mozilla.adm AD template will allow you to control in your AD group policy.

Lastly, for those of you have haven't seen my Firefox Web Developer videos, you can view them at the below links. Even though the videos were created using Firefox 1.0, everything in them is still true in Firefox 2.0. In the future I may released more videos, but for now what's posted is all I have prepared. I had one last video in the series , but "something" happened and it got cut in half.

So, if you haven't done so already GetFirefox.com today and help spread the goodness around the world and into your corporation

Links in this Entry

My Firefox Web Developer Video Series Link

Introducing the XML Assembly Generator



OK, so I'm back… with a gift to the world. For the last month or so I've been working on a project in my spare time that has already been a great help in my architecture and development work. About a month ago I got COMPLETELY fed up with writing code manually and I've always despised UML and graphical code generation systems (like Visio for Enterprise Architects-- I hate Visio anyhow!), but I'm completely addicted to XML and have been for years. What I wanted (demanded!) was a declarative (NON GUI!!!!!) programming tool that allows brainstorms/architectures/projects to be written in pure XML, so that I can think in concepts without having to work directly with code. So, I decided that it was about time that I create a system that will compile a XAML-like structure to a complete VS2005/C# project.

The system has already been a tremendous help to me. In fact, when I got the initial features of the system setup, I used it to create the rest of the system. This helped speed up development because I think in terms of trees, branches organization, and XML. When I was architecting the internal components of the compiler, I was doing all my work in XML using my XAML-like format. Then, when I got a design I kinda liked, I would run it through my compiler (at the time just a console application) and VOOM I got my C# project.

So, as of today, I'm releasing to the public in alpha form under the project-name "XAG" or "XML Assembly Generator". I considered the project-name "XAC" for "XML Assembly Compiler" as it's more of a compiler than anything else... but "XAC"? That's a real name and I found that beyond lame.

Though there is a complete documentation page linked from the XAG start page, here are some of the features that XAG provides.

  • Creation of classes
  • Creation of structs
  • Creation of enumerations
  • Creation of delegates
  • Creation of interfaces
  • Creation of physical folders
  • Creation of custom attributes
  • Creation of type aliases ("using A = B;")
  • Automatic Interface Implementation
  • Usage of Polymorphism
  • Strongly-linked objects (the resource "x:Key" subsystem)
  • Inclusion of properties
  • Inclusion of fields
  • Inclusion of constructors
  • Inclusion of methods
  • Inclusion of events
  • Auto generated constructors for properties
  • Static members
  • ref and out parameters
  • Inline instantiation of properties and fields
  • Inclusion of app.config data
    • I would like to point out a few special features of the system besides what should be obvious. First, I tried to make the syntax as close to XAML as possible, including the concept of resources. So, not only can you create types, but you can strongly-link types together just like you can do in XAML with resources. For example, you can create a class called "Item" and give it a key of "MyItem01" then you can create another class and declare a property using the type referring to the key "MyItem01". XAG will do all the magic for you in finding the real name of the type. This same concept is used for many things including inheritance, interface implementation, and aliasing generics. This helps you keep your structures strongly-linked, so you can ensure that when you want to inherit from a specific class named "MyClass" you get the specific one you want, not another one with the same name, but in a different name space. This also decouples the name of the type from the key. So you can rename the class all day long and not have to update any references. As a side note, just like with WPF/XAML, in order to access a resource, you have to first declare it. I don't think that's too much to ask.

      Second, have you ever created a type with multiple properties and then had to create a constructor to set all the properties? I hate doing that. I appreciate it when it's done (who isn't frustrated at the WPF guys forgetting to do that on their UIElements!?), but still... it just seems like work that should be done for you. C# 3.0 makes this work easier... but XAG simplifies this for you today. So, when you want to create a class with properties that has a constructor to set the properties, simply create the class and the properties and set AutoGenerateConstructorsByProperties to true and BAM, your type will magically have a constructor (in addition to the parameterless one) that maps parameters to properties.

      Third, when compiling the XML to C# (or VB2005 or IL or whatever the destination is--given I add those abilities), XAG looks for compliance to many coding practices. For example, if you try to set a class field to public, the compiler will give a warning and tell you it's changing it to private. I personally hate it when people write code that doesn't obey the .NET coding laws. So, I'm not allowing some of the most common things that lead to screw ups. Also, structs have many rules that are enforced. In fact, structs have more rules enforced than all other types combined. This is not so much for compliance to the .NET coding laws, but, rather, because structs just have more rules than classes. For example, say you have a struct with three instance Int32 fields and you want a constructor. Well, first off, you can't have a parameterless constructor and secondly, if you have a constructor at all, you have to initialize all the fields before control leaves that constructor. When creating constructors, XAG knows about your fields and initializes them for you.

      Here are some sample XML documents that will compile to VS2005 projects:

      The simplest ever:

      <assembly />

      Something a bit more interesting:

      <Assembly xmlns:x=" http://www.jampadtechnology.com/xag/2006/11/ ">
        <MyClass x:Key="MyClass" Type="Class" Namespace="ClassNamespace" />
      </Assembly>

      OK, that wasn't interesting at all... So, here's one that should explain things a bit better:

      <Assembly xmlns:x=" http://www.jampadtechnology.com/xag/2006/11/">
        <MyClass x:Key="MyClass"
                   Type="Class"
                   AutoGenerateConstructorsByProperties="True"
                   Namespace="ClassNamespace">
          <Properties>
            <Id Type="Int32" />
            <Name Type="String" />
          </Properties>
        </MyClass>
      
      
        <MyOtherClass Type="Class" AccessModifier="Public" Inherits="{Type MyClass}" Namespace="ClassNamespace" />
      
      
      </Assembly>

      This last one creates a project with two classes, one inheriting from the other. The first class has two properties and two constructors, one which is parameterless (as you should always have!) and one which takes two parameters and sets them to their respective properties.

      Looking at that, you may think it's too much overhead. Well, this isn't a sissy C# file creator. This thing actually creates the entire project and returns it to you as a single zip file. So, even if you wanted to start a new project, this system will help you tremendously. Simply open the XAG screen, select a template (optional), type in your code, hit Create Project, and you'll immediately get a ZIP file containing all folders, all files, an AssemblyInfo.cs file, and the project file. You will have everything you need to start your solution or to continue your solution by simply adding the XAG project to your existence solution.

      The XAG website also currently has a few tools you may find useful. Not only can you use the initial screen to create your XAG projects, but you can also use it to check for well-formed XML and also to format your XML. The entire website is Ajax based, so responsiveness is unsurpassed. As a side note, in case anyone is wondering, I did all the Ajax code manually as I find it much more efficient than using Atlas, however... I am using Atlas for web service calls to the main compilation server.

      As a warning, I'm still cleaning up the website (it's alpha!) so there may be problems in selling all compilation errors. I'm also redoing major parts of how compiler warnings are displayed, so, for now, there might not be any compiler warnings (it depends on when you look at the site!) Ideally, I would like the system to give a list of compiler errors and warnings to the end user (you!) It does in the console version, but I've yet to completely add that to the website.

      In the future I'll probably be modifying the syntax a bit (and therefore adding a release notes/change log here) and adding a few features and simplifications that I've been meaning to add for a while. For example, I wrote a much more powerful subsystem for generics, but decided that I should hold off on a public release of that to version 2.0. I will also be monitoring the exception logs and fixing bugs as they come up. I'm sure I'll be adding a ton of "if(v != null)" in this initial release.

      You can access this application at http://www.jampadtechnology.com/xag/. You can hit the intro link to see how it works, but it's fairly obvious. Most importantly, PLEASE SKIM THE DOCUMENTATION. I didn't say read it. Only super-geeks with no lives READ documentation. Just skim it and take in the overall idea and syntax. Lastly, please feel free to use any examples in the documentation, documents in the samples section (which I will be expanding upon), or provided templates to start or assist in your usage of the system.

      Links

Using XAG to Create a WCF Service



Here's a good example of what you could use XAG for. Using XAG, the below XML document compiles to a WCF Service Project. It contains an interface, a class implementing the interface, a few data contracts, and all appropriate references.

As you can see, you can include a literal configuration in the XML structure. This will be included as an app.config in your project.

What is XAG? XAG is a new FREE .NET 2.0/3.0 architecture and development tool allowing the creation of entire VS2005 projects in a single XML structure. You can access XAG at http://www.jampadtechnology.com/xag/

<Assembly xmlns:x="http://www.jampadtechnology.com/xag/2006/11/">
  <References>
    <Reference Name="System.Runtime.Serialization " />
    <Reference Name="System.ServiceModel" />
  </References>
  <Folder Header="Data Contracts">
    <Person x:Key="Person" Type="Class" AutoGenerateConstructorsByProperties="True" AccessModifier="Public" Namespace="AcmeCorp.Sales ">
      <Attributes>
        <Attribute Type="DataContract" Namespace="System.Runtime.Serialization" />
      </Attributes>
      <Properties>
        <FirstName Type="String" />
        <LastName Type="String" />
        <Address1 Type="String" />
        <Address2 Type="String" />
        <City Type="String" />
        <State Type="String" />
        <PostalCode Type="String" />
      </Properties>
    </Person>
    <CreditCard x:Key="CreditCard" Type="Class" AccessModifier="Public" Namespace="AcmeCorp.Sales">
      <Attributes>
        <Attribute Type="DataContract" Namespace="System.Runtime.Serialization" />
      </Attributes>
      <Properties>
        <Number Type="String" />
        <Cvv2 Type="String" />
        <Name Type="String" />
        <ExpDate Type="String" />
      </Properties>
    </CreditCard>
    <Item x:Key="Item" Type="Class" AccessModifier="Public" Namespace="AcmeCorp.Sales">
      <Attributes>
        <Attribute Type="DataContract" Namespace="System.Runtime.Serialization" />
      </Attributes>
      <Properties>
        <ItemCode Type="String" />
        <Name Type="String" />
        <Price Type="Decimal" />
      </Properties>
    </Item>
    <Cart x:Key="Cart" Type="Class" AccessModifier="Public" Namespace="AcmeCorp.Sales ">
      <Attributes>
        <Attribute Type="DataContract" Namespace="System.Runtime.Serialization" />
      </Attributes>
      <Aliases>
        <Alias x:Key="LineItemsCollection" Name="LineItemsCollection" Type="System.Collections.ObjectModel.Collection [{Type Item}]" />
      </Aliases>
      <Properties>
        <LineItems Type="{Type LineItemsCollection}" />
      </Properties>
    </Cart>
    <Sale x:Key="Sale" Type="Class" AccessModifier="Public" Namespace="AcmeCorp.Sales">
      <Attributes>
        <Attribute Type="DataContract" Namespace="System.Runtime.Serialization " />
      </Attributes>
      <Properties>
        <Person AccessModifier="Public" Type="{Type Person}" InstantiateObject="True" />
        <CreditCard AccessModifier="Public" Type="{Type CreditCard}" />
        <Cart AccessModifier="Public" Type="{Type Cart}" />
      </Properties>
    </Sale>
  </Folder>
  <Folder Header="Services">
    <IProcessorService x:Key="IProcessorService" Type="Interface" AccessModifier="Public" Namespace="AcmeCorp.ServiceContracts">
      <Attributes>
        <Attribute Type="ServiceContract" Namespace="System.ServiceModel" Reference="System.ServiceModel" />
      </Attributes>
      <Methods>
        <ProcessSale ReturnType="Void">
          <Attributes>
            <Attribute Type="OperationContract" Namespace="System.ServiceModel" />
          </Attributes>
          <Parameters>
            <Parameter Name="sale" Type="{Type Sale}" />
          </Parameters>
        </ProcessSale>
      </Methods>
    </IProcessorService>
    <ProcessorService Type="Class" AccessModifier="Public" Namespace="AcmeCorp.Service">
      <Implements>
        <Interface Name="{Type IProcessorService}" Namespace="System" />
      </Implements>
    </ProcessorService>
  </Folder>
  <Configuration>
    <!--
// Sample Console Application


using System;
using System.ServiceModel;


namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args) {
            using (ServiceHost service = new ServiceHost(typeof(AcmeCorp.Service.ProcessorService))) {
                service.Open( );
                Console.WriteLine("Listening...");
                Console.ReadLine( );
            }
        }
    }
}
-->
    <system.serviceModel>
      <services>
        <service name="AcmeCorp.Service.ProcessorService" behaviorConfiguration="Service1Behavior">
          <host>
            <baseAddresses>
              <add baseAddress="http://localhost:3827/"/>
              <add baseAddress="net.pipe://localhost/"/>
            </baseAddresses>
          </host>
          <endpoint address="" contract="AcmeCorp.ServiceContracts.IProcessorService" binding="netNamedPipeBinding"/>
          <endpoint address="mex" contract="IMetadataExchange" binding="mexHttpBinding"/>
        </service>
      </services>
      <behaviors>
        <serviceBehaviors>
          <behavior name="Service1Behavior">
            <serviceMetadata httpGetEnabled="true"/>
            <serviceDebug includeExceptionDetailInFaults="true"/>
          </behavior>
        </serviceBehaviors>
      </behaviors>
    </system.serviceModel>
  </Configuration>
</Assembly>