.Net ramblings
# Monday, 28 January 2008
Vista, CPU problems, explorer.exe, lsass.exe, SearchIndexer.exe
I was in the same boat as a lot of the folks on this MSDN forum thread.  Vista stability went out the window a few weeks ago.  mostly related to Search, but disabling the Search service only seemed to shift the problems to explorer.exe or lsass.exe.  installing SP1 RC1 refresh 2 seeemed to help but after rebuilding the index the same problems came back.  i found some useful info about lsass, and finally found a great solution by Aaron Tiensivu on his blog post about resetting a corrupt vista user profile. i didn't think it had anything to do with a corrupt profile, but the stuck-in-a-loop lsass.exe activity referencing the SamSs service made me try it out.  it did work, but after a day or two the explorer.exe CPU problems came back.  however, disabling Search has given me normal stability back, which is very welcome.  it's running smoothly so far. 

i guess Windows 7 isn't that far away really, hopefully MS will be more careful next time :)

Monday, 28 January 2008 14:27:41 (GMT Standard Time, UTC+00:00)  #    Comments [1]  General

# Thursday, 20 December 2007
GA-P35-DQ6 overclock settings
just posting my config here with a Gigabyte GA-P35-DQ6 motherboard
  • Processor: E6600 / 2.4Ghz Core Duo.
  • Ram: 4x512Mb Crucial Ballistix PC6500 4-4-4-12 @ 2.2v
  • Cooling: OCZ Vindicator
  • Disks: 74Gb 10k WD Raptor, 500Gb WD SATA 2, 1Tb WD MyBook eSATA.
My current stable overclock settings are as follows:
  • FSB 395 Mhz x9
  • Memory Multiplier 2.0
  • vCore 1.375
  • vFSB +.05
  • vMCH +.05
  • vDimm +.2
  • Memory timings: 5-5-5-18-auto-etc.
This results in a very happy 3.554 Ghz currently running @ 59 celsius under max load (orthos).  It could go a good bit higher but i don't want to be worrying about overheating problems long term since it is a work PC, and this represents about a 50% overclock which is great. 


I haven't tried pushing the memory yet but i'll try out the 4-4-4-12 @ 2.2v next.  Some earlier attempts at overclocking were foiled by bad memory settings, it was good advice i read to relax the memory settings before overclocking because it can cause stability problems that are not related to your FSB adjustments etc.

by the way, before i got these settings working, i was getting crazy temps like 79c with hardly any overclocking with this same setup. it all came down to not enough thermal paste. 

Thursday, 20 December 2007 23:08:55 (GMT Standard Time, UTC+00:00)  #    Comments [1]  General

# Wednesday, 28 November 2007
Format a FAT32 partition above 32Gb
Windows has a pointless 32Gb sizelimitation on FAT32 partitions.
a very sound chap called Tom Thornill wrote a partition formatting utility that does not have this limit. full details on his site


Wednesday, 28 November 2007 15:04:31 (GMT Standard Time, UTC+00:00)  #    Comments [0]  General | Windows Server

# Tuesday, 27 November 2007
Deploy Crystal Reports for VS 2008 (RTM)
if, like me, you were running VS 2008 Beta 2 on a server and you had crystal reports working fine, and then recompiled your projects in VS 2008 RTM, you may get an error like this when you try and create a crystal report on a production server:
System.Runtime.InteropServices.COMException (0x800736B1):
Retrieving the COM class factory for component with CLSID
{5FF57840-5172-4482-9CA3-541C7878AE0F} failed due to the following error:
800736b1. at CrystalDecisions.CrystalReports.Engine.ReportDocument..cctor()
In my case, i had installed Crystal Reports Runtime for VS 2008 Beta 2, and i never installed the runtime for the RTM version.  it should be available on your VS machine, if you opted for CR in the VS installer:
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\CrystalReports10_5

should probably uninstall the old version of the CR runtime while you're at it too. 


Tuesday, 27 November 2007 11:32:12 (GMT Standard Time, UTC+00:00)  #    Comments [2]  .Net General | Asp.Net | Windows Server

# Monday, 19 November 2007
IFRAME causes all content beneath to disappear
how weird is this.  i upgraded my CMS editor to XHTML and i suddenly find that any pages with an IFRAME have the footer cut off, completely invisible.  i found out it was because the self-closing tag (as per XHTML) screws up the page layout in IE and FF.  you have to use </iframe>, which unfortunately breaks XHTML validation, but i can live with that.
for more info see this blog post that explains it further.


Monday, 19 November 2007 11:20:35 (GMT Standard Time, UTC+00:00)  #    Comments [0]  .Net General

# Friday, 16 November 2007
Running WSE 2 and 3 side by side

Note: this doesn't really work..

i'm just leaving it here for interest.  the approach will work for the first invocation of either v2 or v3 client, but after a v2 client has used the web service, any v3 clients will fail.  MS told me this is not supported because of the 2 soapExtensions interfere with each other in the pipeline etc


