Whaly's World tail -f /var/log/whaly

3Apr/120

Lightroom SDK Getting Started

Download the Lightroom Plugin SDK
Download the Lua stuff

Interresting ressource on Assembla lrdevplugin
> Getting Started
> Editor and workflow

Tagged as: , No Comments
22Feb/120

Using WinDbg to find the cause of an IIS crash in production.

We had a dump file of the crash \o/ and I had a Microsoft training on this subject 3 month ago with the impressive Christophe Nasarre.

Opening the dump

  1. Launch WinDbg x64 because we have a dump of a 64 bits process
  2. CTRL+D or FILE / OPEN CRASH DUMP

Setting the symbols server

.sympath SRV*c:\symbols*http://msdl.microsoft.com/download/symbols
.reload

Check the modification

.sympath

Symbol search path is: SRV*c:\symbols*http://msdl.microsoft.com/download/symbols
Expanded Symbol search path is: srv*c:\symbols*http://msdl.microsoft.com/download/symbols

Loading the SOS module for .NET

For .NET 2.0 | 3.0 | 3.5

.loadby sos mscorwks

For .NET 4.0

.loadby sos clr

Check what is loaded

.chain

Check if the module SOS is working

!EEVersion

If you have this error :

Failed to load data access DLL, 0x80004005
Verify that 1) you have a recent build of the debugger (6.2.14 or newer)
            2) the file mscordacwks.dll that matches your version of mscorwks.dll is
                in the version directory
            3) or, if you are debugging a dump file, verify that the file
                mscordacwks_<arch>_<arch>_<version>.dll is on your symbol path.
            4) you are debugging on the same architecture as the dump file.
                For example, an IA64 dump file must be debugged on an IA64
                machine.

You can also run the debugger command .cordll to control the debugger's
load of mscordacwks.dll.  .cordll -ve -u -l will do a verbose reload.
If that succeeds, the SOS command should work on retry.

If you are debugging a minidump, you need to make sure that your executable
path is pointing to mscorwks.dll as well.

Try what is in the message :

.cordll -ve -u -l

And if you got :

CLR DLL status: No load attempts

Try :

lmv m mscorwks

You should have something like :

start             end                 module name
000007fe`f9030000 000007fe`f99cc000   mscorwks   (pdb symbols)          c:\symbols\mscorwks.pdb\A3BDE007E06845F7A0A4073CD16B1D7A1\mscorwks.pdb
    Loaded symbol image file: mscorwks.dll
    Mapped memory image file: c:\symbols\mscorwks.dll\4E15396099c000\mscorwks.dll
    Image path: C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
    Image name: mscorwks.dll
    Timestamp:        Thu Jul 07 06:43:12 2011 (4E153960)
    CheckSum:         0098DCAB
    ImageSize:        0099C000
    File version:     2.0.50727.5448
    Product version:  2.0.50727.5448
    File flags:       0 (Mask 3F)
    File OS:          4 Unknown Win32
    File type:        2.0 Dll
    File date:        00000000.00000000
    Translations:     0409.04b0
    CompanyName:      Microsoft Corporation
    ProductName:      Microsoft® .NET Framework
    InternalName:     mscorwks.dll
    OriginalFilename: mscorwks.dll
    ProductVersion:   2.0.50727.5448
    FileVersion:      2.0.50727.5448 (Win7SP1GDR.050727-5400)
    FileDescription:  Microsoft .NET Runtime Common Language Runtime - WorkStation
    LegalCopyright:   © Microsoft Corporation.  All rights reserved.
    Comments:         Flavor=Retail

Add the path where mscorwks.dll is located (Image path) with :

.exepath+ C:\Windows\Microsoft.NET\Framework64\v2.0.50727\

And a little :

.reload

(Thanks to Volker von Einem for his post)

We check again if SOS is working :

!EEVersion

CLRDLL: Loaded DLL C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscordacwks.dll
2.0.50727.5448 free
Server mode with 24 gc heaps
SOS Version: 2.0.50727.5448 retail build

Finding the cause

We can take a look at all the managed threads with :

!threads

