<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">
    <title>Shafqat Ahmed's .NET Blog</title>
    
    
    <link rel="alternate" type="text/html" href="http://www.shafqatahmed.com/" />
    <id>tag:typepad.com,2003:weblog-1431343</id>
    <updated>2010-12-02T01:36:02+06:00</updated>
    <subtitle>I am a software developer following .NET since the first PDC release and interest areas include architecture and design, Frameworks, WPF, threading. </subtitle>
    <generator uri="http://www.typepad.com/">TypePad</generator>
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/typepad/raasiel/a_day_in_my_life" /><feedburner:info uri="typepad/raasiel/a_day_in_my_life" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://hubbub.api.typepad.com/" /><feedburner:emailServiceId>typepad/raasiel/a_day_in_my_life</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><entry>
        <title>Powershell Recipe 1: Clean up binaries before build</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/typepad/raasiel/a_day_in_my_life/~3/vb_Mxhnn5to/powershell-recipe-1-clean-up-binaries-before-build.html" />
        <link rel="replies" type="text/html" href="http://www.shafqatahmed.com/2010/12/powershell-recipe-1-clean-up-binaries-before-build.html" thr:count="1" thr:updated="2011-06-08T10:04:26+06:00" />
        <id>tag:typepad.com,2003:post-6a00e54ee5d5478833013489a82735970c</id>
        <published>2010-12-02T01:36:02+06:00</published>
        <updated>2010-12-02T01:36:02+06:00</updated>
        <summary>In my mind two great inventions Microsoft came in last ten years were Windows Presentation Foundations (also Slilverlight) and Powershell. We in .NET used to jealous of Linux Shell Programming as something that powerful was not possible in Windows. Powershell...</summary>
        <author>
            <name>Shafqat Ahmed</name>
        </author>
        
        
<content type="xhtml" xml:lang="en-US" xml:base="http://www.shafqatahmed.com/"><div xmlns="http://www.w3.org/1999/xhtml"><p align="justify">In my mind two great inventions Microsoft came in last ten years were Windows Presentation Foundations (also Slilverlight) and Powershell. We in .NET used to jealous of Linux Shell Programming as something that powerful was not possible in Windows. Powershell changed all that, at present it is the most powerful scripting language and shell available ( btw: Its 10 times better than linux shells even). </p>  <p align="justify">I use PS (PowerShell) in everyday repetitive tasks. We use it to download source code from source code control, build code, release code, create release notes, email to sqa, mark task as fixed in task management system, run automated test scripts and in many more tasks. From now on I am going to share a few PS recipes that make my life easier on a regular basis. I use it as much as I use C#.</p>  <p align="justify">When doing automated build, its best to clear the old binaries, or even its good to clear the binary files when running from VS because old binaries can sometimes create unpredictable results.</p>  <h3 align="justify">Cleaning Up Binaries in folder</h3>  <p align="justify"><font color="#008000" size="2" face="Consolas"># Returns a list of files given the filter pattern      <br />#  $sourcePath - Path which to recursively look for files       <br />#  $pattern – File filter such as *.dll      <br />#  $list – Ignore, used internally</font></p>  <p><font size="2" face="Consolas"><font color="#ff0000"><font color="#0000ff">function</font> </font>Get-Files ( <font color="#ff0000">$sourcePath</font>, <font color="#ff0000">$pattern</font>, <font color="#ff0000">$list </font>)      <br />{      <br /></font><font size="2" face="Consolas">    <font color="#008000"># Is this the root call       <br /></font>    <font color="#ff0000">$return_list</font> = <font color="#0000ff">$false</font>      <br />    <font color="#0000ff">if</font> (<font color="#ff0000">$list</font> -eq <font color="#ff0000">$null</font>)       <br />    {      <br /></font><font size="2" face="Consolas">        # Create the collection that we will return     <br />        <font color="#ff0000">$list</font> = New-Object System.Collections.ObjectModel.Collection[System.IO.FileInfo]      <br />        <font color="#ff0000">$return_list </font>= <font color="#0000ff">$true</font>;      <br />    }      <br />    <br />    <font color="#ff0000">$dir </font>= New-Object System.IO.DirectoryInfo <font color="#ff0000">$sourcePath</font>      <br />    <font color="#ff0000">$files</font> = <font color="#ff0000">$null</font>      <br />    <font color="#ff0000">$files </font>= $dir.GetFiles(<font color="#ff0000">$pattern</font>)      <br />    <font color="#0000ff">if</font> ($files.Length -gt 0)      <br />    {      <br />        <font color="#ff0000">$files</font> | % {<font color="#ff0000">$list</font>.Add($_)}    <br />    }      <br />    <font color="#ff0000">$dirs </font>= <font color="#ff0000">$dir</font>.GetDirectories();      <br />    <font color="#ff0000">$dirs</font> | % {Get-Files <font color="#0000ff">$_</font>.FullName <font color="#ff0000">$pattern</font> <font color="#ff0000">$list</font>}      <br />    <font color="#0000ff">if </font>(<font color="#ff0000">$return_list </font>-eq <font color="#0000ff">$true</font>)      <br />    {      <br />        <font color="#0000ff">return</font> <font color="#0000ff">$list</font>      <br />    }      <br />}</font></p>  <p align="justify">Now we want to delete the dll and pdb files. We will create a function called Delete-Binaries. Get file function will return the list of files of a certain type. Then we can delete the files. See below</p>  <p><font size="2" face="Consolas"><font color="#0000ff">function</font> Delete-Binaries ( <font color="#ff0000">$sourcePath</font> )      <br />{      <br />    Write-Host "Deleting all dll and pdb files from path $sourcePath"      <br />    Get-Files <font color="#ff0000">$sourcePath</font> "*.dll" | % { <font color="#0000ff">$_</font>.Delete() }      <br />    Get-Files <font color="#ff0000">$sourcePath</font> "*.pdb" | % { <font color="#0000ff">$_</font>.Delete() }      <br />    Write-Host "Deletion Complete"      <br />}</font></p>  <p><font size="2" face="Consolas"> </font></p><xhtml:img xmlns:xhtml="http://www.w3.org/1999/xhtml" src="http://feeds.feedburner.com/~r/typepad/raasiel/a_day_in_my_life/~4/vb_Mxhnn5to" height="1" width="1" /></div></content>



    <feedburner:origLink>http://www.shafqatahmed.com/2010/12/powershell-recipe-1-clean-up-binaries-before-build.html</feedburner:origLink></entry>
    <entry>
        <title>Fun with NTFS : Hide your data in Alternate Streams</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/typepad/raasiel/a_day_in_my_life/~3/LBSttpprS8Y/fun-with-ntfs-hide-your-data-in-alternate-streams.html" />
        <link rel="replies" type="text/html" href="http://www.shafqatahmed.com/2010/12/fun-with-ntfs-hide-your-data-in-alternate-streams.html" thr:count="0" />
        <id>tag:typepad.com,2003:post-6a00e54ee5d54788330147e0449b94970b</id>
        <published>2010-12-01T00:31:25+06:00</published>
        <updated>2010-12-01T00:31:25+06:00</updated>
        <summary>Windows NT is a dynamic filesystems. It has certain cool capabilities such as file and directory linking, spurse files, alternate streams and many more. Today we are going to see what Alternate Streams can do for us. Alternate Streams We...</summary>
        <author>
            <name>Shafqat Ahmed</name>
        </author>
        
        