My asp.net CMS has some winforms clients running WSE2, and i'm doing an upgrade to the client (and server) to use WSE3, but i want to support both versions.  Both WSE2 and WSE3 clients are using a CustomUsernameTokenManager.  it was a bit tricky to work out, but here is what i ended up doing. thanks to brian o'keefe for his newsgroup post for most of the answer.  Your exact config might vary but hopefully it will save you some of the hassle of working all this out.
  • Leave the existing web service in place, e.g. Service_WSE2.asmx
  • Create a new web service for the WSE3 client, essentially copy/paste the ASMX file, e.g. Service_WSE3.asmx
  • Create a new CustomUsernameTokenManager for the WSE3 service which inherits from Microsoft.Web.Services3.Security.Tokens.UsernameTokenManager.  In my case it was as easy as copy/paste from the WSE2 token manager and change all the WSE2 namespaces to WSE3.
  • then in web.config, make sure both WSE config sections are listed:
    <configuration>
    <configSections>
    <section name="microsoft.web.services3" type="Microsoft.Web.Services3.Configuration.WebServicesConfiguration, Microsoft.Web.Services3,Version=3.0.0.0,Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <section name="microsoft.web.services2" type="Microsoft.Web.Services2.Configuration.WebServicesConfiguration, Microsoft.Web.Services2, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </configSections>
  • add in references to both the assemblies for the compilation section (not 100% sure if this is necessary, but at least it means the app will not compile on the production server if you forget to deploy either of the WSE assemblies, instead of waiting till one of your clients connects).

    	<compilation defaultLanguage="c#" debug="true">
    <assemblies>
    <add assembly="Microsoft.Web.Services2, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add assembly="Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  • remove the <webServices> section from <system.web>, because each web service should be configured by location, not global as this interferes.

    	<location path="Service_WSE2.asmx">
    <system.web>
    <webServices>
    <soapExtensionTypes>
    <add type="Microsoft.Web.Services2.WebServicesExtension, Microsoft.Web.Services2, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" priority="1" group="0" />
    </soapExtensionTypes>
    </webServices>
    </system.web>
    </location>

    <location path="Service_WSE3.asmx">
    <system.web>
    <webServices>
    <soapExtensionTypes>
    <clear/>
    </soapExtensionTypes>
    <soapServerProtocolFactory type="Microsoft.Web.Services3.WseProtocolFactory, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    <soapExtensionImporterTypes>
    <add type="Microsoft.Web.Services3.Description.WseExtensionImporter, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </soapExtensionImporterTypes>
    </webServices>
    </system.web>
    </location>
  • my webservice policy are defined in policyCache.config files, so the following web.config sections point each version of WSE to the right file:
    	<microsoft.web.services3>
    <policy fileName="policyCache_WSE3.config"/>
    <security>
    <securityTokenManager>
    <add type="Whatever.CustomUsernameTokenManager3" namespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" localName="UsernameToken"/>
    </securityTokenManager>
    </security>
    </microsoft.web.services3>
    <microsoft.web.services2>
    <messaging>
    <maxRequestLength>10000</maxRequestLength>
    </messaging>
    <security>
    <securityTokenManager type="Whatever.CustomUsernameTokenManager2, MyAssemblyName" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
    qname="wsse:UsernameToken" />
    <defaultTtlInSeconds>86400</defaultTtlInSeconds>
    <timeToleranceInSeconds>86400</timeToleranceInSeconds>
    </security>
    <policy>
    <cache name="policyCache_WSE2.config" />
    </policy>
    </microsoft.web.services2>
  • and lastly, the policy cache files themselves:
    WSE 3 version
    <?xml version="1.0"?>
    <policies xmlns="http://schemas.microsoft.com/wse/2005/06/policy">
    <extensions>
    <extension name="usernameOverTransportSecurity" type="Microsoft.Web.Services3.Design.UsernameOverTransportAssertion, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <extension name="requireActionHeader" type="Microsoft.Web.Services3.Design.RequireActionHeaderAssertion, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </extensions>
    <policy name="usernameTokenSecurity">
    <usernameOverTransportSecurity />
    <requireActionHeader />
    </policy>
    </policies>
  • WSE 2 version
    <?xml version="1.0"?>
    <policyDocument xmlns:wse="http://schemas.microsoft.com/wse/2003/06/Policy" xmlns="http://schemas.microsoft.com/wse/2003/06/Policy">
    <mappings xmlns:wse="http://schemas.microsoft.com/wse/2003/06/Policy">

    <endpoint uri="http://localhost/Service_WSE2.asmx">
    <defaultOperation>
    <request policy="#username-token-signed" />
    <response policy="" />
    <fault policy="" />
    </defaultOperation>
    </endpoint>

    <defaultEndpoint>
    <defaultOperation>
    <request policy="" />
    <response policy="" />
    <fault policy="" />
    </defaultOperation>
    </defaultEndpoint>

    </mappings>
    <policies xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <wsp:Policy wsu:Id="username-token-signed" xmlns:wsp="http://schemas.xmlsoap.org/ws/2002/12/policy" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing" xmlns:wssp="http://schemas.xmlsoap.org/ws/2002/12/secext">
    <wsp:MessagePredicate wsp:Usage="wsp:Required" Dialect="http://schemas.xmlsoap.org/2002/12/wsse#part">
    wsp:Body() wsp:Header(wsa:To) wsp:Header(wsa:Action) wsp:Header(wsa:MessageID) wse:Timestamp()
    </wsp:MessagePredicate>
    <wssp:Integrity wsp:Usage="wsp:Required">
    <wssp:TokenInfo>
    <SecurityToken xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext">
    <wssp:TokenType>http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#UsernameToken</wssp:TokenType>
    <wssp:Claims>
    <wssp:UsePassword wsp:Usage="wsp:Required" />
    </wssp:Claims>
    </SecurityToken>
    </wssp:TokenInfo>
    <wssp:MessageParts Dialect="http://schemas.xmlsoap.org/2002/12/wsse#part">
    wsp:Body() wsp:Header(wsa:Action) wsp:Header(wsa:FaultTo) wsp:Header(wsa:From) wsp:Header(wsa:MessageID) wsp:Header(wsa:RelatesTo) wsp:Header(wsa:ReplyTo) wsp:Header(wsa:To) wse:Timestamp()
    </wssp:MessageParts>
    </wssp:Integrity>
    </wsp:Policy>
    </policies>
    </policyDocument>


