mostlylucid

April 2005 Entries

Sahil Malik [MVP] : System.Transactions - Beta2 Changes - and other good stuff

Sahil Malik [MVP] : System.Transactions - Beta2 Changes - and other good stuff

Really nice article on Systems.Transactions…with a nice example of working with files transactionally. Also been reading this blog which sheds more light on Transactional NTFS – a fantastic feature in Longhorn which doesn’t just look all snazzy but actually does something of benefit to everyone… 

Great book...

I’ve been reading the current debate on Microsoft’s position on an anti-discrimination bill in the US right now, I have no right to comment on this other than to say that I value consistency and fairness above most other things in life.
What I am reminded of though is a book I’m reading right now, Hackers & Painters by Paul Graham – this is a truly brilliant book, examining all sorts of stuff to do with ‘hacker philosophy’ including the obsession ‘hackers’ have with freedom of speech and freedom of expression. I hadn’t really twigged before just how intertwined hacking (oh. I’m using hacking in the ‘proper’ sense here) and civil liberties actually are anyway, fantastic book which I recommend everyone to read.  

Ooh, new (allegedly) XBOX 360 image...

Well, before the NDA kicks in  The picture below (which I found here) claims to be of the new XBOX 360, it also seems consistent with ‘official’ pictures showing bits of the machine. Anyway, hope it is real, it looks pretty awesome!
  xbox_360s.jpg image

Man, the BBC is slipping!

Take a look at this story on HD-DVD here’s a couple of extracts which I just don’t get:

“This offers incredible 3D-like quality pictures which major Hollywood studios and games publishers are extremely keen to exploit. “

“Gamers will also benefit from the next generation of discs. The storage capacity means that console titles will fit onto a single disc and the graphics will be much improved, almost film-like.”

I mean what? What is 3D-like quality? What console games don’t currently fit on a single DVD?

Assimilated the red kool aid...umm...

Well, looks like I’ll be joining Microsoft – and I couldn’t be happier . Yet to get all the details sorted (and I really have to get my driving test sorted out…) but I can’t wait!

No news yet...

Just in case you’re wondering, presentation went OK, team seems really good. So, we’ll see (should be later today or tomorrow)!

The Code Project - An improvement to RegisterClientScriptBlock - ASP.NET

The Code Project - An improvement to RegisterClientScriptBlock - ASP.NET

Very handy but I always forget where to find it…so here it is, an enhanced RegisterClientScriptBlock.

Playing with System.Transactions...

Ahead of the horror of tomorrow…here’s a little class I was playing with as a demo, let me know what you think (it’s partially based on this example)

using System;

using System.Collections.Generic;

using System.Text;

using System.Transactions;

using System.Collections;

namespace TransTest

{

    public class TransactedHashtable : Hashtable, IEnlistmentNotification, ISinglePhaseNotification, IPromotableSinglePhaseNotification

    {

        Transaction transaction;

 

        Hashtable holdingTable;

        public TransactedHashtable()

        {

            Enlist();

            holdingTable = new Hashtable();

        }

 

        void Enlist()

        {

 

            transaction = Transaction.Current;

            if (transaction != null)

                transaction.EnlistVolatile(this, EnlistmentOptions.None);

        }

        public override void Add(object key, object value)

        {

            if (transaction == null || transaction != Transaction.Current) Enlist();

            holdingTable.Add(key, value);

        }

 

 

        void OnCommit()

        {

            foreach (DictionaryEntry de in holdingTable)

            {

                base[de.Value] = de.Value;

            }

            holdingTable.Clear();

        }

 

        #region IDisposable Members

 

        public void Dispose()

        {

            base.Clear();

        }

 

        #endregion

 

        #region IEnlistmentNotification Members

 

        public void Commit(Enlistment enlistment)

        {

            OnCommit();

            enlistment.Done();

        }

 

        public void InDoubt(Enlistment enlistment)

        {

 

        }

 

        public void Prepare(PreparingEnlistment preparingEnlistment)

        {

            preparingEnlistment.Prepared();

            //preparingEnlistment.Done();

        }

 

        public void Rollback(Enlistment enlistment)

        {

            holdingTable.Clear();

        }

 

        #endregion

 

        #region ISinglePhaseNotification Members

 

        public void SinglePhaseCommit(SinglePhaseEnlistment singlePhaseEnlistment)

        {

            OnCommit();

            singlePhaseEnlistment.Committed();

        }

 