ThreadCount: 38
UnstartedThread: 0
BackgroundThread: 38
PendingThread: 0
DeadThread: 0
Hosted Runtime: no
PreEmptive Lock
ID OSID ThreadOBJ State GC GC Alloc Context Domain Count APT Exception
28 1 1430 0000000001f7ce30 8220 Enabled 0000000000000000:0000000000000000 0000000001f704c0 0 Ukn
57 2 19b8 0000000001fd9f00 b220 Enabled 000000019f6d1378:000000019f6d3060 0000000001f704c0 0 MTA (Finalizer)
58 3 140c 0000000002012840 80a220 Enabled 0000000000000000:0000000000000000 0000000001f704c0 0 MTA (Threadpool Completion Port)
59 4 1534 00000000020136f0 1220 Enabled 0000000000000000:0000000000000000 0000000001f704c0 0 Ukn
60 9 b08 0000000009bd07a0 180b220 Enabled 000000016f893630:000000016f894500 0000000001f704c0 0 MTA (Threadpool Worker)
61 a 15d0 0000000009ae53a0 180b220 Disabled 00000001c0003ae8:00000001c0005340 00000000020141a0 1 MTA (Threadpool Worker) System.StackOverflowException (00000001af2a0138)
62 b 1b90 00000000098cd980 180b220 Enabled 00000001dfcc8a20:00000001dfcc8ad0 0000000001f704c0 0 MTA (Threadpool Worker)
63 c 1e74 000000000ca417c0 180b220 Enabled 0000000100383358:0000000100385200 0000000001f704c0 0 MTA (Threadpool Worker)
64 d 15a0 0000000009c5f9d0 180b220 Enabled 0000000140a3f988:0000000140a3fb28 0000000001f704c0 0 MTA (Threadpool Worker)
65 e 1d4c 000000000c8e12a0 180b220 Enabled 000000016076a250:000000016076bad0 0000000001f704c0 0 MTA (Threadpool Worker)
66 f 1ca0 0000000009c2cc90 180b220 Enabled 000000027020ffa0:00000002702115c8 0000000001f704c0 0 MTA (Threadpool Worker)
68 10 b74 000000000c97d6e0 180b220 Enabled 00000001affdbcd8:00000001affddc28 00000000020141a0 1 MTA (Threadpool Worker)
69 11 1d20 000000000ca01290 180b220 Enabled 0000000110415f08:0000000110417860 0000000001f704c0 0 MTA (Threadpool Worker)
70 12 15dc 000000000c9ffbb0 180b220 Enabled 000000011faae010:000000011faaf408 0000000001f704c0 0 MTA (Threadpool Worker)
71 13 134 000000000ca2dbb0 180b220 Enabled 00000001ef8a9f00:00000001ef8aa6b8 0000000001f704c0 0 MTA (Threadpool Worker)
72 14 1f54 000000000ca2e180 180b220 Enabled 000000023f96bc40:000000023f96db18 0000000001f704c0 0 MTA (Threadpool Worker)
73 15 166c 000000000ca2e750 180b220 Enabled 000000011fb05b38:000000011fb07408 0000000001f704c0 0 MTA (Threadpool Worker)
74 16 1b20 000000000ca2ed20 180b220 Enabled 00000001ffdc1038:00000001ffdc1ef8 0000000001f704c0 0 MTA (Threadpool Worker)
75 17 1774 000000000ca2f2f0 180b220 Enabled 000000023fb99c60:000000023fb9a618 0000000001f704c0 0 MTA (Threadpool Worker)
76 8 1b10 000000000ca2f8c0 180b220 Enabled 00000001dfcb6100:00000001dfcb6ad0 0000000001f704c0 0 MTA (Threadpool Worker)
77 7 10f4 000000000ca2fe90 180b220 Enabled 000000012ffb5400:000000012ffb7398 0000000001f704c0 0 MTA (Threadpool Worker)
78 18 42c 000000000ca30460 180b220 Enabled 000000021f80cd48:000000021f80d468 0000000001f704c0 0 MTA (Threadpool Worker)
79 19 1d94 000000000ca30a30 180b220 Enabled 000000022f8ad6e8:000000022f8af470 0000000001f704c0 0 MTA (Threadpool Worker)
80 1a 127c 000000000ca31000 180b220 Enabled 000000014f919ed8:000000014f91a980 0000000001f704c0 0 MTA (Threadpool Worker)
81 1b 1928 000000000ca315d0 180b220 Enabled 00000001cff3abd0:00000001cff3c168 0000000001f704c0 0 MTA (Threadpool Worker)
82 1c 1250 000000000ca31ba0 180b220 Enabled 000000024f96e848:000000024f9707a0 0000000001f704c0 0 MTA (Threadpool Worker)
83 1d 16ac 000000000ca32170 180b220 Enabled 00000001bff81ce0:00000001bff83340 0000000001f704c0 0 MTA (Threadpool Worker)
84 1e 1eec 000000000ca32740 180b220 Enabled 000000024f982a30:000000024f9847a0 0000000001f704c0 0 MTA (Threadpool Worker)
85 20 424 000000000ca332e0 880b220 Enabled 0000000000000000:0000000000000000 0000000001f704c0 0 MTA (Threadpool Completion Port)
86 21 3fc 000000000ca338b0 200b220 Enabled 000000018fa79a10:000000018fa7a078 00000000020141a0 1 MTA
4 22 1d8c 000000000ca33e80 220 Enabled 0000000000000000:0000000000000000 0000000001f704c0 0 Ukn
88 23 b58 000000000ca34450 200b220 Enabled 000000017f9e4390:000000017f9e5d20 00000000020141a0 0 MTA System.IO.FileNotFoundException (00000000ff338d80)
24 1f 1d90 000000000ca32d10 220 Enabled 0000000000000000:0000000000000000 0000000001f704c0 0 Ukn
27 6 b04 000000000ca34a20 220 Enabled 0000000000000000:0000000000000000 0000000001f704c0 0 Ukn
26 24 17c4 000000000ccb89e0 220 Enabled 0000000000000000:0000000000000000 0000000001f704c0 0 Ukn
91 25 1844 000000000ccb8fb0 80a220 Enabled 0000000000000000:0000000000000000 0000000001f704c0 0 MTA (Threadpool Completion Port)
2 26 86c 000000000ccb8410 220 Enabled 0000000000000000:0000000000000000 0000000001f704c0 0 Ukn
90 27 1c88 000000000ccba120 220 Enabled 0000000000000000:0000000000000000 0000000001f704c0 0 Ukn