<content type="xhtml" xml:lang="en-US" xml:base="http://www.shafqatahmed.com/"><div xmlns="http://www.w3.org/1999/xhtml"><p align="justify">Windows NT is a dynamic filesystems. It has certain cool capabilities such as file and directory linking, spurse files, alternate streams and many more. Today we are going to see what Alternate Streams can do for us. </p>  <h3 align="justify">Alternate Streams</h3>  <p align="justify">We can programmatically open files in NTFS as file streams. NTFS supports alternate file streams for any file. We can open multiple file streams on a single file. To a normal user only the default file stream would be visible. This technique can be used to hide sensitive data in plain sight, or hide the encrypted data in hidden stream. Some viruses and rootkits use this technique to hide. Even two years ago many of the famous antiviruses did not use to scan for alternate file streams.    <br />Before we go into programming details lets have fun exercise with alternate file streams.</p>  <p align="justify">   <br />  Step 1. Open up command prompt in windows     <br />  Step 2. Type the following    <br /><strong><font size="2">    </font></strong><font size="3" face="Courier New"><strong><font size="2">notepad myfile.txt</font>        <br /></strong></font>  Step 3. Type "Default text" in notepad then save the file    <br />  Step 4. again in command prompt type     <br />    <font size="2" face="Courier New"><strong>notepad myfile.txt:hidden_data</strong></font>    <br />  Step 5. Type "My gmail password : yoho" in notepad then save the file    <br />  Step 6. Open the myfile.txt. What do you see?    <br />  </p>  <p align="justify">You can see the "Default text" in the file. But the data you saved in the alternate stream named "hidden_data" is not visible. If you look in the explorer you will not find the file named myfile.txt:hidden_data, rather you will only see myfile.txt. Now if we type in the command again "notepad myfile.txt:hidden_data" then we will see that the text "My gmail password : yoho" is on notepad.</p>  <p align="justify">So, myfile.txt have an alternate file stream called "hidden_data". We can open and keep multiple such streams for the file. This is a cool feature, isn’t it?</p>  <p align="justify"> </p>  <h3 align="justify">.NET Does not support NTFS alternate strems</h3>  <p align="justify">NTFS streams have been around for more than 10 years and we have .NET version 4.0 released. But unfortuntely .NET Framework yet do not have any support for alternative file streams. This is quite unexpected and sad. </p>  <p align="justify">I am quite disappointed in Microsoft for not providing such a basic file system manipulation has been in NTFS for over 10 years.</p>  <p align="justify"> </p>  <h4 align="justify">So? What is our option</h4>  <p align="justify">You can write Alternative file stream class yourself by using the basic windows APIs. But it would be a lot easier to use a prebuilt library. Greg Duncan has already created a library. His code can be found here. </p>  <p align="justify"><a title="http://coolthingoftheday.blogspot.com/2008/09/accessing-ntfs-alternate-data-streams.html" href="http://coolthingoftheday.blogspot.com/2008/09/accessing-ntfs-alternate-data-streams.html">http://coolthingoftheday.blogspot.com/2008/09/accessing-ntfs-alternate-data-streams.html</a></p><xhtml:img xmlns:xhtml="http://www.w3.org/1999/xhtml" src="http://feeds.feedburner.com/~r/typepad/raasiel/a_day_in_my_life/~4/LBSttpprS8Y" height="1" width="1" /></div></content>



    <feedburner:origLink>http://www.shafqatahmed.com/2010/12/fun-with-ntfs-hide-your-data-in-alternate-streams.html</feedburner:origLink></entry>
    <entry>
        <title>Coding Python S60 Application on Nokia E72: Accelerometer to sense motion and move objects</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/typepad/raasiel/a_day_in_my_life/~3/i5LKPLusw0c/coding-python-s60-application-on-nokia-e72-accelerometer-to-sense-motion-and-move-objects.html" />
        <link rel="replies" type="text/html" href="http://www.shafqatahmed.com/2010/01/coding-python-s60-application-on-nokia-e72-accelerometer-to-sense-motion-and-move-objects.html" thr:count="8" thr:updated="2011-04-21T12:34:32+06:00" />
        <id>tag:typepad.com,2003:post-6a00e54ee5d54788330120a7e99449970b</id>
        <published>2010-01-19T05:08:22+06:00</published>
        <updated>2010-08-11T01:18:11+06:00</updated>
        <summary>Update : I am no longer using e72. I do not see symbian as preferred platform for developing smartphone applications. I have moved on to android which I personally find almost magical. A little Background A few days ago I...</summary>
        <author>
            <name>Shafqat Ahmed</name>
        </author>
        
        
<content type="xhtml" xml:lang="en-US" xml:base="http://www.shafqatahmed.com/"><div xmlns="http://www.w3.org/1999/xhtml"><h3>Update : I am no longer using e72. I do not see symbian as preferred platform for developing smartphone applications. I have moved on to android which I personally find almost magical.</h3> <p>

<h3>A little Background</h3> <p style="text-align: justify">A few days ago I got a Nokia E72 phone as a gift and I really loved the phone because of its 600 Mhz processor. I needed a phone with a full keyboard so that I can check and send emails easily from anywhere. I like windows mobile platform but did want to try raw processing power. As usual I tried writing .NET in Symbian ( usual Nokia phone OS ) and had fun. But I needed more functionality that is native to the OS and decided to go with python. Although Nokia has a cool gadget API, I wanted take advantage of the hardware on the phone. There is a python compiler for the S60 platform, I installed it and wrote my first tiny python code. </p> <p style="text-align: justify">Can’t resist the urge to share the spec of E72 hardware. It has a 600 MHz ARM 11 Processor, 290 MB internal memory, 128 MB RAM, 16GB external mem capbility, Acceleretometer for motion detection, Digital Magnetic Sensor for compass, Ambient Light Sensor, Active GPS, 5 Megapixed cam, WLAN, Bluetooth, FM Radio, Optical Trackpad, HSDPA 10Mbps connectivity, Active noise cancellation etc.</p> <h3>Downloading and installing python on your S60 phone</h3> <p>Download the python for S60 from <a href="https://garage.maemo.org/frs/download.php/6448/PythonForS60_1.9.7.tar.gz" title="https://garage.maemo.org/frs/download.php/6448/PythonForS60_1.9.7.tar.gz">https://garage.maemo.org/frs/download.php/6448/PythonForS60_1.9.7.tar.gz</a>. </p> <p>Extract the contents then install the python runtime for your device. Then install the python shell script mine was S60 3<sup>rd</sup> edition feature pack 2. </p> <h4>Video Demo</h4> <object height="344" width="425"><param name="movie" value="http://www.youtube.com/v/gspDbzI_big&amp;hl=en_US&amp;fs=1&amp;" /><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><embed allowfullscreen="true" allowscriptaccess="always" height="344" src="http://www.youtube.com/v/gspDbzI_big&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" width="425" /></object> <p>This is what the application does</p> <h3>A python primer for a c# (or any) developer </h3> <p>Unlike perl, which looks horrible (sorry if any perl developer is reading this, I mean you no harm, it is just my opinion), python looks pretty structured somewhat like Delphi/Pascal. My objective was to write a few programs for my phone and play around so I wanted to learn python fast in an hour. Before we proceed further we should know a few facts about python. Firstly Python is a dynamic scripting language that is interpreted. Then …</p> <h4>Without correct indentation python code will not run</h4> <p>Wait a second, what!?  <br />Yes, python has specific code indentation rules that makes your write code in beautiful formatted indentation. Python indentation works like C# braces. For example let me demonstrate a hello world method. </p> <pre>def say_hello():

 print u”hello world”</pre>


<p>See the indentation that you have to make for the function? Yep that makes most python code look nice at the same time</p>



<h4>No variable Declaration</h4>



<p>There is no variable declaration required to use a variable, just make up a variable and use it. See example</p>



<pre>myname = “Shafqat Ahmed” 

print myname</pre>


<h4>Importing namespaces</h4>



<p>Like .NET you can import namespaces ( called modules ) in python. </p>



<pre>import math 

import appuifw</pre>


<h3>A primer on python for Series 60</h3>



<p>Since my objective was to write code on python for Symbian, I am going to share few little tidbits.</p>



<h4>For Python for S60 make sure you use Unicode everywhere </h4>