        #endregion

 

        #region IPromotableSinglePhaseNotification Members

 

        public void Initialize()

        {

        }

 

        public Transaction Promote()

        {

            return transaction.Clone();

        }

 

        public void Rollback(SinglePhaseEnlistment singlePhaseEnlistment)

        {

            this.holdingTable.Clear();

        }

 

        #endregion

    }

}

using System;

using System.Collections.Generic;

using System.Text;

using System.Transactions;

using System.Collections;

using System.Data.SqlClient;

 

namespace TransTest

{

    class Program

    {

        static void Main(string[] args)

        {

 

 

 

            TransactedHashtable t = new TransactedHashtable();

 

            using(TransactionScope ts = new TransactionScope())

            {

                using (SqlConnection conn = new SqlConnection("database=Northwind;data source=127.0.0.1;Integrated Security=SSPI;"))

                {

                    conn.Open();

                    SqlCommand comm = new SqlCommand("UPDATE    Customers SET City = 'New York' WHERE    (CustomerID = 'ALFKI')");

                    comm.Connection = conn;

                    comm.ExecuteNonQuery();

                }

                t.Add("aaaaa", "aaa");

                t.Add("bbbbb", "bbb");

                ts.Complete();

            }

 

            foreach(DictionaryEntry de in t )

            {

                Console.WriteLine(de.Key.ToString() + " :: " + de.Value.ToString());

            }

 

            using (TransactionScope ts = new TransactionScope())

            {

                using (SqlConnection conn = new SqlConnection("database=Northwind;data source=127.0.0.1;Integrated Security=SSPI;"))

                {

                    conn.Open();

                    SqlCommand comm = new SqlCommand("UPDATE    Customers SET City = 'Berlin' WHERE    (CustomerID = 'ALFKI')");

                    comm.Connection = conn;

                    comm.ExecuteNonQuery();

                }

                t.Add("ccccc", "ccc");

                t.Add("ddddd", "ddd");

                //ts.Complete();

            }

 

            foreach (DictionaryEntry de in t)

            {

                Console.WriteLine(de.Key.ToString() + " :: " + de.Value.ToString());

            }

            Console.ReadLine();

        }

    }

}


Since the second add block doesn’t commit the transaction, it’s not committed (and rolled back…which just means I don’t add them to the hashtable in this instance). Anyway, I thought it was a nice little example…opinions???

