<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Debugging</title>
        <link>http://geekswithblogs.net/EltonStoneman/category/9543.aspx</link>
        <description>Debugging</description>
        <language>en-GB</language>
        <copyright>EltonStoneman</copyright>
        <managingEditor>elton.stoneman@gmail.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>Hacking the Assembly Manifest</title>
            <link>http://geekswithblogs.net/EltonStoneman/archive/2009/03/11/hacking-the-assembly-manifest.aspx</link>
            <description>&lt;p style="text-align: center;"&gt;&lt;span style="font-size: 10pt;"&gt;[Source: &lt;a href="http://geekswithblogs.net/EltonStoneman"&gt;http://geekswithblogs.net/EltonStoneman&lt;/a&gt;] &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I was debugging a particularly nasty problem and found myself wanting to edit the manifest of a compiled .NET assembly, to change the version number of the assemblies it was referencing. Not necessarily best practice, but in this case it would enable me to confirm the exact issue without a two-hour build-and-deploy cycle. Turns out that nasty hacks like this are very straightforward: &lt;/p&gt;
&lt;ol&gt;
    &lt;li&gt;Run ILDASM, open the assembly and choose &lt;em&gt;File…Dump&lt;/em&gt; to extract the IL &lt;/li&gt;
    &lt;li&gt;
    &lt;div&gt;Open the IL file in Visual Studio and edit the manifest – in this case, the version numbers of the referenced assemblies are easily found at the top of the file: &lt;/div&gt;
    &lt;p&gt;&lt;span style="font-family: Courier New;"&gt;&lt;span style="font-size: 10pt;"&gt;// Metadata version: v2.0.50727&lt;/span&gt; 					&lt;br /&gt;
    &lt;span style="font-size: 10pt;"&gt;.assembly extern mscorlib&lt;/span&gt; 					&lt;br /&gt;
    &lt;span style="font-size: 10pt;"&gt;{&lt;/span&gt; 					&lt;br /&gt;
    &lt;span style="font-size: 10pt;"&gt;  .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )                         // .z\V.4..&lt;/span&gt; 					&lt;br /&gt;
    &lt;span style="font-size: 10pt;"&gt;  .ver 2:0:0:0&lt;/span&gt; 					&lt;br /&gt;
    &lt;span style="font-size: 10pt;"&gt;}&lt;/span&gt; 					&lt;br /&gt;
    &lt;span style="font-size: 10pt;"&gt;.assembly extern &lt;span style="background-color: yellow;"&gt;x.y.z&lt;/span&gt;&lt;/span&gt; 					&lt;br /&gt;
    &lt;span style="font-size: 10pt;"&gt;{&lt;/span&gt; 					&lt;br /&gt;
    &lt;span style="font-size: 10pt;"&gt;  .publickeytoken = (E4 21 0D 54 23 66 A2 B4 )                         // . .D'f..&lt;/span&gt; 					&lt;br /&gt;
    &lt;span style="font-size: 10pt;"&gt;  .ver &lt;span style="background-color: yellow;"&gt;1:0:9:12&lt;/span&gt;&lt;/span&gt; 					&lt;br /&gt;
    &lt;span style="font-size: 10pt;"&gt;}&lt;/span&gt; 				&lt;/span&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li&gt;Save the IL and reassemble it with ILASM – if the assembly was signed, re-sign it using &lt;strong&gt;ilasm /DLL x.y.z.il /KEY=x.y.z.snk&lt;/strong&gt; 		&lt;/li&gt;
    &lt;li&gt;Ensure the new assembly has the same name as the original, and it will operate as an exact replacement, only now its dependencies will be for the modified versions. &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;a href="http://www.codeproject.com/KB/msil/ManifestEdit.aspx"&gt;Simon McEnlly's article on CodeProject&lt;/a&gt; describes going further with the manifest to change the visibility of methods, and generally modifying and rebuilding assemblies where you don't have the source code. Note that if the assembly is signed and you don't have the strong name key to re-sign it, the modified assembly will warn about being tampered with and won't load. &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=130019"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=130019" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/EltonStoneman/aggbug/130019.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>EltonStoneman</dc:creator>
            <guid>http://geekswithblogs.net/EltonStoneman/archive/2009/03/11/hacking-the-assembly-manifest.aspx</guid>
            <pubDate>Wed, 11 Mar 2009 22:44:28 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/EltonStoneman/comments/130019.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/EltonStoneman/archive/2009/03/11/hacking-the-assembly-manifest.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/EltonStoneman/comments/commentRss/130019.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Debugging SOAP messages with WireShark</title>
            <link>http://geekswithblogs.net/EltonStoneman/archive/2009/01/29/debugging-soap-messages-with-wireshark.aspx</link>
            <description>&lt;p style="text-align: center;"&gt;&lt;span style="font-size: 10pt;"&gt;[Source: &lt;a href="http://geekswithblogs.net/EltonStoneman"&gt;http://geekswithblogs.net/EltonStoneman&lt;/a&gt;] &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;If you're debugging Web service calls, you may want to capture incoming requests so you can see exactly what's reaching the service. If BizTalk's hosting the Web service, it's a simple process of adding a FILE send port filtered on the receive port name to copy all incoming messages. If this isn't an option, or if you want the full SOAP envelope together with metadata about the call, you can use a packet sniffer. &lt;/p&gt;
&lt;p&gt;Packet sniffers monitor traffic over a machine NIC, and show you exactly what was sent or received over the wire. An excellent, free tool is &lt;a href="http://www.wireshark.org/"&gt;WireShark&lt;/a&gt; (previously "Ethereal"), which has an rich suite of functionality, but has a bit of a learning curve. To use it exclusively for SOAP debugging is a matter of correctly configuring filters. &lt;/p&gt;
&lt;p&gt;Run WireShark on the machine hosting your Web service. Open &lt;em&gt;Capture…Options &lt;/em&gt;(screenshots below are from version 1.0.5). You'll be shown all the NICs on your machine, select one (it may be trial-and-error to pick the right NIC if you have multiple cards on a server) and configure it as shown: &lt;/p&gt;
&lt;p&gt;&lt;img style="width: 677px; height: 480px;" src="http://geekswithblogs.net/images/geekswithblogs_net/EltonStoneman/012909_0837_DebuggingSO1.jpg" alt="" /&gt;&lt;em&gt; 		&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The key options to set are: &lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;Enable network name resolution (makes identifying traffic much easier) &lt;/li&gt;
    &lt;li&gt;Capture Filter = &lt;strong&gt;tcp port http&lt;/strong&gt; (this captures TCP packets over default port 80). &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Specifying a Capture Filter limits the amount of traffic logged, but isn't necessary if you're not using the default port, as you can also filter results. Click Start and send some calls in to your Web service. Note the capture only operates over the selected NIC, so calls to &lt;em&gt;localhost&lt;/em&gt; won't be recorded – you'll need to make requests from a separate machine. You'll see the network traffic building up in the results pane: &lt;/p&gt;
&lt;p&gt;&lt;img style="width: 674px; height: 412px;" src="http://geekswithblogs.net/images/geekswithblogs_net/EltonStoneman/012909_0837_DebuggingSO2.jpg" alt="" /&gt; 	&lt;/p&gt;
&lt;p&gt;Source and Destination will show the names of the communicating machines if WireShark has been able to resolve them, IP addresses if not. Enter a filter of &lt;strong&gt;xml &lt;/strong&gt;and only packets representing XML exchanges over HTTP will be shown. It's simple to identify the service calls as they will be listed as POSTs to the service endpoint. Note that these are individual TCP packets. WireShark can reassemble all the packets in an exchange to show the full conversation – right click one packet and select "Follow TCP Stream". &lt;/p&gt;
&lt;p&gt;The full stream will be shown, and can be converted between known formats or saved. The stream includes metadata information on the exchange and the full SOAP envelope: &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;POST /ESB.ItineraryServices.Response/ProcessItinerary.asmx HTTP/1.1&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.3053) &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;Content-Type: text/xml; charset=utf-8 &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;SOAPAction: "http://microsoft.practices.esb/Process/SubmitRequestResponse" &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;Host: itinerary-service &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;Content-Length: 1635 &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;Expect: 100-continue &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;Connection: Keep-Alive &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;xml&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;version&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;1.0&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;encoding&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;utf-8&lt;/span&gt;"&lt;span style="color: blue;"&gt;?&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;soap:Envelope&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;xmlns:soap&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;http://schemas.xmlsoap.org/soap/envelope/&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;xmlns:xsi&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;http://www.w3.org/2001/XMLSchema-instance&lt;/span&gt;"&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;xmlns:xsd&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;http://www.w3.org/2001/XMLSchema&lt;/span&gt;"&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;soap:Header&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Itinerary&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;http://schemas.microsoft.biztalk.practices.esb.com/itinerary&lt;/span&gt;"&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: blue; font-family: Courier New; font-size: 10pt;"&gt;            … &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;soap:Body&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;SubmitRequestResponse&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;http://microsoft.practices.esb&lt;/span&gt;"&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;            &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Root&lt;/span&gt;&lt;span style="color: blue;"&gt; 			&lt;/span&gt;&lt;span style="color: red;"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;http://schemas.microsoft.com/BizTalk/2003/Any&lt;/span&gt;"&lt;span style="color: blue;"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: blue; font-family: Courier New; font-size: 10pt;"&gt;                …&lt;/span&gt; 	&lt;/p&gt;
&lt;p&gt;  &lt;/p&gt;
&lt;p&gt;- in this case, a request to the itinerary service from Microsoft's ESB Guidance package, capturing the full itinerary in the header and the service payload in the body. Any response sent to the caller will also be shown. &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129061"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129061" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/EltonStoneman/aggbug/129061.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>EltonStoneman</dc:creator>
            <guid>http://geekswithblogs.net/EltonStoneman/archive/2009/01/29/debugging-soap-messages-with-wireshark.aspx</guid>
            <pubDate>Thu, 29 Jan 2009 14:37:44 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/EltonStoneman/comments/129061.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/EltonStoneman/archive/2009/01/29/debugging-soap-messages-with-wireshark.aspx#feedback</comments>
            <slash:comments>3</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/EltonStoneman/comments/commentRss/129061.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>