<p>The Python S60 SDK for Symbian (I think other phones also have this same requirement) requires you to use unicode strings in most places. See below</p>



<pre>myname = u“Shafqat Ahmed” 

print myname</pre>


<p>See that “u” in front of the string declaration? That is how you make a unicode string.</p>



<h4>Important modules</h4>



<p>For a PyS60 app usually the first required module is the Application UI Framework for short <strong>appuifw</strong>.  The e32 module contains some system function, the <strong>contacts</strong> module lets us use the contacts on the phone, the <strong>messaging</strong> lets us use sms messaging, the <strong>telephone</strong> library lets us dial or hang up a phone number, the <strong>audio</strong> module lets us play music, or record voice note or record a phone conversation. </p>



<h4>Using the Symbian Native UI</h4>



<p>There are simple functions that lets the user use the native Symbian UI widgets. For example if we want to read values as input. We could write something like </p>



<pre>import appuifw 

name = appuifw.query(u”What is your nam?e”, u”text”)</pre>


<h3>Code</h3>



<h4>Reading the Accelerometer data on PyS60 on Nokia E72</h4>



<p>In order to access the accelerometer data we need to use the sensor module. Then we will setup a callback where the accelerometer data will be sent. Here is how the code looks like ( I created a class to organize code, so the actual code look a little different)</p>



<pre>import sensors 

from sensors import * 



accelerometer = AccelerometerXYZAxisData ( data_filter = LowPassFilter()) 

accelerometer.set_callback ( data_callback=my_callback)</pre>


<p>Then I can access the data in my callback function each time by accessing accelerometer.x for X axis data, accelerometer.y for Y axis data and accelerometer.z for Z axis data.</p>



<h4>Managing Sensitivity </h4>



<p>The E72 has a -60 to +60 range value for each axis. We could use a constant value to move the graphic object, then that would move evenly. But we want to the app to be more responsive human like. So if we take the value of the axis and devide it by a value, say 10 then I would get 1 for a 10 value from the accelerometer, a 3 for 30 on accelerometer, a 6 for 60 (max value) on accelerometer. Similarly I would get a -1 for -10. A value of +/-10 mins the device is a little tilted, +/-60 means highly tilted. So can move the object faster if the device is more tilted.</p>



<p>Also I have added a menu for controlling sensitivity. If I use 5 instead of 10 then the division would result higher values thus making the movement faster. The application code looks like this. </p>



<pre>def my_callback(self):

  x_incr = (self.accelerometer.x / self.sensitivity) * -1

  self.x= self.x + x_incr

  y_incr = (self.accelerometer.y / self.sensitivity ) 

  self.y= self.y + y_incr

  if self.y &lt; 0:

    self.y = 0

  if self.y &gt; 220:

    self.y = 220

  if self.x &lt; 0:

    self.x = 0

  if self.x &gt; 300:

    self.x = 300

  self.draw()</pre>


<p>Then we draw the graphic on to an image then blit it down to the drawing canvas.</p>



<h4>Download</h4>



<p>Please download the <a href="http://raasiel.typepad.com/files/draw.py">draw.py(2.0K)</a> from here. And keep in your E:\data\python folder, use c: if you have installed python in the internal memory not the memory card.</p>



<h5>Running the app </h5>



<p>Run python shell, select ‘Run Script’ from the menu and run draw.py. To exit press the right softkey. You can select high sensitivity from the left softkey menu to have more fun.</p></p><xhtml:img xmlns:xhtml="http://www.w3.org/1999/xhtml" src="http://feeds.feedburner.com/~r/typepad/raasiel/a_day_in_my_life/~4/i5LKPLusw0c" height="1" width="1" /></div></content>



    <feedburner:origLink>http://www.shafqatahmed.com/2010/01/coding-python-s60-application-on-nokia-e72-accelerometer-to-sense-motion-and-move-objects.html</feedburner:origLink></entry>
    <entry>
        <title>Running .NET CF applications and code on Symbian based Phones</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/typepad/raasiel/a_day_in_my_life/~3/oxrNrzRJklE/running-net-cf-applications-and-code-on-symbian-based-phones.html" />
        <link rel="replies" type="text/html" href="http://www.shafqatahmed.com/2010/01/running-net-cf-applications-and-code-on-symbian-based-phones.html" thr:count="1" thr:updated="2010-01-28T14:05:35+06:00" />
        <id>tag:typepad.com,2003:post-6a00e54ee5d54788330120a7958151970b</id>
        <published>2010-01-01T20:30:06+06:00</published>
        <updated>2010-01-01T20:42:00+06:00</updated>
        <summary>J2ME has always been the standard in cross phone applications. Most java app are truly cross phone. The only phone we could write code in .NET was the Windows mobile or Pocket PC. A company called AppForge came up with...</summary>
        <author>
            <name>Shafqat Ahmed</name>
        </author>
        
        
<content type="xhtml" xml:lang="en-US" xml:base="http://www.shafqatahmed.com/"><div xmlns="http://www.w3.org/1999/xhtml"><p>J2ME has always been the standard in cross phone applications. Most java app are truly cross phone. The only phone we could write code in .NET was the Windows mobile or Pocket PC. A company called <a href="http://en.wikipedia.org/wiki/AppForge">AppForge</a> came up with a solution to run .NET code. But in 2007 the company was acquired by Oracle and shut down. </p>  <p>Now <a href="http://www.redfivelabs.com/">Red Five Labs</a> have come up with a .NET based solution called <a href="http://www.redfivelabs.com/content/WhyNet60.aspx">Net60</a> which runs windows mobile based .NET code. Currently .NET 2.0 framework is supported and they plan to add support for compact framework 3.5. Now what made me exited is their licensing policy. With <a href="http://en.wikipedia.org/wiki/AppForge">AppForge</a> it was not possible to develop when the trial expired. With Net60 that is not not case. You can get a IMEI bound license for your non commercial application. Now, isn’t that wonderful? That means I can write my own apps to run on symbian and use them. That also paves way for .NET based open source apps. Lets face it, Nokia holds 41% market share for smartphone applications, which is a very large number (<a href="http://www.electronista.com/articles/09/05/20/gartner.phone.share.q1.09/">source</a>).</p>  <p>I recently got myself a Nokia E63 phone, which is actually an economic version of Nokia E71 (only diff is 2Mpx cam instead of 5 Mpx cam and no GPS and plastic body instead of steel). It has the full qwerty keyboard. I spend a lot of time reading and writing mails as communication has become a large part of my role, so the full keyboard is really helpful. I was looking for a good way to write C# code and run it on my phone ( E71- Symbian OS S60 3rd edition feature pack 1).  After a few tries it worked very nicely. So here is what you need to do in order run .NET code on your Symbian phone.</p>  <h3>Aquiring the SDK</h3>  <p>1. Get the Net60 SDK from <a href="http://www.redfivelabs.com/net60/Explore.aspx">here</a>. It is about 13MB. You would have to provide your phone IMEI no and email. That is the phone where the application would run. If you want a version where it will run on different phones, then you would have to get a commercial license.     <br />2. Check your email to get the free non commercial express license  from Red Five Labs. ( I’d strongly suggest you see the video tutorial at their site, which is the next set of steps about)</p>  <h3>Writing the Application</h3>  <p>1. Create a compact framework 2.0 application (not CF 3.5)    <br />2. After you are done with the application add a Genesis Setup Project to the solution     <br />3. Point to the executable, fill up the necessary fields     <br />4. Add Net60.sisx as dependency, also add the license that you received from RF Labs.     <br />5.  Compile, install the output on your cell phone and run</p>  <h3>Debug version vs Release Version</h3>  <p>The debug version comes with logger and a runner tool. If you are developing, I would suggest that you use the debug version. Making a build and deploying each time you change the code can be pretty annoying. There is a NET60 Launcher tool that can run a .NET executable. So instead of building installation package and deploying each time you can just use that tool to run the exe. Make sure you copy the executable under c:\DATA\RedFiveLabs\Apps\ folder so that it shows on you NET60 Launcher.</p>  <h3>Additional API</h3>  <p>There are some additional API provided by RF Labs to control various features in Symbian OS. These are distributed over a few assemblies. These assemblies are </p>  <p>RedFiveLabs.Mobile.Audio    <br />RedFiveLabs.Mobile.Bluetooth     <br />RedFiveLabs.Mobile.Location     <br />RedFiveLabs.Mobile.Messaging ( for SMS etc)     <br />RedFiveLabs.Mobile.OpenGL ( oh yes open GL support)     <br />RedFiveLabs.Mobile.Pim ( for contacts)   <br />RedFiveLabs.Mobile.Services     <br />RedFiveLabs.Mobile.Vibration</p>  <p>Have fun .Netting on Symbian</p><xhtml:img xmlns:xhtml="http://www.w3.org/1999/xhtml" src="http://feeds.feedburner.com/~r/typepad/raasiel/a_day_in_my_life/~4/oxrNrzRJklE" height="1" width="1" /></div></content>



    <feedburner:origLink>http://www.shafqatahmed.com/2010/01/running-net-cf-applications-and-code-on-symbian-based-phones.html</feedburner:origLink></entry>
    <entry>
        <title>Serializing Web Service Requests to run Load Tests</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/typepad/raasiel/a_day_in_my_life/~3/4jdnTeh8KbU/serializing-web-service-requests-to-run-load-tests.html" />
        <link rel="replies" type="text/html" href="http://www.shafqatahmed.com/2009/08/serializing-web-service-requests-to-run-load-tests.html" thr:count="2" thr:updated="2009-10-17T19:15:03+06:00" />
        <id>tag:typepad.com,2003:post-6a00e54ee5d54788330120a568092f970c</id>
        <published>2009-08-23T03:11:30+06:00</published>
        <updated>2009-08-23T03:11:30+06:00</updated>
        <summary>A few days ago we wanted to how would our application behave under high stress scenarios and wanted to take as little time as possible. We thought we would be able to use Microsoft Web Stress tool. But it turned...</summary>
        <author>
            <name>Shafqat Ahmed</name>
        </author>
        
        