Friday, 16 November 2007 12:16:50 (GMT Standard Time, UTC+00:00)  #    Comments [1]  .Net General | .Net Windows Forms | Asp.Net

# Tuesday, 09 October 2007
MultiThreading In CF2 with Delegates
what a frustrating problem this was.  delegates weren't support in CF1, but now we have CF2 and according to microsoft:

The .NET Compact Framework 2.0 now supports asynchronous execution of a delegate on a user interface thread. Unlike the .NET Compact Framework 1.0 that supports only the Control.Invoke method (which synchronously executes a delegate on a control's owning thread), the .NET Compact Framework 2.0 provides Control.BeginInvoke that asynchronously executes a delegate on the control's owning thread. The Control.EndInvoke method is also provided. When called, the EndInvoke method returns the results of an asynchronous operation.

This is great but it's easily assumed that delegates are fully supported now in CF2, but no such luck.  they don't say that calling BeginInvoke on a delegate will cause your application to crash (with a NotSupportedException) even though it will compile in visual studio without warning or error.  there is an excellent (if lengthy) discussion on the matter on this newsgroup post.  the long and short of it is that you should use the ThreadPool class instead of using delegates to fire off worker threads.  You can still use delegates to send a function back to the UI thread just like in winforms.  Notice in the code below that the method signature of the function you are starting the thread on, requires a single 'object' parameter.
using System.Threading;

private void Button_Click(etc)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(this.DoSomeWork));
}

private void DoSomeWork(object o)
{
...
}

Tuesday, 09 October 2007 15:00:03 (GMT Daylight Time, UTC+01:00)  #    Comments [0]  .Net Compact

# Monday, 08 October 2007
Look After Your Eyes!
i went to the optician yesterday for an annual check up, i'm always a bit worried because i write code for most of the day and that's not very healthy for eyes etc etc.  i know you're supposed to take breaks every 15 mins or so but that's difficult to do in practice.
the test showed one of my eyes with a very slight deterioration which makes no difference really but still i found it quite alarming that i'm doing damage to my eyes, specially since you only get 2 for your whole life.  i dug out a program i wrote a few years ago to go 'ding' in the background every 10 minutes to remind you to take an eye break.  apparently relaxing your eyes on a distant object for a minute or two is a good idea etc.  i was going to post up my little exe file but then i went looking and found "TakeYourBreak" on download.com, it is a much better program!


Monday, 08 October 2007 15:44:00 (GMT Daylight Time, UTC+01:00)  #    Comments [0]  General

# Tuesday, 02 October 2007
Bug in ComboBox SelectedIndex
big bug in ComboBox control here: http://support.microsoft.com/default.aspx?scid=kb;en-us;327244
you have to set the SelectedIndex to -1 twice in a row if you want it to take effect!
i came across this in a compact framework app, but it looks like it applies to win-forms as well.


Tuesday, 02 October 2007 17:17:18 (GMT Daylight Time, UTC+01:00)  #    Comments [0]  .Net Compact | .Net Windows Forms

# Tuesday, 18 September 2007
Profiler For SQL 2005 Express
wow, i never knew this existed: http://sqlprofiler.googlepages.com/
thanks to nikolay.zhebrun
it works great.


Tuesday, 18 September 2007 13:43:58 (GMT Daylight Time, UTC+01:00)  #    Comments [0]  .Net General | Database