Standing on the shoulders of giants. RSS 2.0
# Saturday, February 28, 2009

image

It doesn’t let you save anything, Windows Azure doesn’t like it when you try to write to the filesystem, but it shows the posts & loads the theme. And with only minor changes!

I used the manual from “Cloudy in Seattle” to get an existing ASP.NET app running on Windows Azure, to get started. Because ASP.NET is an older application we still had a referce to MSBuild 8.0 in the proj. file and the Azure packaging tool didn’t like that so I removed the following from the web project.

  <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v8.0\WebApplications\Microsoft.WebApplication.targets" 
Condition=" '$(Solutions.VSVersion)' == '8.0'" />

Further I added a dummy log file to the logs directory to make sure that directory was avaialble got created. And made sure all files which are required have the Build action set to content:

image

The final thing to do is make sure you use the IIS 7 web.config file and disable tracing.

<trace enabled="false" />
Saturday, February 28, 2009 8:59:57 AM (Pacific Standard Time, UTC-08:00)  #    Comments [2] - Trackback
dasBlog | WindowsAzure
# Tuesday, February 24, 2009

In November last year Kim Cameron wrote a series of posts about Project Geneva. It’s a little late, but still very interesting.

  1. Project Geneva - Part 1
  2. Project Geneva - Part 2
  3. Project Geneva - Part 3
  4. Project Geneva - Part 4
  5. Project Geneva - Part 5

And the PDF with the Identity Software + Services Roadmap.

Tuesday, February 24, 2009 2:09:28 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0] - Trackback
Security | Services
# Friday, February 20, 2009

Since today there is a beta version of a SilverLight livestream control on the homepage of this site, which shows my activity on Twitter, Delicious and this blog. It’s not the most original idea, but it was a small enough project to learn something about SilverLight.

Loading the items

You can use the WebClient class (which internally uses the WebRequest class) to load data from the internet, this has some restrictions. To successfully connect to a site different from the site where the control is hosted, the site has to have a clientaccesspolicy.xml file or a crossdomain.xml which allows remote connections.

For performance reasons all methods on the WebClient class are asynchronous and since I request 3 different streams, I request those using using workitems in the ThreadPool (from a Timerevent every 5 minutes).

public void ProcessFeeds(object state)
{
    // twitter crossdomain.xml is very strict, so we have to have to 
    // use a proxy
    ThreadPool.QueueUserWorkItem(new WaitCallback(StartLoadFeed), new Uri("http://feeds2.feedburner.com/paulvanbrenk/twitter"));
    ThreadPool.QueueUserWorkItem(new WaitCallback(StartLoadFeed), new Uri("http://feeds2.feedburner.com/paulvanbrenk/clean"));
    ThreadPool.QueueUserWorkItem(new WaitCallback(StartLoadFeed), new Uri("http://feeds.delicious.com/v2/rss/paul.van.brenk"));
}

private void StartLoadFeed(object url)
{
    WebClient client = new WebClient();
    client.OpenReadCompleted += new OpenReadCompletedEventHandler(client_OpenReadCompleted);
    client.OpenReadAsync((Uri)url);
}

void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
    SyndicationFeed feed;
    using (var xReader = XmlReader.Create(e.Result))
    {
        feed = SyndicationFeed.Load(xReader);
    }

    foreach (var item in feed.Items)
    {
        Dispatcher.BeginInvoke(new AddItem(delegate(FeedItem x) { feedItems.Add(x); }), FeedItem.Create(item));
    }
}

private delegate void AddItem(FeedItem item); 

We need to use the Dispatcher to add the items to the collection, since the collection is bound to a UI element, which responds to changes in the collection.

Binding the items to the UI

The items are bound to the panel which renders them, using the DataContext. This makes it easy to use the Binding Markup Extension to extract information from the bound items and allows the panel to monitor the collection for changes (if the collection implements the INotifyCollectionChanged interface).

Render the items

The items are rendered using an ItemsControl, with the ItemsPanelTemplate set the WrapPanel from the SilverLight Toolkit, this way the items are wrapped over multiple lines. The items are renderd using a DataTemplate in the ItemsTemplate. The image for each type of feed is converted from the type of the item using to an ImageBrush using a class implementing the IValueConverter interface.

Improvements:

  1. Implement an ICollectionView instead of wrapping an ObservableCollection in a custom collection;
  2. Use some smart caching for the feeditem collection;
  3. Add an info button, instead of the the info in the bottom left;
  4. Improved the design;
  5. Add filtering and sorting;
  6. Make the SilverLight plugin resize with the browser;
  7. Support more feed types like flickr and youtube.

[Download the project from http://code.msdn.microsoft.com/LiveStream]

Friday, February 20, 2009 7:42:30 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0] - Trackback
SilverLight
# Wednesday, February 18, 2009

Shawn Wildermuth wrote about his experience using ASP.NET MVC for a new site he developed.

  1. Part 1: Why ASP.NET MVC
  2. Part 2: MVC in action
  3. Part 3: Datavalidation

One of the things he does is sending "complex" models to the view to render, I'm not sure that's something you should do. I believe that you should stick so simple strings and have the controller do all the heavy lifting. It's a slippery slope you're stepping on, before you know, you're sending 'models' straight from the Entity Model to the view.