<content type="xhtml" xml:lang="en-US" xml:base="http://www.shafqatahmed.com/"><div xmlns="http://www.w3.org/1999/xhtml"><p align="justify">A few days ago we wanted to how would our application behave under high stress scenarios and wanted to take as little time as possible. We thought we would be able to use Microsoft Web Stress tool. But it turned out that the tool location is not available anymore on the Microsoft web site. We tried an older version, but it seemed that it was not a proper tool to run load tests.  We have a custom Sharepoint application running in front of an application server. All of the core business logic goes through the application server. The web application calls the application server via a few web service calls. This is how the application is supposed to be deployed.</p>  <p><a href="http://raasiel.typepad.com/.a/6a00e54ee5d54788330120a51114c0970b-pi"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="Layers" border="0" alt="Layers" src="http://raasiel.typepad.com/.a/6a00e54ee5d54788330120a5680910970c-pi" width="516" height="365" /></a></p>  <p align="justify">Since all the core requests are coming from web to the app via web services, and our goal was to to stress test the application server, we could simulate stress by calling the web service in the application server.    <br /></p>  <h3>Issues</h3>  <p>The first and basic issue is, that we had very limited time and in that time it was not possible write real life test scenarios for most of the use cases.</p>  <p>The second issue was, the test should be as realistic as possible. Writing tests may not be best way.</p>  <h3>Solution</h3>  <p>The solution was to record a real use case, and then play it again many times with a little varied parameters.</p>  <h3 />  <h3>Implementation</h3>  <p align="justify">So we injected a little code in the web service (we could do this with context handlers, but we did not have the time). Serialized each of the web requests sequentially, In the start of a use case we would clear the folder where we were serializing the web requests. After we have finished the use case then we would de-serialize the requests and inject some randomizing items to a few parameters that changes in real life and then run in multiple thread to simulate real stress. The diagram below shows the whole process. The process if repeated in multiple threads to simulate multiple clients and it worked.</p>  <p><a href="http://raasiel.typepad.com/.a/6a00e54ee5d54788330120a568091b970c-pi"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Simulation" border="0" alt="Simulation" src="http://raasiel.typepad.com/.a/6a00e54ee5d54788330120a568092a970c-pi" width="515" height="757" /></a></p>  <p>So if any of you want to simulate real life scenario without writing too much code, give this a try. Will update this blog with sample code a few days later.</p><xhtml:img xmlns:xhtml="http://www.w3.org/1999/xhtml" src="http://feeds.feedburner.com/~r/typepad/raasiel/a_day_in_my_life/~4/4jdnTeh8KbU" height="1" width="1" /></div></content>



    <feedburner:origLink>http://www.shafqatahmed.com/2009/08/serializing-web-service-requests-to-run-load-tests.html</feedburner:origLink></entry>
    <entry>
        <title>Skype Automation in Powershell : Dont have to dial in conference codes anymore</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/typepad/raasiel/a_day_in_my_life/~3/pGkXP9p94cM/skype-automation-in-powershell-dont-have-to-dial-conference-codes-in-anymore.html" />
        <link rel="replies" type="text/html" href="http://www.shafqatahmed.com/2009/05/skype-automation-in-powershell-dont-have-to-dial-conference-codes-in-anymore.html" thr:count="10" thr:updated="2011-01-05T18:20:07+06:00" />
        <id>tag:typepad.com,2003:post-67256491</id>
        <published>2009-05-26T03:07:08+06:00</published>
        <updated>2009-05-26T03:22:12+06:00</updated>
        <summary>For teams located in different locations conference calling is a must. Most of these calling facilities have toll free 1-800 dial in numbers. Skype lets you dial in to the toll free 1-800 numbers without any cost. One annoying thing...</summary>
        <author>
            <name>Shafqat Ahmed</name>
        </author>
        
        