UPDATE: Very much a work in progress (since there's virtually no documentation on how to do this yet), just updated this to support promotion, the above example just uses the SQL connections to force promotion to the OLETx Manager (using MSDTC)...suspect this will become pretty common in the years to come :0)

Why oh why???

Why doesn’t Windows XP SP2 not have a bluetooth headset profile – are they mental???

Ooh, found a fantastic new (for me) blog!

Why have I never seen this blog before? Whilst on the trawl through the web for more on System.Transactions (go on, ask me anything ) I discovered this fantastic blog, great content, interesting topics, the lot!

Bit of a long shot - anyone have an example of XML Configuration for System.Transactions?

Well, I’m currently beetling away on my presentation for Tuesday – “Transactions with System.Transactions in .NET 2.0” have to say, it’s a big area (well, System.Transactions isn’t, existing EnterpriseServices is…). I’ll get together a list of resources on this after my presentation (not sure if it’d be wise to give away too much ). One thing I can’t find anything on though is configuration of System.Transaction transactions using the application config file so, anyone know anything about this please let me know (I can’t believe the docs just don’t exist)!

Wierd Server Control issue - ever lose Viewstate for your Container object?

OK, bit of an unusual issue – but this happened to me when using a Server Control which extended another, parent control. Essentially I was binding an ITemplate on to a Container control to allow for DataBinding problem was that on reload, the child controls of my Server Control (in this instance, the Container) was not being recreated – which was a problem for saving content…Well the issue came down to not implementing INamingContainer on the child server control (I had it on the parent) – which results in problems for the control tracking it’s ViewState problem. Anyway, as I said odd issue but might save someone else the same problem! 

The Code Project - Simulated Multiple Inheritance Pattern for C# - C# Programming

The Code Project - Simulated Multiple Inheritance Pattern for C# - C# Programming

Really interesting pattern…not sure how much I’d want to rely on it for all but the most edge cases but nice read anyway…

Really nice article on .NET Data Access

Steven Smith has a great little article on ASPAllicance on comparing performance and methods of performing data access in .NET applications. Some really interesting techniques there, I especially like the IDataReader delegate example, a really nice solution to passing IDataReaders between layers in an app…

NHibernate

NHibernate
Must check out this Object-Persistence framework in more detail…

Scott Galloway

CodeGuru: Inter-Process Communication in .NET Using Named Pipes, Part 1

CodeGuru: Inter-Process Communication in .NET Using Named Pipes, Part 1
Now this is really cool! Really fast, efficient solution for Inter-Process Communication in .NET (until IPC Channel arrives in .NET 2.0)!
Just noticed, this remoting channel example for Named Pipes too...
And really great remoting links can be found here...

Scott Galloway

The Code Project - Hacking out the C# 2.0 Iterators - C# Programming

The Code Project - Hacking out the C# 2.0 Iterators - C# Programming

Interesting article…lets you use C# 2.0 style iterators in 1.1. Not sure how useful this would actually be in practice but it’s still a good read!

All the MVP wierdness...

Well, you can tell it’s MVP time again, the usual backbiting, patronizing comments from those with seriously over-inflated egos you know the kind of thing. Anyway, I’ve said before I’d love to be awarded an MVP but I’ll probably never get one, and that’s fine too…
I’ve always been concerned about the whole MVP thing, there seem to be a lot of mixed messages out there and I haven’t seen anyone clear it up, there’s just too many MVPs who just seem to be on the list because they either work at large Microsoft target companies (so sales driven appointments), push products targeted at Microsoft Technologies (PR driven appointments), who’ve written a couple of books (targeted at getting them to write more I suppose) or are paid to speak  about MS technologies (unofficial evangelists).
I’ve never really understood that – arent’s these people supposed to be the ‘people’s champions’, providing support to the community yadda yadda…from the site:

Q2: Why does the award exist?

A2: Microsoft believes that a robust, interactive user community is key to helping customers maximize the solutions and benefits from their software investments. The MVP Award is the way Microsoft recognizes those participants who have made a highly positive impact in the technical and product communities in which they participate. Microsoft wants community participants and leaders to know that their contributions are greatly appreciated. The MVP Award exists as a way to reach out to and thank outstanding members for their past participation and willingness to help others in these communities, both online and offline.

Cool – unfortunately there’s just too many who from my viewpoint don’t seem to meet any of these requirements…maybe it’s time to lose some MVPs? Maybe the partner program could be extended to include the businesses who contribute to Microsoft  but don’t really give back to the community??? Oh, and include more fat scottish guys as MVPs…that’d be nice

Interesting method of deep-cloning objects

I though that this was a really nice method of implementing deep cloning of objects – uses serialization so the usual problems apply…

More on Viewstate Compression

Seems like this won’t die…Scott Hanselman just posted some stuff on Viewstate compression, this is pretty similar to a technique I posted a while ago with the addition of a technique mentioned by Mark DeMichele.

Second chances

A while ago I posted about a job I’d applied for as a result of a blog posting…well, at that point some things were going on in my life which would have made it a major problem to move 500 miles down to Reading for this job…long story short, the situation changed.
 In a couple of weeks I have the final part of the recruitment process for this same job; I’ve already been through a telephone screen and an in-person interview. So on April 19th I’ll be heading down to Reading  to do a presentation to a bunch of people in the same team I hope to work on (the PSfD team…nice MS acronym ). I have to say, I’m really nervous about this…I’ll get the presentation topic 3 days before the actual presentation…being the aspergery wierdo I am I will of course be reading a few dozen books before then to try and get a jump on the topic .
So that’s the situation…well…it is kind of contingent on my Passport arriving in time (theoretically it should take 3 weeks but the UK Government being the way it is you never know…). Luckily I thought to check my passport just before the previous part of the interview process and discovered it had expired in December…and bizarrely I have no other photographic ID…so a long train journey may be ahead…
Anyway I really do want this job – I’m not really the type to pretend about such things – and my employer is fully informed as to the situation…so fingers crossed!
UPDATE: Passport arrived, flight booked...it's starting to seem a little to real now...gulp...and the picture in my passport makes it look like my face has been squished up against a bus...

Semi-online again...

Back to posting (though at reduced frequency) now…get back to full service in a week or so…at which time I’ll also hopefully work out a reliable method of updating to Community Server (so far none of the converters I’ve tried work…)