Not sure if that's really feasible (or the simplest/easiest) in all situations, but it ensure a clean separation between business logic in the controller and the model and the UI in the view.

More info:Enforcing Strict Model-View Separation in Template Engines (pdf)

Wednesday, February 18, 2009 8:56:48 AM (Pacific Standard Time, UTC-08:00)  #    Comments [1] - Trackback
ASP.NET | Security
# Tuesday, January 27, 2009

Yesterday and today I had an interesting problem to solve. One of the projects I’m working on involves calling stored procedures on an Oracle server which return User Defined Types (UDT). To get this to work you need to install at least ODP.NET version 11.1.0.6.20, which at the moment is only publicly available in a 32bit. This was not a problem during development and since most .NET components are not architecture specific we were a bit surprised when we couldn’t get data from the Oracle server on the 64bit test environment.

After some investigation we discovered the ODP.NET components are architecture specific, so we needed to find 64bit components (since running in 32bit was not an option). Some research showed, that there is a 11.1.0.7.0 patch for 64bit, which can be downloaded from Metalink, but this requires a previous version to update. The solution to get everything working is downloading and installing the client tools from the 11.1.0.6.0 64bit server and finally applying the 1.4gb (!) 11.1.0.7.0 patch.

Tuesday, January 27, 2009 9:02:41 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0] - Trackback
64bit | Oracle
# Thursday, January 22, 2009

This is not new, but something that helped me today.

When debugging, you can see the types in scope in the auto’s window:

Default debugger

This shows only the relevant information after expanding the view. One way of improving the experience is by implementing the ToString() method.

ToString method

While this helps a lot, this means you can’t use the ToString method for something else. Luckily in VS 2008 the DebuggerDisplayAttribute was introduced, this allows you to achieve the same effect and more.

DebuggerDisplayAttribute

And the code:

[System.Diagnostics.DebuggerDisplay("Date:{Date}, Value:{Value}", Name="{Name}")]
class Item
{
    public string Name { get; set; }

    public DateTime Date { get; set; }

    public int Value { get; set; }
}
Thursday, January 22, 2009 8:31:28 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0] - Trackback
C# | Codesnippet
# Tuesday, December 30, 2008

String.Join concatenates an array of strings together without checking for empty entries. This means the separator character is added twice, between non-empty items sometimes.

String[] input = {foo, null, bar};

var result = String.Join(",", input);

// result == "foo,,bar"

My alternative uses the IEnumerable.Aggregate extension method, it checks for there empty entries and when it finds one doesn't add a redundant separator.

 string[] input = { "foo", null, "bar" };
 string result = input.Aggregate((x, y) => String.IsNullOrEmpty(y) ? x : string.Concat(x, ",", y));

// result == "foo,bar"
Tuesday, December 30, 2008 5:40:12 AM (Pacific Standard Time, UTC-08:00)  #    Comments [1] - Trackback
Codesnippet
# Monday, November 03, 2008

After a week of geeking out, PDC 2008 is over. It was an intense week with a bunch of interesting announcements and promising technologies.

The highlights:

Dublin”: an application server build upon IIS 7 (Win2k8) hosting WCF and WF 4.0. But it’s more! Besides hosting WCF and WF, it also includes tooling (in the IIS management interface and Power Shell commandlets), templates in Visual Studio for deploying and a database filled with management information. (See also: BB18).

Geneva”: an STS (Security Token Server) which allows you to extract the authentication from your applications (making it the problem of the IT professionals ;-)). Using the Geneva Server and the Geneva Framework federation, extracting metadata about your users from diverse sources (age, shoe size etc.) becomes a matter of configuration instead of a matter of fragile hardcoded queries. (See also: BB42).

C# Futures: dynamic types, a little love from the dynamic languages for their static cousins. (See also: TL16 and TL10).

Boku: the best presentation from MSFT research, a ‘game’ which allows you to program using an Xbox controller.

Oslo”: a language “M”, a visual modeler “Quadrant” and a repository. Everything is data, the quadrant visual modeler is stored as data in the repository. “M” (and MGrammer and MSchema) allows you to define your own DSL for your problem (e.g. music library with songs), build a grammar for it and create an object graph in memory. Quadrant is a visual modeler for your Visual DSL, which gives your end users a very rich editing experience. I did a hands on lab with “Oslo” and Dublin, modeling a WCF and WF solution and deploying it all from Quadrant, very slick! (See also: TL23 and TL31).

Windows Azure: making hosting easy and cheap. Combined with all the announced services (.NET Services, SQL Services, Access Services, Workflow Services etc.) this is a very compelling story for hosting your websites and –applications without the headaches of scaling and maintenance. (See also: ES16 and BB01).

CodeContract class: the new CodeContract class in .NET 4.0 allows you to defined pre- and post-conditions for the parameters of your methods (should never be null) and uses static analysis to verify those conditions. (This and more changes to the CLR in 4.0 see: PC49).

Expect more detailed posts about these and other subjects after my vacation.

See you at PDC 2009 (17 November 2009 – 20 November 2009).

Monday, November 03, 2008 8:33:08 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0] - Trackback
Conference | PDC2008
Ads
About
© Copyright 2012
Paul van Brenk
Sign In
newtelligence dasBlog 2.3.2011.0
All Content © 2012, Paul van Brenk
DasBlog theme 'Business' created by Christoph De Baene (delarou)