<content type="xhtml" xml:lang="en-US" xml:base="http://www.shafqatahmed.com/"><div xmlns="http://www.w3.org/1999/xhtml"><p align="justify">For teams located in different locations conference calling is a must. Most of these calling facilities have toll free 1-800 dial in numbers. Skype lets you dial in to the toll free 1-800 numbers without any cost. One annoying thing with these conference calls is that you have to dial in a pin code to enter. If you are dialing in to one conference only then you memorize it. But if you have to dial in several different conferences calls in a day it becomes a pain. You would probably have to lookup the outlook calendar entry and type it in, which is quite annoying and distracting. Recently I have been trying to do everything with Powershell. As you have guessed … … now we can dial into a Skype meeting with one powershell command.</p>  <p align="justify"><strong>You can download the powershell script : </strong><a href="http://raasiel.typepad.com/downloads/skype.ps1"><strong>Download skype.ps1 (5.2K)</strong></a></p>  <p align="justify">I just wrote a function ( just bare minimum, no error handling ) that calls a Skype contact or a phone number waits for certain time then enters the pin as DTMF codes. I have the different meeting and number to different  functions which calls this function. And now I can get into any meeting without hassle.</p>  <p align="justify">The function is called Call-SkypeContactSendDTMF. The first parameter can be a skype contact name or a saved phone only contact or a number to dial. The second parameter is the number of seconds to wait after the phone has been picked up by the conference bot. The third parameter is the DTMF codes. You can add pause by putting in “@” to pause for a second. Here is the calling syntax</p>  <p align="justify"><font face="Consolas" color="#000080" size="2">Call-SkypeContactSendDTMF (<font color="#ff0000">ConferenceNo</font>, <font color="#ff0000">SecondsTOWait</font>, <font color="#ff0000">DTMFCodes</font>)</font></p>  <p align="justify">So I have created different entries from the meetings like this</p>  <p align="justify"><font face="Consolas" color="#004080" size="2"><font color="#ff0000">function</font> call-conf1()       <br />{       <br />   Call-SkypeContactSendDTMF ("ConfNo",10,"7363784394#")       <br />}</font></p>  <p align="justify">All I have to do is type in call-conf1 like this</p>  <p align="justify"><font face="Consolas" color="#000080" size="2">call-conf1</font></p>  <p align="justify">I love powershell. Hope this helps someone.</p>  <p align="justify">btw: When executing this script remember that we want the function to stay in memory so you can either put this in the powershell profile or <a href="http://www.shafqatahmed.com/2009/05/executing-powershell-scripts-in-the-same-execution-context.html" target="_blank">you can call it in the same context by adding a “. ” to it</a>.</p><xhtml:img xmlns:xhtml="http://www.w3.org/1999/xhtml" src="http://feeds.feedburner.com/~r/typepad/raasiel/a_day_in_my_life/~4/pGkXP9p94cM" height="1" width="1" /></div></content>



    <feedburner:origLink>http://www.shafqatahmed.com/2009/05/skype-automation-in-powershell-dont-have-to-dial-conference-codes-in-anymore.html</feedburner:origLink></entry>
    <entry>
        <title>Executing Powershell Scripts in the Same Execution Context</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/typepad/raasiel/a_day_in_my_life/~3/C_PImCbPgRc/executing-powershell-scripts-in-the-same-execution-context.html" />
        <link rel="replies" type="text/html" href="http://www.shafqatahmed.com/2009/05/executing-powershell-scripts-in-the-same-execution-context.html" thr:count="5" thr:updated="2010-10-14T16:59:26+06:00" />
        <id>tag:typepad.com,2003:post-67184565</id>
        <published>2009-05-23T17:30:57+06:00</published>
        <updated>2009-05-23T17:40:07+06:00</updated>
        <summary>Recently I have been trying to do almost everything in Powershell. With the release of Powershell V2 RC and the awesome visual debugger that comes with Powershell called Powershell ISE, I have a Powershell window open at all times. I...</summary>
        <author>
            <name>Shafqat Ahmed</name>
        </author>
        
        
<content type="xhtml" xml:lang="en-US" xml:base="http://www.shafqatahmed.com/"><div xmlns="http://www.w3.org/1999/xhtml"><p>Recently I have been trying to do almost everything in Powershell. With the release of Powershell V2 RC and the awesome visual debugger that comes with Powershell called Powershell ISE, I have a Powershell window open at all times. I am getting my google calendar events form command line, doing recursive ftp uploads and download as well. Now I have started to even do outlook automation with PS.</p>  <h3>The Problem</h3>  <p align="justify">Any slightly efficient developer would write functions and reuse them later. So I tended to write functions add kept on adding them to my Powershell profile file. After a while that turned a little messy and hard to manage. So now I thought why don’t write different script files put my functions in there and use them when needed. So I created functions for Google Data API, Outlook functions. Now when I call them from the prompt, after execution of the script the functions are no longer there. It is because the scriptblock runs in a different execution context and after execution the context is removed. So the functions I have put the file no longer exist when I call them.</p>  <p align="justify">For example I have written a function in myfunc.ps1 to convert string into base64 string which looks like this </p>  <pre>function tobase64 ( $asciistring )
{
  return [Convert]::ToBase64String([System.Text.Encoding]
    ::ASCII.GetBytes($asciistring))
}</pre>

<p>Now after running the script .\myfunc.ps1 when I call the function, it no longer works.</p>

<h3>Solution</h3>

<p>After running around the internet for hours, looking for a solution to run scripts in the same executions context and trying out several different approaches, I was about to give up. Then I found the worlds easiest solution in <a href="http://blog.donnfelker.com/post/Loading-PowerShell-Profiles-from-Other-Script-Files.aspx" target="_blank">Donn Felkers blog</a>. All you need to do is to add a simple dot ( “.” ) at the start of the line to make it run the in the same context.</p>

<p>So if you were running the script like this,</p>

<pre>.\myfunc.ps1 
or
c:\somefolder\myfunc.ps1</pre>

<p>You should run it like this</p>

<pre>. .\myfunc.ps1 
or
. ‘c:\somefolder\myfunc.ps1’</pre>

<p>See the added dot? That does the trick. I wish this was advertized more, then I wouldn’t have had to search for hours to find a solution.</p>

<a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fwww.shafqatahmed.com%2f2009%2f05%2fexecuting-powershell-scripts-in-the-same-execution-context.html"><img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.shafqatahmed.com%2f2009%2f05%2fexecuting-powershell-scripts-in-the-same-execution-context.html" border="0" alt="kick it on DotNetKicks.com" /></a><xhtml:img xmlns:xhtml="http://www.w3.org/1999/xhtml" src="http://feeds.feedburner.com/~r/typepad/raasiel/a_day_in_my_life/~4/C_PImCbPgRc" height="1" width="1" /></div></content>



    <feedburner:origLink>http://www.shafqatahmed.com/2009/05/executing-powershell-scripts-in-the-same-execution-context.html</feedburner:origLink></entry>
    <entry>
        <title>InterOp: Using a .NET based component from a non .NET platform by creating Isolated Application</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/typepad/raasiel/a_day_in_my_life/~3/i-KyyYRHIXg/interop-using-a-net-based-component-from-a-non-net-platform-using-registry-free-com.html" />
        <link rel="replies" type="text/html" href="http://www.shafqatahmed.com/2009/04/interop-using-a-net-based-component-from-a-non-net-platform-using-registry-free-com.html" thr:count="7" thr:updated="2010-07-24T11:49:03+06:00" />
        <id>tag:typepad.com,2003:post-65414523</id>
        <published>2009-04-14T00:48:38+06:00</published>
        <updated>2009-04-14T00:58:47+06:00</updated>
        <summary>Whenever we try to use a .NET component from VB6 or VC++ applications we tend to expose the .NET classes as COM components and register them and from the VB6 or VC applications so that we can instantiate and use...</summary>
        <author>
            <name>Shafqat Ahmed</name>
        </author>
        
        