We have a StackOverflowException !

if we are not on the good thread we change with the command ~XXs where XX is the thread number, here we do :

~61s

Now we can take a look at the stack :

!CLRStack

OS Thread Id: 0x15d0 (61)
*** WARNING: Unable to verify checksum for mscorlib.ni.dll
Unable to load image C:\Windows\assembly\NativeImages_v2.0.50727_64\Microsoft.VisualBas#\486ff8cee09c8c63aa9c60ff4f5feafa\Microsoft.VisualBasic.ni.dll, Win32 error 0n2
*** WARNING: Unable to verify checksum for Microsoft.VisualBasic.ni.dll
*** WARNING: Unable to verify checksum for System.Data.ni.dll
(!clrstack processes a max of 1000 stack frames)
Child-SP RetAddr Call Site
000000000d4b7230 000007fef5237fed XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
000000000d4b7260 000007ff002446c6 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
000000000d4b72a0 000007ff00244634 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
000000000d4b7300 000007ff002445dd XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
000000000d4b7340 000007ff00ec16af XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
000000000d4b7370 000007ff015f0389 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
000000000d4b7460 000007ff00e9bcac XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
000000000d4b74a0 000007fef913e219 Line 1
000000000d4b9460 000007fef913e219 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
000000000d4bb430 000007fef913e219 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
000000000d4bd430 000007fef913e219 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
000000000d4bf410 000007fef21143d5 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
000000000d4bf450 000007fef2112c5b XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
000000000d4bf4b0 000007fef2107b4a XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
000000000d4bf580 000007fef2107410 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
000000000d4bf5d0 000007fef21043c9 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
000000000d4bf650 000007fef21042ad XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
000000000d4bf6d0 000007fef2103d48 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
000000000d4bf7b0 000007fef2103b8c XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
000000000d4bf860 000007fef21039c3 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
000000000d4bf8a0 000007fef2103835 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
000000000d4bf950 000007ff00d3a002 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
000000000d4bf9c0 000007ff0148fa2a XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
000000000d4bfa70 000007ff0148f8d6 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
000000000d4bfb10 000007ff0148f847 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
000000000d4bfb60 000007ff00e9bade XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
000000000d4bfbb0 000007ff00d4eb9a Line 1
000000000d4bfc60 000007ff00d4ef02 Line 2
000000000d4bfca0 000007ff00d4db60 Line 3
000000000d4bfd30 000007ff01984a67 Line 4
000000000d4bfe50 000007ff00e9bc11 Line 5
000000000d4bfef0 000007ff00d4eb9a Line 1
000000000d4bffa0 000007ff00d4ef02 Line 2
000000000d4bffe0 000007ff00d4db60 Line 3
000000000d4c0070 000007ff01984a67 Line 4
000000000d4c0190 000007ff00e9bc11 Line 5
000000000d4c0230 000007ff00d4eb9a Line 1
000000000d4c02e0 000007ff00d4ef02 Line 2
000000000d4c0320 000007ff00d4db60 Line 3
000000000d4c03b0 000007ff01984a67 Line 4
000000000d4c04d0 000007ff00e9bc11 Line 5
000000000d4c0570 000007ff00d4eb9a Line 1
000000000d4c0620 000007ff00d4ef02 Line 2
000000000d4c0660 000007ff00d4db60 Line 3
000000000d4c06f0 000007ff01984a67 Line 4
000000000d4c0810 000007ff00e9bc11 Line 5
000000000d4c08b0 000007ff00d4eb9a Line 1
000000000d4c0960 000007ff00d4ef02 Line 2
000000000d4c09a0 000007ff00d4db60 Line 3
000000000d4c0a30 000007ff01984a67 Line 4
000000000d4c0b50 000007ff00e9bc11 Line 5
...

