<?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-01-19T05:08:22+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>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="5" thr:updated="2010-07-22T11:41:58+06:00" />
        <id>tag:typepad.com,2003:post-6a00e54ee5d54788330120a7e99449970b</id>
        <published>2010-01-19T05:08:22+06:00</published>
        <updated>2010-01-20T20:46:18+06:00</updated>
        <summary>A little Background 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...</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>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></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></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></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="9" thr:updated="2010-02-16T13:56:54+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></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="4" thr:updated="2010-06-25T00:52:00+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></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;
</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="7" thr:updated="2009-11-11T17:41:37+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></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="5" thr:updated="2010-06-29T12:31:05+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></div>
</content>



    <feedburner:origLink>http://www.shafqatahmed.com/2009/02/preparing-to-move-to-blogenginenet-from-typepad.html</feedburner:origLink></entry>
    <entry>
        <title>WPF Kid Stuff: Extracting a Control Template</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/typepad/raasiel/a_day_in_my_life/~3/G0t0XoYmZ30/wpf-kid-stuff-extracting-a-control-template.html" />
        <link rel="replies" type="text/html" href="http://www.shafqatahmed.com/2009/01/wpf-kid-stuff-extracting-a-control-template.html" thr:count="1" thr:updated="2009-05-22T11:09:50+06:00" />
        <id>tag:typepad.com,2003:post-60723682</id>
        <published>2009-01-02T23:41:47+06:00</published>
        <updated>2009-01-02T23:41:47+06:00</updated>
        <summary>One of the design principles for WPF was to enable the developer decide the look and feel of the control and that resulted in the most versatile UI framework that can be customized in any way the developer wants. Previously...</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">One of the design principles for WPF was to enable the developer decide the look and feel of the control and that resulted in the most versatile UI framework that can be customized in any way the developer wants. Previously there were many widgets for different languages and frameworks because their look could not be customized beyond the method the control builder provided. With the help of templates in WPF that has changed and that is why there are a lot less custom controls in WPF than the previous technologies. In order to customize something the end developer has to only modify the templates. </p>  <p align="justify">If we want to modify a the default look of a controls that is not controllable by the properties, the best way to do that is to extract the existing template of the control and change that. Manually we could open up Expression Blend and right click on a control end edit a copy of the template. See image below.</p>  <p align="justify"><img title="extract" style="border-top-width: 0px; display: block; border-left-width: 0px; float: none; border-bottom-width: 0px; margin-left: auto; margin-right: auto; border-right-width: 0px" height="389" alt="extract" src="http://raasiel.typepad.com/.a/6a00e54ee5d5478833010536a3b788970b-pi" width="377" border="0" /></p>  <p align="justify">This would actually reveal the control template that builds control and we can modify it and use as we please. </p>  <p align="justify">Another procedure is the extract the template from code is to get the template from the control itself. We can write c# code to extract the template like this …</p>  <pre><div align="left"><font style="color: #008000">// Get the template from the control </font>
ControlTemplate template = ctl.Template;<br />
<font style="color: #008000">// We want our xaml of be properly indented, ohterwise</font><br /><font style="color: #008000">// we would not be able to indent them.</font><br />XmlWriterSettings xmlSettings = <font style="color: #0000ff">new</font> XmlWriterSettings();<br />xmlSettings.Indent = <font style="color: #0000ff">true</font>;<br />
<font style="color: #008000">// Make the string builder</font><br />StringBuilder sb = <font style="color: #0000ff">new</font> StringBuilder();<br />XmlWriter writer = XmlWriter.Create(sb, xmlSettings);<br />XamlWriter.Save(template, writer);<br /><br />
<font style="color: #008000">// Now the sb.ToString() should give us the template</font>
</div></pre>