<content type="html" xml:lang="en-US" xml:base="http://www.shafqatahmed.com/">
&lt;div xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;P align="justify"&gt;Whenever we try to use a .NET component from VB6 or VC++ applications we tend to expose the .NET classes as COM components and register them and from the VB6 or VC applications so that we can instantiate and use the COM components written in .NET. One downside to doing interOp this way is the use of Registry to store the COM information as COM uses registry to lookup the prog id and clsid. This hassle can be avoided by using xcopy deployment with Registry Free COM.&lt;/P&gt; &lt;H3 align="justify"&gt;Isolated Applications and Side by Side Assemblies &lt;/H3&gt; &lt;P align="justify"&gt;.NET is not the sole platform to come up with xcopy deployment and freedom from dll hell. Cpp and Delphie had this for long time. Isolated Applications and Side by side Assemblies  have been invented as a solution to the versioning problem. &lt;/P&gt; &lt;P align="justify"&gt;According to &lt;A href="http://msdn.microsoft.com/en-us/library/ms235531.aspx" target="_blank"&gt;MSDN&lt;/A&gt;, &lt;A href="http://msdn.microsoft.com/en-us/library/aa375190.aspx" target="_blank"&gt;Isolated Applications&lt;/A&gt; are self-describing applications installed with manifests. The benefits of Isolated Applications are that these are more stable and reliable since they are not affected by installation or change in other software, they will always run with the component version they were originally intended for, they can take advantage of Side by Side Assemblies feature, can be installed with xcopy deployment without impacting the registry. A side by side assembly can be a dll, windows class, COM server, type library or interface defined by manifests. &lt;/P&gt; &lt;H3&gt;Private and Shared Assembly&lt;/H3&gt; &lt;P align="justify"&gt;There are two types of Side By Side Assemblies. Private Assemblies are those which are for consumption of one single application, usually placed in the application folder or sub folder. But a Shared Assembly can be used by multiple applications. A fully Isolated application uses only side by side assemblies. If you want to find the Shared Assemblies installed in your computer look in \Windows\WinSxS folder. The shared assemblies are installed here.&lt;/P&gt; &lt;H3&gt;Manifests&lt;/H3&gt; &lt;P align="justify"&gt;Manifests are xml files that accompany assemblies with extra information like dependency, binding, activation. A manifest can be an external file or can be embedded as a resource within the assembly. In older operating systems like Windows XP, manifests need to be embedded inside the side by side (denoted SxS) assemblies to work properly. Assembly Manifests describe side by side assemblies and thus needs to be embedded to work properly in operating systems like Windows XP. Application Manifests describe isolated applications and do not need to be embedded inside the application. &lt;/P&gt; &lt;H3&gt;Normal Registry Based COM Component Load Procedure &lt;/H3&gt; &lt;P align="justify"&gt;If we look up a COM self registering dll we will find that it usually* has four &lt;A href="http://msdn.microsoft.com/en-us/library/zxk0tw93(vs.71).aspx" target="_blank"&gt;stdcall&lt;/A&gt;  calling convention functions. Look at the dependency walker image below of a standard self registering COM server dll.&lt;/P&gt; &lt;P align="justify"&gt;&lt;A href="http://raasiel.typepad.com/.a/6a00e54ee5d547883301157018a318970b-pi"&gt;&lt;img  title="dependency_walker" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="99" alt="dependency_walker" src="http://raasiel.typepad.com/.a/6a00e54ee5d547883301156f21b905970c-pi" width="469" border="0"&gt;&lt;/A&gt; &lt;/P&gt; &lt;P&gt;&lt;/P&gt; &lt;P align="justify"&gt;When we use regsvr32.exe to register a COM dll, the register server application calls the &lt;A href="http://msdn.microsoft.com/en-us/library/ms682162(VS.85).aspx" target="_blank"&gt;DllRegisterServer&lt;/A&gt; function of the dll and that function call inside the dll takes care of putting information in the windows registry so that it can be used by any user application. Now lets have a look at the registry where all these information is recorded. Let us take a standard windows COM component and see its registry structure. The COM component that we will look up today is FileSystemObject from Micorsoft scripting runtime. The progid of the object is Scripting.FileSystemObject. Lets say we are using script code like this &lt;/P&gt; &lt;PRE&gt; Set fso = CreateObject( “Scripting.FileSystemObject” )&lt;/PRE&gt;


&lt;P align="justify"&gt;So lets try to have an understanding how this object is created from the code above. If we go and try looking up the string “Scripting.FileSystemObject” under the HKEY_CLASSES_ROOT key then we would see this.&lt;/P&gt;



&lt;P align="justify"&gt;&lt;A href="http://raasiel.typepad.com/.a/6a00e54ee5d547883301157018a32a970b-pi" target="_blank"&gt;&lt;img  title="registry_1" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="207" alt="registry_1" src="http://raasiel.typepad.com/.a/6a00e54ee5d547883301157018a33c970b-pi" width="517" border="0"&gt;&lt;/A&gt; &lt;/P&gt;



&lt;P&gt;&lt;/P&gt;



&lt;P align="justify"&gt;As you can see there is a node called CLSID and it contains the Class ID ( GUID of the class) inside the node. Now lets go and visit that Class ID node under the HKEY_CLASSES_ROOT\CLSID registry node. See below&lt;/P&gt;



&lt;P align="justify"&gt;&lt;A href="http://raasiel.typepad.com/.a/6a00e54ee5d547883301157018a346970b-pi"&gt;&lt;img  title="registry_2" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="246" alt="registry_2" src="http://raasiel.typepad.com/.a/6a00e54ee5d547883301156f21b934970c-pi" width="516" border="0"&gt;&lt;/A&gt;&lt;/P&gt;



&lt;P align="justify"&gt;As we can see that this is how the dll containing the class object is found, COM infrastructure then calls the &lt;A href="http://msdn.microsoft.com/en-us/library/ms680760(VS.85).aspx" target="_blank"&gt;DllGetClassObject&lt;/A&gt; function to retrieve a pointer to the object we are looking for. As like all COM interfaces the object implements &lt;A href="http://msdn.microsoft.com/en-us/library/ms680509(VS.85).aspx" target="_blank"&gt;IUnknown&lt;/A&gt; interface and all scriptable COM objects implement &lt;A href="http://msdn.microsoft.com/en-us/library/ms221608.aspx" target="_blank"&gt;IDispatch&lt;/A&gt; interface. However how COM identifies and uses the object beyond the scope of this article. The point that I wanted to make is that the windows registry has a very important function here and to have any COM component usable by other applications we had to register it in windows registry.  &lt;/P&gt;



&lt;H3&gt;Registry Free COM Access in an Isolated Application&lt;/H3&gt;



&lt;P align="justify"&gt;In an Isolated Application we can skip entering all the information in the registry and rather enter them in the manifest. We need to create an application manifest which will have the filename in the format of application.exe.manifest. Then we need to create an assembly manifest and embed that assembly manifest inside the dll. Then we would have created an Isolated Application and would not need to register to windows registry to access the functions of the COM dll.&lt;/P&gt;



&lt;P align="justify"&gt;The side by side assemblies are searched in the following order&lt;/P&gt;



&lt;blockquote&gt;

 &lt;P&gt;1. In the executable folder 

  &lt;br&gt;2. Subfolder of the executable folder, subfolder must have the same name as the assembly. For example see inside your Windows\WinSxS folder 



  &lt;br&gt;3. In language specific or culture specific subfolder of the executable&lt;/P&gt;



 &lt;P&gt;For more information on assembly search order &lt;A href="http://msdn.microsoft.com/en-us/library/aa374224.aspx" target="_blank"&gt;look here in MSDN&lt;/A&gt;.&lt;/P&gt;

&lt;/blockquote&gt;



&lt;P align="justify"&gt;&lt;strong&gt;Activation Contexts&lt;/strong&gt; are data structures that allows the OS to redirect loading. For example it can redirect the loader to load a specific version of a dll, or redirect COM object loading process. We will use the COM object loading redirection to avoid using windows registry. For more information on &lt;A href="http://msdn.microsoft.com/en-us/library/aa374153(VS.85).aspx" target="_blank"&gt;Activation Contexts read this&lt;/A&gt;.  &lt;/P&gt;



&lt;H3&gt;Doing it by example&lt;/H3&gt;



&lt;P align="justify"&gt;I have setup a sample application with source that will show how we can create a registry free COM component. Please note that there is already a practical example in the following article in MSDN, &lt;A href="http://msdn.microsoft.com/en-us/library/ms973915.aspx" target="_blank"&gt;Registration-Free Activation of .NET-Based Components: A Walkthrough&lt;/A&gt; by Steve White and Leslie Muller. You might want to read that article if you find my example not clear enough. &lt;/P&gt;



&lt;TABLE cellspacing="0" cellpadding="2" width="217" border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD valign="top" width="215"&gt;

    &lt;P align="center"&gt;&lt;A href="http://raasiel.typepad.com/files/IsolatedApp.zip" target="_blank"&gt;&lt;strong&gt;&lt;font size="3"&gt;Download Sample Code&lt;/font&gt;&lt;/strong&gt;&lt;/A&gt;&lt;/P&gt;

   &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;



&lt;P&gt;Here is what we are going to do in the sample application &lt;/P&gt;



&lt;blockquote&gt;

 &lt;P align="justify"&gt;1. Create C# based class that serves funny quotes and expose that as a COM component and register it.&lt;/P&gt;



 &lt;P align="justify"&gt;2. Create a VB6 executable that uses the COM dll to show quotes &lt;/P&gt;



 &lt;P align="justify"&gt;3. Unregister the COM dll to show that without COM registration in windows registry the application is no longer working&lt;/P&gt;



 &lt;P align="justify"&gt;4. Create an application manifest, then create an assembly manifest and recompile the C# application with the embedded assembly manifest to create our isolated application. &lt;/P&gt;



 &lt;P align="justify"&gt;5. Move the isolated application to a different folder and prove that the application is using COM without registry. &lt;/P&gt;

