Sergey Shishkin

on agile software development

Archive for September 2006

Installing CardSpace Samples (Vista RC1)

Just install them under your local built-in Administrator account. I could not install CAPICOM while being logged in as a member of local Administrators group, neither using this new "Run as administrator" feature, nor from command line with regsvr32. Maybe disabling UAC could solve the problem, but I was just lazy to reboot the machine and test it. However, under the local Administrator account installation scripts run just perfectly.

Written by Sergey Shishkin

25.09.2006 at 17:49

Posted in Uncategorized

Enterprise Library: ContextItems and ExtendedProperties Fix

Yet another Enterprise Library 2.0 Logging Application Block fix here. All values that are stored in the CallContext using the EntLib’s ContextItems class are populated to the LogEntry.ExtendedProperties dictionary during the LogEntry processing in the LogWriter class. The problem is that these values are populated only after the LogEntry is considered to be logged, i.e. after all the filters are passed. So, there is no opportunity to use these values during the ShouldLog phase in a custom filter, which I consider as a design flaw. To involve CallContext items into the entries filtering, one needs to move just two lines of code from one method to another. Here is the fix:

Logging\LogWriter.cs, Line 376, Remove:

              
ContextItems items = new ContextItems();
items.ProcessContextItems(log);

Logging\LogWriter.cs, Line 237, Add:

              
ContextItems items = new ContextItems();
items.ProcessContextItems(log);

Written by Sergey Shishkin

22.09.2006 at 18:07

Posted in Uncategorized

Windows CardSpace Killer

Finally, I have found the CardSpace killer that has been making me crazy for about a month!

Symptoms

When I launch the Windows CardSpace Control Panel Applet it flashes shortly and then disappears forever. Next tries causes this error message to appear: "The Windows CardSpace control panel applet failed to start. An error occurred accessing the Windows CardSpace. Please check the event log for more details". I experienced the same problem on two different machines with XP and Vista (Beta 2 and RC1) on each.

Event log says just that "The Windows CardSpace service is too busy to process this request. User has too many outstanding requests", and provides a stack trace:

              
Additional Information:
at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
at System.Environment.get_StackTrace()
at Microsoft.InfoCards.Diagnostics.InfoCardTrace.BuildMessage(InfoCardBaseException ie)
at Microsoft.InfoCards.Diagnostics.InfoCardTrace.TraceAndLogException(Exception e)
at Microsoft.InfoCards.Diagnostics.InfoCardTrace.ThrowHelperError(Exception e)
at Microsoft.InfoCards.UIAgentMonitor.AddNewClient(UIAgentMonitorHandle handle)
at Microsoft.InfoCards.UIAgentMonitorHandle.CreateAgent(Int32 callerPid, WindowsIdentity callerIdentity, Int32 tsSessionId)
at Microsoft.InfoCards.RequestFactory.CreateClientRequestInstance(UIAgentMonitorHandle monitorHandle, String reqName, IntPtr rpcHandle, Stream inStream, Stream outStream)
at Microsoft.InfoCards.RequestFactory.ProcessNewRequest(Int32 parentRequestHandle, IntPtr rpcHandle, IntPtr inArgs, IntPtr& outArgs)

Troubleshooting

Reinstalling the framework and Visual Studio did not help as well as searching the internet for these error descriptions.

After installing fresh Windows Vista RC1 I checked the CardSpace – it worked perfectly! After installing on top of it Office 2007 Beta 2 TR, VS 2005, SQL 2005 Express, and some other small software I got already known errors! I reinstall Vista RC1 once again – CardSpace works! Installing new software, checking CardSpace and making incremental hard drive images, I found the CardSpace killer! I was not any of Microsoft beta or RTM software, not a community developer tool, it actually had nothing common even with .NET! It was small, xcopy deployable, old-fashioned Win32 instant messenger – Miranda IM, which I use to access the ICQ IM network.

After some investigation I found out that Miranda crashes CardSpace service even without any of the networks plugins! I have no idea where this incompatibility came from, but after exiting Miranda and restarting Windows CardSpace service CardSpace works perfectly again.

<added date="13.11.2006">
Discussion on MSDN Forums: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=899841&SiteID=1.
Discussion on Miranda IM Forums: http://forums.miranda-im.org/showthread.php?t=11677.
Reported issue to the Miranda IM Bug Tracker: http://bugs.miranda-im.org/view.php?id=2694.
</added>

Written by Sergey Shishkin

22.09.2006 at 17:27

Posted in Uncategorized

Enterprise Library: Couple of fixes

Working with Enterprise Library 2.0 I faced several issues. Two of them I describe here (fixes included 🙂 ).

1. I tried to add values in the Hashtable that is stored in the CallContext under the "EntLibLoggerContextItems" key to get these values populated to the LogEntry.ExtendedProperties dictionary. This is another long story why did not I use ContextItems.SetContextItem method instead of hacking it, and I will post about it separately 🙂 This functionality works fine – the Hashtable from the CallContext is being merged to the LogEntry.ExtendedProperties dictionary during processing the LogEntry by the LogWriter and ContextItems.ProcessContextItems method. Nevertheless, it has a flaw – instead of storing objects themselves, ContextItems.ProcessContextItems method calls ToString method on each object and stores the strings! It also does Base64 encoding for byte[] values but ToString looks like an ugly hack, since both LogEntry.ExtendedProperties dictionary and ContextItems.SetContextItem method accept not only strings but any objects.

File: Logging\ContextItems.cs, Line 87.
Change:

              
string itemValue = GetContextItemValue(entry.Value);
log.ExtendedProperties.Add(entry.Key.ToString(), itemValue);

To:

              
log.ExtendedProperties.Add(entry.Key.ToString(), entry.Value);

2. The second problem I found in the QuickStart project – SQLConfigurationSource. I always got the ConfigurationException saying "Expected to find an element". Which element? No idea. Debugging and reflecting I found out that this exception is always thrown by the ConfigurationSection.DeserializeSection method expecting an element and getting a whitespace instead. So, I have asserted my developer’s right to have whitespaces as well as comments inside the configuration XML stored in the SQL Server 🙂 Here is the fix:

File: SQLConfigurationSource\Configuration\SqlConfigurationSystem.cs, Line 115
Change:

              
XmlReaderSettings settings = new XmlReaderSettings();
settings.CloseInput = true;

To:

              
XmlReaderSettings settings = new XmlReaderSettings();
settings.CloseInput = true;
settings.IgnoreWhitespace = true;
settings.IgnoreComments = true;

That’s it!

Written by Sergey Shishkin

19.09.2006 at 14:48

Posted in Uncategorized