<p>Note: There will be more controls in the xaml template output. Their templates can be extracted further. </p></div>
</content>



    <feedburner:origLink>http://www.shafqatahmed.com/2009/01/wpf-kid-stuff-extracting-a-control-template.html</feedburner:origLink></entry>
    <entry>
        <title>Comparison of Different Open Source Licenses -With Comparison Chart!</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/typepad/raasiel/a_day_in_my_life/~3/uerryY00aTE/comparison-of-d.html" />
        <link rel="replies" type="text/html" href="http://www.shafqatahmed.com/2008/10/comparison-of-d.html" thr:count="8" thr:updated="2009-12-31T02:21:44+06:00" />
        <id>tag:typepad.com,2003:post-56640935</id>
        <published>2008-10-07T07:57:00+06:00</published>
        <updated>2008-10-07T07:57:00+06:00</updated>
        <summary>I was a little confused with which license to use for an open source initiative and the benefits and limitations of difference licenses, so I dug a little and here is what I have found. I hope this helps you...</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 was a little confused with which license to use for an open source initiative and the benefits and limitations of difference licenses, so I dug a little and here is what I have found. I hope this helps you with your selection of a license for your open source initiative.</p>  <h3 align="justify"><strong>Pretext</strong></h3>  <p align="justify">Previously I had my open source projects listed in SourceForge.net, and the last one I worked on was pretty long ago. Recently I took on a few more initiatives to release some of the libraries that I developed as open source projects and a new open source project for file synchronization. As a .NET person my first choice was CodePlex.com which is a great site with TFS and subversion and issue tracking support. </p>  <p align="justify">I am used to write the license myself for the software. However the codeplex site comes with a bunch of pre defined standard licenses and no option to write your own custom open source license. In order select a license I had to read all of these licenses and also read this cool book on licenses - <a href="http://www.amazon.com/Understanding-Open-Source-Software-Licensing/dp/0596005814" target="_blank">Open Source and Free Software Licensing</a><strong> </strong>By <a href="http://www.oreillynet.com/cs/catalog/view/au/1838?x-t=book.view">Andrew M. St. Laurent</a> from O’Reilly press (ISBN: 0-596-00581-4).</p>  <h3 align="justify"><strong>The Licenses In Discussion</strong></h3>  <p align="justify">I am going to discuss the following licenses: </p>  <blockquote>   <p align="justify">1. <a href="http://en.wikipedia.org/wiki/MIT_License" target="_blank">The MIT License</a>       <br />2. <a href="http://www.opensource.org/licenses/bsd-license.php" target="_blank">New BSD License</a>       <br />3. <a href="http://www.apache.org/licenses/LICENSE-2.0.html" target="_blank">Apache License</a>       <br />4. <a href="http://www.opensource.org/licenses/ms-pl.html" target="_blank">Microsoft Public License (Ms-PL)</a>       <br />5. <a href="http://www.opensource.org/licenses/ms-rl.html" target="_blank">Microsoft Reciprocal License (Ms-RL)</a>       <br />6. <a href="http://www.gnu.org/copyleft/gpl.html" target="_blank">GNU General Public License (GPL)</a>       <br />7. <a href="http://www.gnu.org/licenses/old-licenses/library.html" target="_blank">GNU Library General Public License (LGPL)</a>       <br />8. <a href="http://www.sun.com/cddl/cddl.html" target="_blank">Common Development and Distribution License</a>       <br />9. <a href="http://www.mozilla.org/MPL/MPL-1.1.html" target="_blank">Mozilla Public License 1.1 (MPL)</a> </p> </blockquote>  <h3 align="justify"><strong>The Basis of Open Source Licensing</strong> </h3>  <p align="justify">Open source does not mean free software, but often is associated with it. Some licenses makes the software free for use, some licenses are to make sure that source is always distributed with the binaries. There are 2 items common among all of these licenses. Firstly the license must be distributed with the software usually with both binary and source code form. Secondly, the licenses have a warranty disclaimer. Having a warranty disclaimer is very important when you are making a free software. Since software creator is not making money out of a software it does not make sense to be liable for implied warranty. The warranty disclaimer releases the creator of the software from the liability of implied warranty. </p>  <h3 align="justify"><strong>Comparison Summary</strong></h3>  <p align="justify">The chart below shows a basic comparison of explicitly stated items among different open source licenses (click to enlarge)</p>  <p align="justify"><a href="http://www.shafqatahmed.com/WindowsLiveWriter/OpenSourceLicenseComparison.png" target="_blank"><img title="OpenSourceLicenseComparison" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="389" alt="OpenSourceLicenseComparison" src="http://www.shafqatahmed.com/WindowsLiveWriter/OpenSourceLicenseComparison_thumb.png" width="503" border="0" /></a></p>  <p align="justify">Hope this helps to have an overview of the licenses </p>  <h3 align="justify"><strong>Simple Licenses</strong></h3>  <p align="justify"><strong>The MIT License</strong></p>  <p align="justify">The MIT License is the simplest non restrictive open source license. It has only two parts, at the first part lets anyone use the software for free even it lets anyone publish, distribute, sublicense or even sell copies of the software. The second part is the disclaimer for warranty.</p>  <p align="justify"><strong>New BSD License</strong></p>  <p align="justify">The new BSD license is as unrestrictive as the MIT license except for the fact, it does not allow the name of the contributors to be used to endorse any derivative software.</p>  <p align="justify"><strong>Microsoft Public License (Ms-PL)</strong></p>  <p align="justify">The Microsoft Public License is similarly non restrictive as the previous two with the following explicit notations. Firstly, the license does not grant permission to the contributor’s name, logo or trademark. Secondly this license lets you royality free use of contributor’s patents that are used in the software but if you make any patent claim against any part of the software your license to the use of contributor’s parent is revoked.</p>  <p align="justify"><strong>Microsoft Reciprocal License (Ms-RL)</strong></p>  <p align="justify">This license exactly as same as the previous one except that if you use any file from software then you must provide source for those files and the copy of the license and the other files in the end result software can be licensed under any term you want.</p>  <p align="justify"><strong>Common Development and Distribution License (CDDL)</strong></p>  <p align="justify">CDDL is also a non restrictive type of open source license, but it has a lot of items explicitly described. See license details</p>  <p align="justify"><strong>Apache 2.0 License</strong></p>  <p align="justify">Apache license makes sure that the software is free, the name of apache foundation cannot be used to endorse the product, any change to the software needs to be distributed in source form and it lets you provide warranty if you want to.</p>  <p align="justify">So read the licenses now and select the one that you like. </p>  <h3 align="justify"><strong>Complex Licenses</strong></h3>  <p align="justify"><strong>GNU General Public License (GPL)  </strong></p>  <p align="justify">This is a highly restrictive license and any software that uses this license must also be distributed under GPL which makes GPL quite infamous and at the same time favorite to a breed of developers. There are several gotcha clauses in GPL. I am not going to describe it as there are many points to discuss. Please read it carefully. </p>  <p align="justify"><strong>GNU Library General Public License (LGPL)</strong></p>  <p align="justify">This is a better version of the GPL license aimed more at the software components. It lets you have LGPL license for the component to be used in software while other components can have different licenses.  Both the GPL and LGPL allows the open source software to be sold as long as the source code is provided. Please read the license carefully before selecting it. </p>  <h3 align="justify"><strong>Disclaimer</strong></h3>  <p align="justify"><font color="#ff0000">Firstly I am not a lawyer, and this is my understanding from what I have read in the licenses and there is no guarantee that what I am writing here is correct since this is my personal interpretation. I would advice you to read the  licenses before you apply them and I do not take any responsibility of my interpretation. </font></p>
<a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fwww.shafqatahmed.com%2f2008%2f10%2fcomparison-of-d.html"><img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.shafqatahmed.com%2f2008%2f10%2fcomparison-of-d.html" border="0" alt="kick it on DotNetKicks.com" /></a>
</div>
</content>



    <feedburner:origLink>http://www.shafqatahmed.com/2008/10/comparison-of-d.html</feedburner:origLink></entry>
 
</feed><!-- ph=1 --><!-- nhm:dynamic-ssi -->