Now we can launch visual studio and change the code to remove/stop the recursive calls.

if we need more information we can try to look at parameters / objects from the dump with :
for the parameters :

!clrstack -p

for local object :

!clrstack -l

or for both :

!clrstack -a

when you have a reference you can dump it with :

!do 0x000000015f9e56f8

Tagged as: No Comments
18Aug/110

Xml deserialization error with invalid character

Recently I had a strange error, I serialized a complex object and during the deserialization process I got :
"Error : System.Xml.XmlException: '.', hexadecimal value 0x00, is an invalid character. Line X, position Y."
It appears that we had a "\0" inside a string, something like "Hello\0World" ! and during a classic serialization, the character was encoded in "&#x0;"

With the help of Google I have found this post (2007) with a way to have an happy deserialization :-)

You can use XmlTextReader instead of XmlReader, but with more research I have found that you can still use XmlReader with XmlReaderSettings and CheckCharacters set to false.

Here is an example :

    public class MyObject
    {
        public string MyString { get; set; }
    }

    class Program
    {
        static void Main(string[] args)
        {

            XmlSerializerFactory fact = new XmlSerializerFactory();
            XmlSerializer ser = fact.CreateSerializer(typeof(MyObject));

            MyObject obj0 = new MyObject();
            obj0.MyString = "Hello\0World";

            // Serialize the object
            StringWriter sw = new StringWriter();
            ser.Serialize(sw, obj0);
            string xml = sw.ToString();
            // We can check that in the xml a \0 is transformed in &#x0;
            Console.WriteLine(xml);

            // Classic use of XmlReader.Create
            StringReader sr1 = new StringReader(xml);
            XmlReader xr1 = XmlTextReader.Create(sr1); // xr1's type is XmlTextReaderImpl
            try
            {
                MyObject obj1 = (MyObject)ser.Deserialize(xr1);
                Console.WriteLine("XmlReader [CheckCharacters({0})] : Success : {1}", xr1.Settings.CheckCharacters, obj1.MyString);
                Console.WriteLine(obj1.MyString);
            }
            catch (Exception e)
            {
                Console.WriteLine("XmlReader [CheckCharacters({0})] : Error : {1}", xr1.Settings.CheckCharacters, e.InnerException);
            }

            // Using an XmlTextReader
            StringReader sr2 = new StringReader(xml);
            XmlTextReader xr2 = new XmlTextReader(sr2);
            // xr2.Settings is null
            MyObject obj2 = (MyObject)ser.Deserialize(xr2);
            Console.WriteLine("XmlTextReader : Success : {0}", obj2.MyString);

            // Using XmlReader with the good XmlReaderSettings
            StringReader sr3 = new StringReader(xml);
            XmlReaderSettings settings = new XmlReaderSettings();
            settings.CheckCharacters = false; // default value is true;
            XmlReader xr3 = XmlTextReader.Create(sr3, settings); // xr3.Settings.CheckCharacters is a read only and xr3's type is XmlTextReaderImpl
            MyObject obj3 = (MyObject)ser.Deserialize(xr3);
            Console.WriteLine("XmlReader [CheckCharacters({0})] : Success : {1}", xr3.Settings.CheckCharacters, obj3.MyString);
        }
    }

