Mike Taulty's Blog
Bits and Bytes from Microsoft UK

March 2008 - Mike Taulty's Blog

Blogs

Mike Taulty's Blog

Elsewhere

  • Silverlight 2 - Passing Data Across Plug-In Instances

    Again, this falls into the category of "just for fun" but it's something that I wanted to experiment with. I wanted to see how easy it was to put together something that passed data from one Silverlight plug-in instance on a page to another instance (on the same page). Silverlight applications are running in separate application domains even if they're on the same HTML page so you can't really use anything other than the HTML DOM itself or perhaps a back-end service to communicate between them. I went with the DOM route. I created a Silverlight class library project as I figure I'd want to reference the code I write from a number of Silverlight applications that want to talk to each other. I guessed that if I register a scriptable object with a "well known" name from each of my Silverlight applications then they'll be able to talk to each other by invoking a method on the instance of that object that they each register. As far as I know, I have to have an instantiatable class in order to register a scriptable...
    Filed under:
  • Entity Framework - Serializing Graphs of Entities

    Julie points to Danny and Danny points to the next CTP of Entity Framework - if you're interested in serializing the entities that Entity Framework returns back to you then you'll be interested in this; http://www.thedatafarm.com/blog/2008/03/28/HallelujahEntityGraphsWillBeXMLSerializable.aspx
  • Silverlight 2 - Update to previous post around clientaccesspolicy.xml

    Just an update to this post as I got a little worried after publishing it :-) In case it wasn't obvious - you wouldn't really want to use a clientaccesspolicy.xml file like the one that I used which says "Allow anybody to do anything" as that'd more than likely be a bad idea. In my specific case, that would mean that any Silverlight application could try (if it knew the URL) to access my local console application via its SOAP based interface and that's almost not what I'd want. So...I'd want to tailor client access policy to only allow cross-site access (in this case to the local machine via my SOAP service) to sites that I trusted.
    Filed under:
  • Silverlight 2 - Talking to a Local WCF Service from a Silverlight Application

    This really falls into the category of "just because it's there" because it's something I was thinking about earlier today and wanted to experiment with. Silverlight 2 applications can make web service calls across domain boundaries if the domain that they are calling to allows that. So, I was thinking about a scenario where perhaps I've got a local application installed such as a WPF application or perhaps a Vista Sidebar gadget and I go and visit a Silverlight website and the Silverlight client can notify the installed application and cause it to maybe "light up" in some fashion. That is, a Silverlight 2 application communicating with another application that's installed and running on the local machine. Before Silverlight will allow a cross-domain call it requests one of two files from the root of the site that it's calling to. I chose to use clientaccesspolicy.xml. So, I wrote a quick "WCF Service" using the System.ServiceModel.Web stuff from .NET Framework V3.5. Service looks like this; [ServiceContract]...
    Filed under:
  • Silverlight 2 - Simple Editing of Web Service Data in a DataGrid

    Somebody asked how you use the DataGrid in Silverlight 2 in order to load data from a web service, modify it and submit it back so I thought I'd spend 5 minutes experimenting with that. I wrote a very simple web service with WCF; [DataContract] public class Person { [DataMember] public int Id { get; set; } [DataMember] public string FirstName { get; set; } [DataMember] public string LastName { get; set; } [DataMember] public int Age { get; set; } } [ServiceContract] public interface IPeopleService { [OperationContract] List<Person> GetPeople(); [OperationContract] void UpdatePeople(List<Person> inserts, List<Person> updates, List<Person> deletes); } and implemented it in the simplest possible way ( no thread-safety, no concurrency ); public class PeopleService : IPeopleService { static PeopleService() { people = new Dictionary< int , Person>(); people.Add(1, new Person() { Id = 1, FirstName = "Mike" , LastName = "Taulty" , Age = 18 }); people.Add(2, new Person() { Id = 2, FirstName...
    Filed under:
  • Skinning Silverlight Controls

    Corrina has posted 4 skins so far for some of the standard Silverlight controls; Bubbly View Download Red View Download Flat View Download and the 4th one is hanging off this post here; A New Control Skin Set
    Filed under:
  • Silverlight, Custom Controls, Generic.xaml, Dictionaries, Errors

    I found these 3 posts really useful around controls, generic.xaml, resource dictionaries and error codes for Silverlight 2; http://marlongrech.wordpress.com/2008/03/19/genericxaml-in-silverlight-beta1-for-wpf-developers/ http://www.codeproject.com/KB/silverlight/mediabutton.aspx http://exdream.no-ip.info/blog/2007/07/20/SilverlightErrorCodesExplained.aspx
    Filed under:
  • LINQ to SQL and SqlConnection ( "when you're wrong, you're wrong" :-) )

    I was talking to Ian and another chap at the UK Launch yesterday about LINQ to SQL and my use of the DataContext in some demo code where I always tend to write something like; using (DataContext ctx = new DataContext()) { } and whether I actually needed to do that dispose or not? Now...I was pretty confident that I do need to do this for two reasons; DataContext is disposable so I figure I should probably Dispose() of it - generally been my approach to anything IDisposable. Someone had recently asked me whether DataContext.Dispose() actually did close the SQL connection and I'd done a little bit of reflecting on it and spotted that; DataContext.Dispose() -> SqlProvider.Dispose() -> SqlConnectionManager.DisposeConnection() -> SqlConnection.Close() although the code paths are more complex than that and I haven't attempted to figure out under what conditions the various calls happen. So, I'd kind of reasoned that; If you don't dispose of the DataContext then you won't get the connection closed and back in...
    Filed under: ,
  • LINQ Talk at UK Visual Studio 2008 Launch

    I did a talk yesterday down at the UK Launch of Visual Studio 2008, SQL Server 2008 and Windows Server 2008 about Language Integrated Query as it stands in VS 2008 and .NET Framework V3.5. Firstly, thanks to everyone who came along to the talk - much appreciated. Also a massive thanks to the guys who helped us out with the track at the launch namely; Guy , Andy and Amanda who did a stunning job. An equally massive thanks to the guys who helped us out in the community area, the ATE and the labs who were all doing a great job - I won't list names here but you know who you are and what a big difference you made to the event :-) If you want to catch up on the launch after the event then you can check out the new ( Silverlight based ) Virtual Launch Experience which is up here; Virtual Launch Experience Now...the content isn't 100% the same as what we did in Birmingham so I thought I'd share my session with you here in written form in case you wanted some snippet from it. Firstly, here's the slides in PPTX , PPT and...
    Filed under: , ,
  • Silverlight 2 & Sockets

    I was bored in my hotel room so I thought I'd have a bit of a play with Silverlight 2 and sockets - you can ( in beta 1 ) open sockets back to the site of origin within a restricted port range ( 4502 to 4532 ). I wrote a little Silverlight UI ( it's a bit much to call it a UI as it only has one TextBlock on it :-) ); < Grid x:Name ="LayoutRoot" Background ="Gray" > < TextBlock x:Name ="theText" FontSize ="24" Text ="Not set" HorizontalAlignment ="Center" VerticalAlignment ="Center" /> </ Grid > and then I wrote some code behind this to update the textblock based on a time that I receive from the server. I wrote a little class to try and help me with that ( no doubt riddled with bugs :-) ); public class DateTimeEventArgs : EventArgs { public DateTime NewDateTime { get; set; } } public class SocketDateTimeReader { public string Host { get; set; } public int Port { get; set; } public SocketDateTimeReader () { socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); ...
    Filed under:
  • Silverlight 2 Diagrams

    I thought this diagram was good; and it is but then I found this diagram which is a different one but gives you all the template parts that make up the built in controls.
    Filed under:
  • Silverlight 2 - Path and File Resolution

    Path and File resolution in Silverlight 2 is confusing so, fortunately, Pete Brown has a good post on it here .
    Filed under:
  • QCon Talk - Silverlight 2

    I did a talk on Silverlight 2 at the QCon conference in London yesterday. I enjoyed it but there weren't a whole lot of people in attendance ( about 30 ) although I'd like to say thanks a lot to the people who did come along as QCon isn't necessarily the most .NET of conferences :-) I thought it might be worth splitting the talk up and blogging the whole thing here as a way of perhaps getting more re-use of what I'd put together. So...firstly, here's the slides in PPTX , PPT and PDF format Here's the demos that I worked through; 1 "Hello World" I just used Visual Studio 2008 and Expression Blend 2.5 March Preview here. First off, I created a new Silverlight project in Visual Studio 2008; took the option to create a website to test the project; and that brings up the XAML editor on my first page Page.xaml with a piece of XAML that looks like this; < UserControl x:Class ="SLOne.Page" xmlns ="http://schemas.microsoft.com/client/2007" xmlns:x ="http://schemas.microsoft.com/winfx/2006/xaml" Width ="400" Height ...
    Filed under:
  • LINQ to SQL, Stored Procs, Output Params, Readers Reading

    I had a discussion at DevWeek about when SqlDataReader.Read () gets called for resultsets coming back from stored procedures accessed with LINQ to SQL. I've got this stored proc; create procedure dbo.GetCustomersByCountry @country nvarchar( max ) as set nocount on select * from dbo.customers where country = @country and I've brought it into LINQ to SQL using the designer and that means that I can write code such as; using (NorthwindModelDataContext ctx = new NorthwindModelDataContext()) { var query = ctx.GetCustomersByCountry( "UK" ); foreach (Customer c in query) { Console.WriteLine(c.CustomerID); } } Question is - when does SqlDataReader.Read() get called here? Do we read all of the data up front and then just provide access to an in-memory collection or is the data read from the wire as the loop iterates over it? I wanted to check so I went ahead and set some breakpoints in a few places; Inside the constructor of my Customer class. Inside SqlDataReader.Read() and what I see there is an interleaved set of calls...
  • DevWeek Talk - Understanding ADO.NET Entity Framework

    I did a talk down at DevWeek this afternoon about ADO.NET Entity Framework. Whilst it was a small room, it was full and I had a great time - hopefully if you attended then you enjoyed it too and got something useful out of it. Thanks for all the questions :-) As promised, the slide-deck is available in PPTX , PPT and PDF formats although it's not a huge slide-deck as I spent a lot more time demonstrating things. It's tricky to publish some of the demo bits that I used because I have a slightly tweaked northwind database so some of what I have probably won't work for you. I will re-publish the simple querying app that I use to demo Entity SQL as that might be something you could find useful.
1 2 Next >