&lt;/blockquote&gt;



&lt;P&gt;&lt;strong&gt;1. C# COM Dll&lt;/strong&gt;&lt;/P&gt;



&lt;P align="justify"&gt;We are going to create a dll called QuoteSource and a class that serves Quotes called QuoteProvider and it is going to implement the IQuoteProvider interface. The methods in the interface will be exposed.&lt;/P&gt;



&lt;P&gt;Here is how the interface looks like.&lt;/P&gt;



&lt;P&gt; &lt;A href="http://raasiel.typepad.com/.a/6a00e54ee5d547883301157018a363970b-pi"&gt;&lt;img  title="interface_1" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="321" alt="interface_1" src="http://raasiel.typepad.com/.a/6a00e54ee5d547883301156f21b93f970c-pi" width="350" border="0"&gt;&lt;/A&gt; &lt;/P&gt;



&lt;P&gt;Here is the class that serves quotes and implements the interface above&lt;/P&gt;



&lt;P&gt;&lt;A href="http://raasiel.typepad.com/.a/6a00e54ee5d547883301156f21b944970c-pi"&gt;&lt;img  title="class_1" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="246" alt="class_1" src="http://raasiel.typepad.com/.a/6a00e54ee5d547883301157018a378970b-pi" width="369" border="0"&gt;&lt;/A&gt;  ‘&lt;/P&gt;



&lt;P&gt;The assembly info contains the assembly guid 

 &lt;br&gt;



 &lt;br&gt;&lt;A href="http://raasiel.typepad.com/.a/6a00e54ee5d547883301156f21b954970c-pi"&gt;&lt;img  title="assembly_info" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="135" alt="assembly_info" src="http://raasiel.typepad.com/.a/6a00e54ee5d547883301156f21b960970c-pi" width="395" border="0"&gt;&lt;/A&gt; &lt;/P&gt;



&lt;P align="justify"&gt;We need to make sure that a tlb file is generated and the assembly we created is registered. We will select “Register for COM interop” option from the build properties screen. See below …&lt;/P&gt;



&lt;P&gt;&lt;A href="http://raasiel.typepad.com/.a/6a00e54ee5d547883301157018a392970b-pi"&gt;&lt;img  title="build" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="92" alt="build" src="http://raasiel.typepad.com/.a/6a00e54ee5d547883301157018a39b970b-pi" width="391" border="0"&gt;&lt;/A&gt; &lt;/P&gt;



&lt;P&gt;&lt;/P&gt;



&lt;P&gt;&lt;/P&gt;



&lt;P&gt;&lt;/P&gt;



&lt;P&gt;&lt;/P&gt;



&lt;P&gt;&lt;strong&gt;2. VB6 Client Executable that uses the C# Library&lt;/strong&gt;&lt;/P&gt;



&lt;P align="justify"&gt;We have created a simple VB6 application that refers and calls the C# assembly dll. See below:&lt;/P&gt;



&lt;P&gt;&lt;A href="http://raasiel.typepad.com/.a/6a00e54ee5d547883301156f21b974970c-pi"&gt;&lt;img  title="VB6Client" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="343" alt="VB6Client" src="http://raasiel.typepad.com/.a/6a00e54ee5d547883301157018a3b5970b-pi" width="340" border="0"&gt;&lt;/A&gt; &lt;/P&gt;



&lt;P&gt;&lt;/P&gt;



&lt;P&gt;Let compile the executable and it becomes VB6Client.exe&lt;/P&gt;



&lt;P&gt;&lt;strong&gt;3. Unregister the C# COM dll to make sure that we a re not using the reference&lt;/strong&gt;&lt;/P&gt;



&lt;P&gt;We will use the following command line in the folder where the dll resides&lt;/P&gt;



&lt;PRE&gt;regasm /u QuoteSource.dll&lt;/PRE&gt;


&lt;P align="justify"&gt;Lets run our VB6Client.exe and press the Get Quote button… walla! It does not work anymore. The executable exits with automation error since we unregistered it from windows registry.&lt;/P&gt;



&lt;P align="justify"&gt;&lt;strong&gt;4. Create the Application and Assembly Manifest and embed Assembly Manifest inside the QuoteSource.dll&lt;/strong&gt;&lt;/P&gt;



&lt;P align="justify"&gt;First we are going to create an application manifest. The application manifest has to have the name in the format of exetutable full name + .manifest. Since our executable is called VB6Client.exe our application manifest will be called VB6Client.exe.manifest. Here are the contents of the manifest.&lt;/P&gt;



&lt;P&gt;&lt;A href="http://raasiel.typepad.com/.a/6a00e54ee5d547883301156f21b97b970c-pi"&gt;&lt;img  title="asm_manifest" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="312" alt="asm_manifest" src="http://raasiel.typepad.com/.a/6a00e54ee5d547883301157018a3c1970b-pi" width="404" border="0"&gt;&lt;/A&gt; &lt;/P&gt;



&lt;P align="justify"&gt;Now lets create the assembly manifest and embed it inside out QuoteSource.dll. First we will create an xml file called QuoteSource.manifest. Please observe that we have put in the progid and clsid of the COM exposed class.&lt;/P&gt;



&lt;P&gt;&lt;A href="http://raasiel.typepad.com/.a/6a00e54ee5d547883301156f21b987970c-pi"&gt;&lt;img  title="asm_manifest2" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="314" alt="asm_manifest2" src="http://raasiel.typepad.com/.a/6a00e54ee5d547883301156f21b98f970c-pi" width="453" border="0"&gt;&lt;/A&gt; &lt;/P&gt;



&lt;P align="justify"&gt;Now we need to convert this assembly into a resource file. We will use rc.exe that comes with windows SDK, or VC++ or VB6 installation. &lt;/P&gt;



&lt;P&gt;We will create a text file called QuoteSource.rc  will put in the following line here.&lt;/P&gt;



&lt;PRE&gt;1 24 QuoteSource.manifest&lt;/PRE&gt;


&lt;P align="justify"&gt;Here 1 is the manifest resource id and 24 means that it is a type of manifest resource. We will now invoke the Windows SDK resouce compiler from the command line. Check where in you computer you have the resource compiler installed. Here is the command line&lt;/P&gt;



&lt;PRE&gt;rc.exe QuoteSource.rc &lt;/PRE&gt;


&lt;P align="justify"&gt;After invoking this it will create a file called QuoteSource.res. This is a windows resource file. &lt;/P&gt;



&lt;P align="justify"&gt;Now we will use a custom build command to create the dll. Observe the command line below&lt;/P&gt;



&lt;PRE&gt;csc /t:library /out:QuoteSource.dll /&lt;font color="#ff0000"&gt;win32res:QuoteSource.res&lt;/font&gt; 

IQuoteProvider.cs QuoteProvider.cs Properties\AssemblyInfo.cs&lt;/PRE&gt;


&lt;P align="justify"&gt;See the win32res switch, it tells the compiler that it is a win32 resource.&lt;/P&gt;



&lt;P align="justify"&gt;Now copy the dll to the same folder as the exe, also copy the application manifest. There is no need to copy the assembly manifest as we have already embedded it inside the dll.&lt;/P&gt;



&lt;P align="justify"&gt;Run the the application and press the Get Quote button, it works!&lt;/P&gt;



&lt;P&gt;&lt;strong&gt;5. XCopy Deployment&lt;/strong&gt;&lt;/P&gt;



&lt;P align="justify"&gt;Copy or move the folder elsewhere, even to another computer. It will still work without any need to register the .NET COM dll. This is because we have created the application and assembly manifest and windows is treating our application as a Isolated application.&lt;/P&gt;