Tagged as: , No Comments
27Jan/110

Viewbox and Windows Phone 7

Viewbox is not in the original WP7 because it's not in Silverlight 3.
Viewbox is in Silverlight 4.

Neil Rees extract the source for the ViewBox control from the November 2009 version of the Silverlight Toolkit.

Now you can use the Viewbox control with the Windows Phone 7.

Tagged as: , No Comments
24Jan/110

Screen Resolution

  • Quad HDTV : 3840 x 2160
  • WUXGA : 1920 x 1200 : Monitor at home
  • Full HD : 1920 × 1080
  • WSXGA+ : 1680 x 1050 : Monitor at work
  • HD Ready : 1280 × 720
  • SVGA : 1024 x 768 : iPad
  • WVGA : 800 x 480 : Windows Phone 7
  • ????????? : 960 x 640 : iPhone 4
  • HVGA : 480 x 320 : iPhone 1, 3G, 3GS

Tagged as: No Comments
15Sep/100

TortoiseGit + Dropbox, my personnal SCM combo under Windows

Why Git ?
Because I followed the early history in 2005 and I liked the design :-)

Why now ?
Because I am under Windows and I feel that the windows port is ready for my personnal use with TortoiseGit.

Where is my repository ?
Just on my local drive, but if you want to opensource your project I suggest you to go on GitHub.

How to backup and get my source from an another computer ?
Dropbox ! because I already use Dropbox to sync my files online and across my computers automatically and it works very well.
If you use my referral link for Dropbox, you will have +250 Mo with your 2 Go free account. (and me too)

Finally, if the project is not a Vaporware, you can always move your repository on GitHub or somewhere else.

Go and try TortoiseGit with Dropbox

10Mar/100

Error 415 and WCF Compatibility between .Net 2.0 and 3.5

If you try to call a 3.5 WCF Service with the framework 2.0 and WCF 3.0, you will have an error 415 :

Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8'

'text/xml' is the content type for SOAP 1.1 while 'application/soap+xml' is the content type for SOAP 1.2 and your client WCF 3.0 use SOAP 1.1 while the service with WCF 3.5 use SOAP 1.2.

Here is the solution that worked for me. If you have access to the service config, you just have to change the binding to use SOAP 1.1 :

Add a new custom binding in the 'bindings' section

      <customBinding>
        <binding name="Soap11HttpBinding">
          <textMessageEncoding messageVersion="Soap11" />
          <httpTransport />
        </binding>
      </customBinding>

and don't forget to update your endpoint with the new binding :

    <endpoint ...
        binding="customBinding"
        bindingConfiguration="Soap11HttpBinding">
        ...
    </endpoint>

28Jan/101

How to remove Diacritics in .net C#

If you need to remove diacritics from a string you can :

  • [Bad] do a lot's of replace like :-(
inputString = inputString.Replace('À', 'A');

repeat for ÀÁÂÃÄâãäàáÈÉÊËêëèéÌÍÎÏîïìíÒÓÔÖôõöòóÙÚÛÜûüùúÝýÑñç and maybe miss some exotic chars or the Õ in this list !

  • [Good] or you can use this function :-)
	public static string RemoveDiacritics(string inputString)
	{
		//!\\ Warning 'œ' will be replaced with a 'o' not an 'oe'
		String normalizedString = inputString.Normalize(NormalizationForm.FormD);
		StringBuilder stringBuilder = new StringBuilder();
		for (int i = 0; i < normalizedString.Length; i++)
		{
			Char c = normalizedString[i];
			if (System.Globalization.CharUnicodeInfo.GetUnicodeCategory(c) != System.Globalization.UnicodeCategory.NonSpacingMark)
				stringBuilder.Append(c);
		}
		return stringBuilder.ToString();
	}

