Tips and Tricks

ByTrent Jones

Issue with opening a solution with Silverlight in Visual Studio 2010

I recently started getting an issue opening any XAML file in the designer in visual studio. Visual studio would crash immediately. This then started to bleed over to crashing when trying to open the solution. I tried everything included reinstalling VS altogether. Didn’t work. When reapplying the Service Pack it downloads the Silverlight Developer tools from the internet. This version is 4.0.60531 which appears to be the culprit. Colleagues have an older version and have no issue. The error in Windows Event Viewer was fault in module agcore.dll. After a quick google i found this post with others having the same issue. The solution was to unregister System.Windows from the GAC. Presto. Works.

ByTrent Jones

Split TFS2010 Collection in two

I kept reading online how you could split TFS Collections in Visual Studio Team System 2010 in 2 but really couldn’t find any information on how to do it so i went upon trying this myself.  For instance, you may have a collection with projects A,B,C,D and you want to collections: one with A,B and another with C,D. 

  1. Detach the collection from TFS Admin Tool.
  2. backing up the corresponding collection db via SQL Management Studio.  (there is one db in sql per collection)
  3. Copy and Paste the back-up and Rename it
  4. Restore Database” in Management Studio. Use new name with “TFS_<YOURNAME>”
  5. Use TFS admin tool to identify existing collection to attach
  6. Use TFS Admin tool to attach new collection db.\
  7. Use VS Explorer to drop out projects not necessary in new collection

SharePoint connectivity is a whole other issue/post

Any TFS Gurus out there have more information please let me know and I will update this post.  I kinda thought there would be a command line tool to do this.

ByTrent Jones

ASP.NET 4.0 and Control IDs

In .NET 4.0 there is a new option when adding controls to a page or user control: ClientIDMode.  This property offers you four choices: Legacy, Static, Predictable, Inherit.  Previously it was almost impossible to find the id of a control in a normal matter such as jQuery.  Using

Choosing Legacy will continue to issue an ID in the same manner they were generated in previous version of ASP.NET, by concatenating the ID values of each parent naming container with the ID of the control.  Setting the property to Static will use the exact value of the ID property of the server control.  Predictable is used for controls that are data-bound controls such as repeater and also makes use of a ClientIDRowSuffix property.  Using Inherit makes the control ID property use the setting of its parent control.

In the example below, two lists are created inside the ContentPlaceHolder of a page using the same DataSource. The first is using the default and the second uses the new property with Static set as the value.

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:XmlDataSource ID="LinkData" runat="server" XPath="Colors/Color">
        <Data>
            <Colors>
                <Color Name="Red"/>
                <Color Name="Blue"/>
                <Color Name="Yellow"/>
                <Color Name="Green" />
            </Colors>
        </Data>
    </asp:XmlDataSource>
    <asp:BulletedList ID="uxList" DataSourceID="LinkData" runat="server" DataTextField="Name" />
    <asp:BulletedList ID="uxListStatic" ClientIDMode="Static" DataSourceID="LinkData" runat="server" DataTextField="Name" />

    <script type="text/javascript">
        $(function() {
            $("#uxList").append("<li>Red</li>");
            $("#uxListStatic").append("<li>Brown</li>");
        });
    </script>
</asp:Content>

Here is the output of the page in HTML

<div>
    <ul id="ctl00_ContentPlaceHolder1_uxList">
        <li>Red</li><li>Blue</li><li>Yellow</li><li>Green</li>
    </ul>
    <ul id="uxListStatic">
        <li>Red</li><li>Blue</li><li>Yellow</li><li>Green</li>
    </ul>

    <script type="text/javascript">
    $(function() {
        $("#uxListStatic").append("<li>Brown</li>");
    });
    </script>
</div>

And the corresponding view in the browser

•    Red
•    Blue
•    Yellow
•    Green

•    Red
•    Blue
•    Yellow
•    Green
•    Brown

Because of the generated tag on the first list jQuery can’t find the control to append to.

ByTrent Jones

Auto-Start ASP.NET Applications

Scott Guthrie has an article up on his website discussing the new auto-start feature of web applications that will be available in IIS7.5 with ASP.NET 4.0.  I just learned about this last week at the Southern Fried Road Show.

http://weblogs.asp.net/scottgu/archive/2009/09/15/auto-start-asp-net-applications-vs-2010-and-net-4-0-series.aspx

ByTrent Jones

960 Grid System

I am going to try and enlist the 960 Grid System on a website I am working on.

“The 960 Grid System is an effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.”

http://960.gs/

ByTrent Jones

40+ open source apps and games

Here is a list of apps and some games that are very useful.  There are a few I hadn’t heard of but will soon be installing.

http://www.downloadsquad.com/2009/05/18/40-great-open-source-apps-and-games-to-trick-out-your-new-windows/

ByTrent Jones

IE and ContentEditable Attribute

Ran into an issue today using jQuery with IE and setting ContentEditable=’true’ on a click command. First I created a div with ContentEditable set to true without jquery and ran it in IE. Ok, it’s working. Now to try and add the attribute dynamically. I removed the attribute and replaced it with this bit of javascript:

$(function(){
$("#test").click(function() {
$(this).attr({ ContentEditable: "true" });
});
});

This did not work. Even though IE would allow the Cap “C” to set to true without jQuery, it would not work in doing so dynamically. Changing to:

$(function(){
$("#test").click(function() {
$(this).attr({ contentEditable: "true" });
});
});

Works perfectly.

ByTrent Jones

Entity Framework Code Only option

.NET 4.0 and VS 2010 introduce a new feature for the Entity Framework called model first.  In addition, you will now be able to have a code only model. Written with POCOs and a simple class derived from ObjectContext and you are on the way…

http://blogs.msdn.com/efdesign/archive/2009/06/10/code-only.aspx

ByTrent Jones

Using T4 to Generate Stored Procs for Entity Framework

T4 code generation has been on my short list of things to look into but keeps getting put off as i navigate down some other endless path.  Meanwhile, I found a nice article on using T4 to generate stored procs for CRUD operations for the Entity Framework.

Entity Framework Stored Procedure Generation

Thanks David.