&lt;H3&gt;Last Words&lt;/H3&gt;



&lt;P align="justify"&gt;This way you can create XCopy deployment for even COM based applications and avoid storing information in registry. Even a multi dll VB6 or VC++ application can be made Isolated Application.&lt;/P&gt;

&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fwww.shafqatahmed.com%2f2009%2f04%2finterop-using-a-net-based-component-from-a-non-net-platform-using-registry-free-com.html"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.shafqatahmed.com%2f2009%2f04%2finterop-using-a-net-based-component-from-a-non-net-platform-using-registry-free-com.html" border="0" alt="kick it on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/typepad/raasiel/a_day_in_my_life/~4/i-KyyYRHIXg" height="1" width="1"/&gt;</content>



    <feedburner:origLink>http://www.shafqatahmed.com/2009/04/interop-using-a-net-based-component-from-a-non-net-platform-using-registry-free-com.html</feedburner:origLink></entry>
    <entry>
        <title>Converting Typepad Exported Blog format to BlogML</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/typepad/raasiel/a_day_in_my_life/~3/LiGNmPbcdwE/converting-typepad-exported-blog-format-to-blogml.html" />
        <link rel="replies" type="text/html" href="http://www.shafqatahmed.com/2009/03/converting-typepad-exported-blog-format-to-blogml.html" thr:count="9" thr:updated="2010-12-06T17:04:23+06:00" />
        <id>tag:typepad.com,2003:post-64774801</id>
        <published>2009-03-28T21:08:58+06:00</published>
        <updated>2009-03-28T21:08:58+06:00</updated>
        <summary>My blog is hosted at Typepad, which in my personal opinion takes the least time to manage than any other blog hosting service. The payment option from typepad has no Paypal support as of the time of my writing and...</summary>
        <author>
            <name>Shafqat Ahmed</name>
        </author>
        
        
<content type="xhtml" xml:lang="en-US" xml:base="http://www.shafqatahmed.com/"><div xmlns="http://www.w3.org/1999/xhtml"><p style="text-align: justify">My blog is hosted at Typepad, which in my personal opinion takes the least time to manage than any other blog hosting service. The payment option from typepad has no Paypal support as of the time of my writing and I did not want to spend from my card. So I planned to move from typepad to self hosting. However that situation was resolved with help of typepad and I am still in Typepad,the best managed blog service.</p> <p style="text-align: justify">I was planning to use BlogEngine.NET, a .NET based blogging platform to host and it supports importing from BlogML. Typepad is a blog hosting service that is based on MovableType blogging platform. MovableType exports blog contents into a plain text based format. I searched around the internet for a tool that converts typepad format to BlogML. Unfortunately there was none. So I had to write a converter to convert the typepad format. </p> <h3>Gotcha!</h3> <p style="text-align: justify">After converting the the blog content to BlogML I just found out that there is a click once installer that comes with BlogEngine.NET 1.4.5 and the application do not start. After a little investigation I had figured that the location of the installer is no longer valid. I then had to add support to directly import into BlogEngine by calling their webservice. So if you are converting the typepad blog exported please use the code below.</p> <h3>Download, Source and Usage</h3> <p style="text-align: justify"><a href="http://" /><a href="http://raasiel.typepad.com/files/typepad2blogmlbinary.zip"><span class="at-xid-6a00e54ee5d547883301156e813c9e970c">Download Typepad2BlogMLBinary</span></a>
<a href="http://" />  <br /><a href="http://raasiel.typepad.com/files/typepad2blogml.zip"><span class="at-xid-6a00e54ee5d547883301156f7bcd75970b">Download Typepad2BlogML</span></a>
</p> <p style="text-align: justify"><strong>Usage</strong>: <span size="2" style="font-family: Consolas;">Typepad2BlogML.exe -i:[</span><font color="#ff0000">input file</font><font size="2">] -mode:[</font><font color="#ff0000">blogml</font><font size="2" /><font color="#00ff00">|</font><font size="2" /><font color="#0000ff">service</font><font size="2">] -o:[</font><font color="#ff0000">output file</font><font size="2">] -s:[</font><font color="#0000ff">service address</font><font size="2">] -u:[</font><font color="#0000ff">username</font><font size="2">] -p:[</font><font color="#0000ff">password</font><font size="2">]</font></p> <p>There are 2 application modes, one for converting into BlogML and another for uploading to BlogEngine via a webservice.</p> <p>For converting to blog ML you should use something like this:</p> <p><span size="2" style="font-family: Consolas;">Typepad2BlogML.exe -i:mytypepadfile.txt -m:blogml -o:out.blogml</span></p> <p><font size="2">F</font>or importing into BlogEngine 1.4.5 use command line code like this:</p> <p><span size="2" style="font-family: Consolas;">Typepad2BlogML.exe -i:mytypepadfile.txt -m:service -s:</span><a href="http://www.myblog.com/api/BlogImporter.asmx"><span size="2" style="font-family: Consolas;">http://www.myblog.com/api/BlogImporter.asmx</span></a><span size="2" style="font-family: Consolas;"> -u:username -p:password</span></p><xhtml:img xmlns:xhtml="http://www.w3.org/1999/xhtml" src="http://feeds.feedburner.com/~r/typepad/raasiel/a_day_in_my_life/~4/LiGNmPbcdwE" height="1" width="1" /></div></content>



    <feedburner:origLink>http://www.shafqatahmed.com/2009/03/converting-typepad-exported-blog-format-to-blogml.html</feedburner:origLink></entry>
    <entry>
        <title>Preparing to move to BlogEngine.NET from Typepad</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/typepad/raasiel/a_day_in_my_life/~3/iEsX_2AjaJU/preparing-to-move-to-blogenginenet-from-typepad.html" />
        <link rel="replies" type="text/html" href="http://www.shafqatahmed.com/2009/02/preparing-to-move-to-blogenginenet-from-typepad.html" thr:count="6" thr:updated="2010-11-17T11:25:22+06:00" />
        <id>tag:typepad.com,2003:post-62914129</id>
        <published>2009-02-16T21:21:13+06:00</published>
        <updated>2009-02-16T21:21:13+06:00</updated>
        <summary>I have been blogging for over a year now and have been using www.typepad.com as my hosting provider. Typepad is a wonderful host but it does not accept payments via paypal and accepts only credit/debit card which I do not...</summary>
        <author>
            <name>Shafqat Ahmed</name>
        </author>
        
        
<content type="xhtml" xml:lang="en-US" xml:base="http://www.shafqatahmed.com/"><div xmlns="http://www.w3.org/1999/xhtml"><p align="justify">I have been blogging for over a year now and have been using <a href="http://www.typepad.com">www.typepad.com</a> as my hosting provider. Typepad is a wonderful host but it does not accept payments via paypal and accepts only credit/debit card which I do not want to use at the moment. Also it is written in perl/cgi probably. The MovableTypes framework is a awesome but it requires perl/cgi. Since I work on the .NET platform mostly I wanted to add some functionality to the blog which I cannot do with typepad or MT. So I have selected BlogEngine.NET as the blogging framework and preparing to move there.</p>  <p align="justify">The site will look the same as I will use the same design as it is now. I am also writing a converter that exports from typepad export format to BlogML which the BlogEngine accepts. Typepad has been a superb blog host until recently. The ticket that I opened a few days ago is still unresolved without a reply. Sad!</p><xhtml:img xmlns:xhtml="http://www.w3.org/1999/xhtml" src="http://feeds.feedburner.com/~r/typepad/raasiel/a_day_in_my_life/~4/iEsX_2AjaJU" height="1" width="1" /></div></content>



    <feedburner:origLink>http://www.shafqatahmed.com/2009/02/preparing-to-move-to-blogenginenet-from-typepad.html</feedburner:origLink></entry>
 
</feed><!-- ph=1 -->