Tagged as: , , 1 Comment
2Nov/090

SEO: Subfolders or Subdomains

I recently moved my blogs from subdomains and multiple domain to one domain with subfolders, here are articles on the subject from Chewy's Blog and Search Engine Journal

... search engine view subdomain site as a different site so the work you have done on the sub domain does not directly affect the parent domain as they are viewed as a separate entity.

History, first I had my blog.baleinoid.fr and whaly.baleinoid.fr websites, I moved recently whaly.baleinoid.fr to wha.ly for the fun of the new domain :-) now I moved again and I have http://baleinoid.com/journal/baleine and http://baleinoid.com/whaly

I checked the pro and cons and I choosed the subfolders path, because I don't have a lots of backlinks and it's easier to get a better search engine rank with one domain.

Subfolders Pro:

  • to spread/share the rank of the domain

Subdomains Pro:

  • if you have different hosting server for your blog / forum / website

9Oct/090

WCF WSDL SOAP binding: Rpc or Document, Encoded or Literal

Yeah, my new WebService must be Rpc/Encoded. What ????

Hopefully this page from Ibm explain the different style/use in SOAP message.

A WSDL document describes a Web service. A WSDL binding describes how the service is bound to a messaging protocol, particularly the SOAP messaging protocol. A WSDL SOAP binding can be either a Remote Procedure Call (RPC) style binding or a document style binding. A SOAP binding can also have an encoded use or a literal use.

Ok now I know that four style/use models:
RPC/Encoded, RPC/literal, Document/encoded or Document/literal

But how do I do that in WCF C# ?? It's very easy, just use the [XmlSerializerFormat] attribute.

Here is a very very simple test to check the different result in the soap message:

Interface of the Wcf service used :

using System.ServiceModel;

namespace WcfService1
{
    [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        [XmlSerializerFormat(Style = OperationFormatStyle.Rpc, Use = OperationFormatUse.Encoded)]
        string TestRpcEncoded(int value);

        [OperationContract]
        [XmlSerializerFormat(Style = OperationFormatStyle.Rpc, Use = OperationFormatUse.Literal)]
        string TestRpcLiteral(int value);

        //[OperationContract]
        //[XmlSerializerFormat(Style = OperationFormatStyle.Document, Use = OperationFormatUse.Encoded)]
        //string TestDocumentEncoded(int value);

        [OperationContract]
        [XmlSerializerFormat(Style = OperationFormatStyle.Document, Use = OperationFormatUse.Literal)]
        string TestDocumentLiteral(int value);
    }
}

Result captured on the network with fiddler:

For clarity, I have removed:

  • s:Envelope tag
  • xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
  • xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  • xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  • xmlns="http://tempuri.org/"

RPC / Encoded call

<!-- Request -->
<s:Body s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  <q1:TestRpcEncoded>
    <value xsi:type="xsd:int">42</value>
  </q1:TestRpcEncoded>
</s:Body>

<!-- Response -->
<s:Body s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  <q1:TestRpcEncodedResponse>
    <TestRpcEncodedResult xsi:type="xsd:string">You entered: 42</TestRpcEncodedResult>
  </q1:TestRpcEncodedResponse>
</s:Body>

RPC / Literal call

<!-- Request -->
<s:Body>
  <TestRpcLiteral>
    <value xmlns="">42</value>
  </TestRpcLiteral>
</s:Body>

<!-- Response -->
<s:Body>
  <TestRpcLiteralResponse>
    <TestRpcLiteralResult xmlns="">You entered: 42</TestRpcLiteralResult>
  </TestRpcLiteralResponse>
</s:Body>

Document / Encoded call
If you add the TestDocumentEncoded you will get an InvalidOperationException.
This combination is not supported.

Document / Literal call

<!-- Request -->
<s:Body></code>
  <TestDocumentLiteral><value>42</value></TestDocumentLiteral>
</s:Body>

<!-- Response -->
<s:Body>
  <TestDocumentLiteralResponse>
    <TestDocumentLiteralResult>You entered: 42</TestDocumentLiteralResult>
  </TestDocumentLiteralResponse>
</s:Body>