Welcome to MSDN Blogs Sign in | Join | Help

This weekend I’ve built a small application, which queries the “Simpsons” seasons guide data and updates the filenames/descriptions. To do this I needed to query a CSV file. While searching for a LINQ to CSV file implementation I’ve found an interesting list of LINQ Providers provider by MVP Charlie Calvert.

  • LINQ to CSV
  • LINQ to Amazon
  • LINQ to Active Directory
  • LINQ to Bindable Sources (SyncLINQ)
  • LINQ to C# project
  • LINQ to Continuous Data (CLinq)
  • LINQ to CRM
  • LINQ To Geo - Language Integrated Query for Geospatial Data
  • LINQ to Excel
  • LINQ to Expressions (MetaLinq)
  • LINQ Extender (Toolkit for building LINQ Providers)
  • LINQ to Flickr
  • LINQ to Google
  • LINQ to Indexes (LINQ and i40)
  • LINQ to IQueryable (Matt Warren on Providers)
  • LINQ to JSON
  • LINQ to LDAP
  • LINQ to NHibernate
  • LINQ to JavaScript
  • LINQ to LLBLGen Pro
  • LINQ to Lucene
  • LINQ to Metaweb(freebase)
  • LINQ to MySQL, Oracle and PostgreSql (DbLinq)
  • LINQ to NCover
  • LINQ to Opf3
  • LINQ to Parallel (PLINQ)
  • LINQ to RDF Files
  • LINQ to Sharepoint
  • LINQ to SimpleDB
  • LINQ to Streams
  • LINQ to Twitter
  • LINQ to WebQueries
  • LINQ to WMI
  • Linq To WIQL
  • LINQ to XtraGrid
  • Windows 7 has a really useful feature called “VHD Boot”. With that you can boot your entire Windows out of a Virtual Hard Disk file (as those used with Virtual PC or Virtual Server).

    This VHD file is mounted as a virtual disk, you can use it as a normal hard disk drive, but all the data is stored in ONE file. The machine is booted physically (unlike with Virtual PC), so you can only run one at a time, but have the full machine’s power.

    The advantages are magnificent:

    • Simply copy one file (the .VHD file) and you’re entire system is included.
    • Create incremental VHD files: One VHD file can be based on another one. So if you have different systems, create a base Win7 VHD and make all others incremental. This will save a lot of disk space!

    There’re also some small disadvantages :-)

    • The .VHD booted OS needs to be Windows 7, Windows Server 2008 R2 or later.
    • There’s a performance decrease of about 3%.
    • Hibernate and BitLocker don’t work.

    For the last three months, all my machines have been running as VHD booted ones.

    So how do you install a VHD-Boot machine?

    1. Boot the system with a setup DVD or USB stick.
    2. At the setup screen, don’t choose “Install Now”, but click “Repair your Computer”.
      2
    3. At the next screen (asking which existing installation should be repaired), select NO installation at all, but instead click into the empty space and press Next.
      3
    4. Now you’ll be presented the “System Recovery options” screen.
      There, simply select “Command Prompt” to get into a command prompt and execute a few commands. A quite complex way to get into cmd out of setup, but it’s useful for a bunch of things!
      4
    5. Enter diskpart to start the partitioning utitlity.
      image
    6. Create a new VHD file by entering

      create vdisk file=”D:\pathToVhd.vhd” type=expandable maximum=maxsizeInMegabyte


      For differencing VHDs you need to add an additional parameter parent=”D:\pathtoparent.vhd”.
      image
    7. Now select the new VHD and attach it as a physical disk.

      select vdisk file=”D:\pathToVhd.vhd”
      attach vdisk

      image
    8. After that switch back to the setup window (e.g. using ALT+TAB) and start the setup.
      2
    9. Proceed the normal setup, but make sure you install to the correct disk (normally the last one), ignore the “Windows cannot install to this disk” warning!!

    At next startup, you’ll see Windows 7 in the boot menu!

    5 Comments
    Filed under: ,

    These days I'm travelling around austria with our biggest developer & IT Pro event Big>Days 2009!

    This year's theme was "packen wir's an" - translated "let's get to work"!

    Accompanying the theme we built a multi-tier application with .NET 3.5 and Silverlight called "Rent-A-Worker"!

    You can download the sources at http://www.codeplex.com/BigDays09/!

    If you're interested in the slides of my four sessoins, feel free to get them here

    IE 8 Searchbar – Instant Answers is really cool (see below).

    image_11 

    There’s only one problem: It doesn’t work in Austria (as in many other countries). I suppose it only works in the US :-)

    To make it work, you need to change the regional settings to “English-US”.

    There are two ways to do it

    • Change your regional settings :-) (that’s really bad…)
    • Change the settings of the search URL

    The latter is the more interesting I suppose!

    I had a look at the registry and found out that there is a setting for the search provider suggestion URL.

    [Updated for BING] It’s under

    HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\
    SearchScopes\{0116A124-45AC-4E95-81CF-08D9FD996515}

    image

    There go to SuggestionsURLFallback and you will see that the URL ends with &FORM=IE8SSC&market={Language}. All you need to do is change {Language} to en-us.

    Voila! Instant Answers will work for you, whatever your machine settings are.

    You can download the registry .REG file here. (Just double click on it, to import the setting). [Update for BING]

    I’m sure all of you know the search box in Internet Explorer!

    You can search ANY searchable site there via pluggable search providers.

    Per default some of them are installed, but you can add your own!

    Here’s how to do it:

    • Go to the page you want to search through.
    • Search for “TEST”.
    • Copy the URL of the search result page (where TEST should be in somewhere)
    • Now go to the Internet Explorer Search Page and paste the URL in the rst textbox.
       
    • Choose a name and select install.
    • Now you have a new search provider in the search box, which will search the wanted page (and substitute TEST with your search text).
       

    Note.. the search providers are standardized and will work in any browser, which supports the open search specification.

    Note 2: Some sites are clever enough to include a search provider already!

    Read here how you can solve equations, get the current weather or other thing directly in the search box.

    Now that I’m running Windows 7 I’m using the new IE 8 as well. Recently I found a cool new feature called “Instant Answers”.

    Just enter some queries into the search box and you’ll get the answer in the drop-down box below the search box.

    There are different possible queries:

    image
    Calculations (2+2, …)
    image
    Conversions (75 C in F, …)
    image
    Weather (with or without location)
    image
    Equations
    image
    Definitions (*smile*)
     
    3 Comments
    Filed under: ,

    I’ve had a little playground TFS 2008 installation for a while for use with some “pet-projects”. I used TFS 2008 Workgroup Edition for this, as this is already part of MSDN subscription package. This edition works the same as the full one, but is limited to 5 users.

    Now that I needed more user accounts for a larger project I tried to upgrade to TFS 2008 Standard Edition.

    This seems to be pretty easy:

    1.) Open Add/Remove Programs in control panel.
    2.) Select “Visual Studio 2008 Team System – Team Foundation Server” and choose “Change”.

    3.) At the TFS setup, select “Upgrade” and enter the new serial number.

    4.) Finished.

    (Summarized from Brian Harry's Weblog)

    This is great, but unfortunately the serial number boxes are disabled / grayed out on my system (and all others as well) :-)

    So it’s harder than expected…

    But.. thanks to a thread in the MSDN Forums I found a way to change the serial number.

    All you need to do (as step 0.) is open setup.sdb in
    "Program Files\Microsoft Visual Studio 2008 Team Foundation Server\Microsoft Visual Studio 2008 Team Foundation Server - ENU"
    and change the [Product Key] value (skip the dashes).

    Voila!

    NET_v_rgb2.jpg I’ve a lot of New Year’s resolutions for 2009 :-) One of them is to blog more often (we’ll see how this works..) another is to do a series of webcasts around WPF.
    We’re starting with our first WPF webcast on Friday, January 9th at 10am with an overview over WPF and XAML.

    Topics we’ll cover:
    *) Why a new UI framework
    *) What tools, frameworks, .. do we need for WPF?
    *) What is XAML, what is it’s syntax.

    >> Register now at the Webcast Website

    I bought myself an Acer L5100 Media Center PC, running with Windows Vista Media Center for Christmas.

    What I wanted was some functionality to wake up the media center out of shutdown mode. So I dig into Wake-On-Lan.

    Almost any modern network interface controller (NIC) supports Wake-On-Lan nowadays. You just send a special packet as a broadcast containing the layer2 MAC address of the NIC and it will boot up the computer immediately.

    So I tried to write my own WOL client with C#. And it turned out it’s pretty easy.

    public static class WakeOnLan
    {
        public static void WakeUp(string macAddress, string ipAddress, string subnetMask)
        {
            UdpClient client = new UdpClient();
    
            Byte[] datagram = new byte[102];
    
            for (int i = 0; i <= 5; i++)
            {
                datagram[i] = 0xff;
            }
    
            string[] macDigits = null;
            if (macAddress.Contains("-"))
            {
                macDigits = macAddress.Split('-');
            }
            else
            {
                macDigits = macAddress.Split(':');
            }
    
            if (macDigits.Length != 6)
            {
                throw new ArgumentException("Incorrect MAC address supplied!");
            }
    
            int start = 6;
            for (int i = 0; i < 16; i++)
            {
                for (int x = 0; x < 6; x++)
                {
                    datagram[start + i * 6 + x] = (byte)Convert.ToInt32(macDigits[x], 16);
                }
            }
    
            IPAddress address = IPAddress.Parse(ipAddress);
            IPAddress mask = IPAddress.Parse(subnetMask);
            IPAddress broadcastAddress = address.GetBroadcastAddress(mask);
    
            client.Send(datagram, datagram.Length, broadcastAddress.ToString(), 3);
        }
    }

    All you need to do is create a packet with 6 times 0xFF at the beginning.

    Then send 16 times the mac address of the machine you want to wake up.

    This is done with the UdpClient class of the .NET Framework.

    The target address of the packet is the broadcast address of the network, which I calculate with the help of the IPAddress Extensions from the earlier blog post.

    Feel free to download the sources here.

    2 Comments

    Attachment(s): WakeOnLan.zip

    Recently I wanted to develop a wake-on-lan application for my media center.

    For that I needed the broadcast address of my local LAN.

    So I decided to write a small but interesting library.. (you can leverage it for all kinds of network calculations like subnets, etc..).

    What it does is do a lot of funny calculations around IPv4.

    • Network Address: This is the first address of each network which is reserved to identify the entire network (or subnet).
      If your ip address is                    192.168.2.234
      and your subnetmask                 255.255.255.0
      then your network address is    192.168.2.0.
    • Broadcast Address: This is the "send-to-all" address. If any traffic is targeted for the broadcast address it is forwarded to all of the machines in the network.
      If your ip address is                    192.168.2.234
      and your subnetmask                 255.255.255.0
      then your broadcast address is  192.168.2.255.

    Are you interested in the calculations behind that? Visit my other blog post.

    In .NET there is a class called System.Net.IPAddress, which is used for storing IPv4 addresses. So what I did is build a bunch of extension methods for this class:

    public static class IPAddressExtensions
    {
        public static IPAddress GetBroadcastAddress(this IPAddress address, IPAddress subnetMask)
        {
            byte[] ipAdressBytes = address.GetAddressBytes();
            byte[] subnetMaskBytes = subnetMask.GetAddressBytes();
    
            if (ipAdressBytes.Length != subnetMaskBytes.Length)
                throw new ArgumentException("Lengths of IP address and subnet mask do not match.");
    
            byte[] broadcastAddress = new byte[ipAdressBytes.Length];
            for (int i = 0; i < broadcastAddress.Length; i++)
            {
                broadcastAddress[i] = (byte)(ipAdressBytes[i] | (subnetMaskBytes[i] ^ 255));
            }
            return new IPAddress(broadcastAddress);
        }
    
        public static IPAddress GetNetworkAddress(this IPAddress address, IPAddress subnetMask)
        {
            byte[] ipAdressBytes = address.GetAddressBytes();
            byte[] subnetMaskBytes = subnetMask.GetAddressBytes();
    
            if (ipAdressBytes.Length != subnetMaskBytes.Length)
                throw new ArgumentException("Lengths of IP address and subnet mask do not match.");
    
            byte[] broadcastAddress = new byte[ipAdressBytes.Length];
            for (int i = 0; i < broadcastAddress.Length; i++)
            {
                broadcastAddress[i] = (byte)(ipAdressBytes[i] & (subnetMaskBytes[i]));
            }
            return new IPAddress(broadcastAddress);
        }
    
        public static bool IsInSameSubnet(this IPAddress address2, IPAddress address, IPAddress subnetMask)
        {
            IPAddress network1 = address.GetNetworkAddress(subnetMask);
            IPAddress network2 = address2.GetNetworkAddress(subnetMask);
    
            return network1.Equals(network2);
        }
    }

    The first two calculate the Broadcast- as well as the NetworkAddress. With the help of the network address you can then calculate whether two IP addresses are in the same subnet (simply by comparing the two network addresses). If they are.. fine, communication is done directly. If not, then the default gateway (a router) is used for the communication between them.

    These extension methods (keep in mind they’re in a static class, are static methods and have the special this (extension) parameter) extend an existing type (at least it seems so to use when using Visual Studio). Now we can call..

    var ip1 = IPAddress.Parse("192.168.0.1");
    var ip2 = IPAddress.Parse("192.168.1.40");
    var mask = IPAddress.Parse("255.255.255.0");
    bool inSameNet = ip1.IsInSameSubnet(ip2, mask);

    I’ve used the GetBroadcastAddress method in another sample to send a Wake-On-Lan packet to ALL computers on my subnet.

    The subnet mask indicates how large the network is. To ease work with it I’ve also built a helper class called Subnet.

    public static class SubnetMask
    {
        public static readonly IPAddress ClassA = IPAddress.Parse("255.0.0.0");
        public static readonly IPAddress ClassB = IPAddress.Parse("255.255.0.0");
        public static readonly IPAddress ClassC = IPAddress.Parse("255.255.255.0");
    
        public static IPAddress CreateByHostBitLength(int hostpartLength)
        {
            int hostPartLength = hostpartLength;
            int netPartLength = 32 - hostPartLength;
    
            if (netPartLength < 2)
                throw new ArgumentException("Number of hosts is to large for IPv4");
    
            Byte[] binaryMask = new byte[4];
    
            for (int i = 0; i < 4; i++)
            {
                if (i * 8 + 8 <= netPartLength)
                    binaryMask[i] = (byte)255;
                else if (i * 8 > netPartLength)
                    binaryMask[i] = (byte)0;
                else
                {
                    int oneLength = netPartLength - i * 8;
                    string binaryDigit =
                        String.Empty.PadLeft(oneLength, '1').PadRight(8, '0');
                    binaryMask[i] = Convert.ToByte(binaryDigit, 2);
                }
            }
            return new IPAddress(binaryMask);
        }
    
        public static IPAddress CreateByNetBitLength(int netpartLength)
        {
            int hostPartLength = 32 - netpartLength;
            return CreateByHostBitLength(hostPartLength);
        }
    
        public static IPAddress CreateByHostNumber(int numberOfHosts)
        {
            int maxNumber = numberOfHosts + 1;
    
            string b = Convert.ToString(maxNumber, 2);
    
            return CreateByHostBitLength(b.Length);
        }
    }

    This class provides constant subnet masks for Class A-C networks as well as methods for calculating subnet masks. A subnet mask is 32-bit long which consist of the network-part as well as the host-part. The methods create subnet masks either by the number of bits in the host- or network part or by the number of hosts, which should fit into the network.

    var classCMask = SubnetMask.CreateByNetBitLength(24);

    creates a subnet mask with 24-bits network part, hence a class C subnet mask.

    Have a lot of fun with IP calculations and visit my post about a wake-on-lan client.

    Also feel free to download the sources here.

    Last week I was in Dublin doing two sessions on WPF for Microsoft Ireland.

    They did a "Client-UI Day", where they featured WPF and Silverlight.

    phone pics 037

    The first session was given by the Irish Developer Evangelist Ronan Geraghty, who did an introduction to the Microsoft Client Platform, showing the differences between AJAX, Silverlight, WPF and when to use what.

    Next I did a WPF for beginners session, where I showed all the details of XAML, Databinding, Styles, Templates, etc...

    Afterwards my colleague Martha Rother from Ireland did a session on Silverlight.

    Last but not least I showed how to leverage WPF and Composite WPF Guidance ("Prism") to build business applications.

    Overall a really nice event, with around 80 attendees and a lot of interesting ideas and feedback on the Microsoft Client Continuum.

    If you're interested in my slides on WPF Introduction and Composite WPF, find them here:

    WPF Sessions.zip

    Going home from Ireland I took two flights via London.. What a bad choice.. I drove to Dublin Airport at 6:30 am, arriving in Vienna at 5pm :-) Almost half a day of traveling and waiting...

    The Silverlight Toolkit is a project built by the Silverlight product team, which contains a lot of "out-of-release cycle" controls.

    These are grouped into three parts:

    • Controls
    • Charts
    • Themes

    Controls include various nice controls (lots of them already part of WPF):

    • Auto Complete Textbox
      AutoCompleteBox example
    • DockPanel
      DockPanel example
    • Expander
      Expander example
    • Label
    • NumericUpDown
    • TreeView
      TreeView example
    • Viewbox
    • WrapPanel

    These controls are especially useful if you plan to write business applications. Also they have similar controls in WPF, so if you plan to port your apps from Silverlight to WPF they come in handy as well.

    The second part contains a number of various chart controls.

    image image image

    As third part, the toolkit contains a couple of themes, which can be applied to your controls.image

    Download the Silverlight Toolkit from http://www.codeplex.com/Silverlight/.

    1 Comments
    Filed under:

    Working with WPF & Silverlight is really great!

    The only problem if you use it in production is how you quickly generate new views. They don't need any animations or other stuff, just plain details views.

    You could do it with Expression Blend or the Visual Studio WPF Designer, still it would take more time than doing it directly in XAML..

    But.. Who is interested in writing 30 or so views in XAML ?!

    There is a better solution: XAML Powertoys.

    XAML Powertoys are a bunch of Visual Studio 2008 additions which really ease your daily work with XAML (either in WPF or in Silverlight).

    Let's say you have an entity Person and you want to create a list view for it.

    Just select "Create Form, ListView,.." in the "XAML Power Toys" context menu within the XAML designer.
    image 

    Next you select the type..

    image

    Next you can select the type of UI you want to create (either form, WPF ListView or the new DataGrid control).

    image

    You can select the participating data fields from the class and configure how they are bound, etc...

    That's it.. The XAML is automatically created and copied into your clipboard. Just paste it at the corresponding position and your UI is ready!

    > Get the XAML PowerToys here.

    But don't forget to add the install-path to trusted Add-In paths under Tools-Options:

    image

    This is about using the templates for a new project.

    First of all you need to download the templates and install them from the links below.

    Download the ZIP-File containing sources and built binaries here.

    See the post on how to install the binaries or build the sources here.

     

    Let's start setting up our new project:

    1. Create a new root folder for your solution (e.g. C:\temp\DemoClient\).
    2. Within the root folder create a Libraries (or other named) folder for the P&P assemblies, like Unity and Composite App Library.
    3. Copy the necessary assemblies to the Libraries folder (build the Composite Application Guidance projects to get them):
       image
    4. Now open Visual Studio choose "File - New Project" and select "Composite WPF Solution" from "Visual C# > Composite App Guidance".
      image_thumb[1][1]
    5. Enter the name of your overall solution (like "CompositeClient") and specify the root folder created before.
      image 
      Important: "Create directory for solution" should be unchecked, to automatically insert references later. Press "OK" then.
    6. A new wizard pops up:
      image
      You can now change your root namespace or the namespaces for the shell and infrastructure project.
      It's important to specify the relative path to the Library folder (starting from the specified root folder). In this case it's Libraries. After that, the new solution is going to be created.
      image 
    7. Select "Add New Project" on the Modules folder.
      image
    8. Choose "Composite WPF Module" and enter the Modules path of the solution as the location
      (e.g. C:\temp\DemoClient\CompositeClient\Modules\).
      Enter a name for the module (e.g. CompositeClient.Modules.Foo).
    9. The New Module Wizard pops up.
      image 
      Press Finish (or change the IModule class name or module namespace).
    10. A new project is created, containing an IModule implementation and a module controller class.
      image
    11. When choosing Add-New Item,  you can add a new Composite WPF View and Presentation Model to the module.
      image 
      Enter a name for the new items (not containing "View" or any other types). Just use "DoFoo" for instance.
    12. The New View Wizard pops up, letting you choose the names for view, presentation model and interfaces.
      image
    13. Choose Finish.
    14. A new subfolder is created, containing the files necessary for the view.
      image

    Note 1: When using the item template for the first time, you might get a dialog requesting to trust the template. Press trust there!

    Note 2: The wizards say "Composite WPF Guidance Contrib", as I hope to get into the Contrib project with this ;-)

    I've played around with Composite Application Guidance for WPF for a while now. Yesterday I did a session about CAG at the DEVcamp, a conference in Austria. As the time slot was only one hour I decided to fasten the demos by using code snippets (and the new designer tool) and special project and item templates. Ezequiel Jadib has built a project-template for Shell projects, but unfortunately until now, now other templates existed.

    That's why I decided to build a bunch of templates myself:

    • Composite WPF - Solution: Containing a shell, and an infrastructure project, all structured in solution folders.
    • Module-Project: Creates a new module, with IModule and a ModuleController class.
    • View-Item Template: Adds a new view (user control) together with a presentation model, necessary interfaces and wires all up.

    Download the ZIP-File containing sources and built binaries here.

    See the post on how to install the binaries or build the sources here.

    Read a step-by-step instruction on how to use the templates.

    After installing (or building), Visual Studio offers a new subgroup under "C#" titled "Composite App Guidance for WPF" in "New Project".

    image

    Additionally you get a new item in the "New Item" dialog, called "Composite WPF View and Presentation Model".

    The project templates use wizards (like the one shown below) to query information about the items created.

    image

    Note: The wizards say "Composite WPF Guidance Contrib", as I hope to get into the Contrib project with this ;-)

    More Posts Next page »
     
    Page view tracker