Technical blog archive
.NET King Support
 You can find the answer to your questions and inqueries here.
Where can I find the relevant material for WCF, WWF, WPF? (10/29/2007)

Hi Guys
 I received this question from Jay today and I thought this might be a questions for may of you:

Where can I find the relevant material for WCF, WWF, WPF?

 This is a very general question and I am not the right person to answer it completely. I have put all my focus on Windows Workflow Foundation and that's the only area that I can give you acceptable answers. Usually the first reference for the Microsoft technologies is Microsoft itself (Microsoft Official Curriculum, MSDN and Microsoft eLearning), but this advice doesn't work here. The first question is: what is your development background? I am not talking about .NET development skills. I mean good and deep understanding of Object Oriented concepts, Abstraction, Inheritance, Polymorphism and Design patterns. Good is not enough. You should be excellent. WF is developed based on OOA&P best practices and design patterns and once you are confident in OOA, it is quite simple to proceed. So to start with I personally recommend Object-Oriented Analysis and Design Using UML (OO-226) delivered by a very qualified instructor. As a trainer I have delivered this course for a couple of times (With Microsoft Visio and C# because I don't know Java ) and I believe this is one of the best starting points for most of the developers. Buy the way, you can find all classic design patterns in .NET here. The more you know design patterns the easier you learn WF.
As an MCT I always recommend Microsoft Official Curriculum (MOC) as the first step, but it seems that Microsoft is a little bit slow in releasing MOCs for .NET framework 3.0, so you should rely on MSDN and Microsoft eLearning at least for the time being. After the OOA&D warm up you have the following steps ahead.

  1. Understand the workflow basics: read this articles in detail Windows Workflow Foundation Overview. If some parts are not very clear don't waste time on that part. Go through it quite fast and everything will be bright. If you can understand it 70% you are in a good shape.
  2. Some visual workflow development taste: I don't mean to scare you, so let's experience the joy of Workflow Development with this article Getting Started with Microsoft Windows Workflow Foundation: A Developer Walkthrough that is published on MSDN by Solid Quality Learning (SQL). (I know Solid Quality Learning (SQL) from the time that I was living in Dubai. They gave us a training on SQL Server 2005 in July 2005 before the product release and the training was wonderful. The trainer was Dejan Sarka). I don't consider this article as a training material. It is just a developer test drive to work with workflow extension and see how it is like developing a simple workflow.
  3. Have your hands dirty with code: you may start from here Windows Workflow Foundation Tutorials depending on your taste. If you are a kind of person that can follow the code and instructions and learn the concepts, this is quite good and reliable content (this is MSDN-programmers bible, so you can put your right hand on it and swear in the court. lol). These samples are beautiful and they go deep into code level WF development. The walkthroughs are not visual and you may need a bit of code manipulation to open these examples with the workflow extension visually although all the codes compile successfully. To open the files visually you only need to make sure that workflow class is the first class definition in the code (It is just a matter of cut and paste that we are all expert in it).
  4. Spend a little bit on books: Hah, not everything comes as free download. If you are looking for a clean way of learning workflow foundation your candy material is here Microsoft® Windows® Workflow Foundation Step by Step. This book is sweet, but it doesn't mean that this book alone will make you a professional workflow developer. Good Object Oriented is still a MUST. By the way, this book is not perfect. Check this link before you start with the book.
  5. Learn workflow patterns and techniques: You are not supposed to reinvent the moon. Maybe by now you know how to drive WF; but do you know the driving rules? You can learn workflow patterns here: Programming Windows Workflow Foundation: Practical WF Techniques and Examples using XAML and C#.
  6. Find the right technology: WF is a super luxury sports car. But where can you go with this car. Not everything is .NET, Windows application or ASP .NET. The entire SharePoint workflow is built on WF. Install MOSS 2007 SDK and enjoy workflow development for MOSS with .NET.

Ok guys, I am done with my WF materials. Can anyone of you blog WCF and MPF learning path?

96 comments by now. Add your comments
SharePoint Page Viewer webpart! (4/16/2007)

I received this question from Ahmad Jadallah:
I am developing a small C# application that I will be showing inside sharepoint server 2007 through the page viewer web part.
I want to be able to show something based on the profile of the currently logged in user.
For example: If the city value of the currently logged in user is Paris then show button 1, otherwise dont show it.
How can I achieve that? I tried the SharePoint webservice but I could not get it to work.
best regards,

Dear Ahmad Jadallah
You are trying to read the user profile info in a wrong way. Remember that Page viewer WebPart cannot and does NOT interact with the page that it opens. In better word Page Viewer WebPart can only get the requested page and display it on the client. It does not execute the requested page as a part of SharePoint page and it does NOT run the requested page in the SharePoint execution context.

  1. To have your page interact with the SharePoint context you have two ways:
    Create your WebPart yourself and interact with the current user like a normal ASP .NET user (User.Identity.Name) and then decide of displaying the controls on the webpart.

  2. Try creating your ASP .NET page under server layouts “C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS” and call it under http://servername/_layouts/yourpage.aspx


12 comments by now. Add your comments
Process isolation sample (12/9/2006)

This sample code is prepared only for KFH clients. This is a simple COM+ component with it's client application used as the proof of concept to isolate a one process from another using COM+. Please notice that this code is only a proof of concept and is used as a training sample in a very controlled environment. Reusing this sample code without proper knowledge of Enterprise services is not advisable in production environment. (Here is the sample code).

29 comments by now. Add your comments
IIS and calling MSMQ (10/7/2006)

Dear Ali,
Reading from a private message Q works fine when I run it under inbuilt VS server2005 server,but when published on IIS server under a folder under inetpub/wwwroot the application fails throwing exception. "Access to Message Queing system is denied." Can you help?
Thanks. John PACI
Actual error log pasted below:- Wait At Q fails :Path is :FormatName:DIRECT=OS:dp-pcd-john\private$\commd_q :Access to Message Queuing system is denied.

Dear John
That is wonderful. I love these kind of errors, simply because without these errors we consultants were out of job (lol).
Ok, fun is enough. Open your IIS administration console. If you right click your ASP .NET web application you will see that on the Directory tab you have a property called Application pool. By default the Application pool is set to DefaultAppPool.

Just keep it in mind and close the properties dialog box. Now in the IIS administration console expand application pools. Then you will find the DefaultAppPool there. Hey, we are very close to the problem source now. Just right click on the default ApplicationAppPool and see the properties.

Click on the Identity tab and here is the problem. Actually your application pool tries to reach MSMQ using Network Service account when you publish the web application on IIS. With a little bit of playing with permissions you can have your ASP .NET web application with this Network Service account, but because it is a built-in windows account it can never reach out of server box resources and Public message Queue is one of them. So do it in a proper way and make the application pool Configurable and assign it an active directory account and provide access to the desired queue to that AD account.
 That will solve the problem. No doubt. Have fun and by the way, I am quite happy that I see at least some people in Kuwait are programming MSMQ.

109 comments by now. Add your comments
.NET DLLs and Unmanaged clients (10/2/2006)

This is the e-mail that was forwarded to me containing two questions.
I'm Omar Adel from Gamalearn company. We met the last seminar in Crown Plaza-AbuDhabi, and i took your email to contact you if anything comes up.
As i was working on a new topic, which is creating a Dll using c# in visual studio 2005.
I completely made the dll and then made another program in Vb which calls it and the return values where successfully retrieved.
But, when i tried implementing this 'DLL' in another software that i'am working with, it gave me the following error
"Couldn't find an entry point to the "function name", it has to be exported".
I tried searching for some code samples and solutions for this "entry point" problem but i only found some minor details which doesnt fullfill the purpose.
And so, what i need to ask you is the following:
1- How to create a successful " Dll " with the 'Pinvoke' or the ' Entry point ' so that i can call it from anywhere ?
2- In visual studio 2005, i can create a dll using only c#, or i have to use it along with c++ ??
Thanks for your time, and i will be waiting for your answer
Omar Adel.. Developer

Dear Omar
 The answer is very simple. When you create a .NET dll, you can call it from any .NET application that has reference to it. But you actually do NOT register .NET assemblies, so each and every single application which calls the should have the full path to the dll, or the dll should be located in the same client application path. The problem happens when you want to deploy the application with the dll to another server or computer. In this case you need to make the dll a shared assembly.
It is also simple. Here are some straight forward references to learn how to do it.
 OK, but as I can see your problem is something else. Most probably you are trying to call the .NET DLL from an unmanaged code (from an application which is not developed with .NET like C++, VB 6.0 or ...). This is impossible without registering the DLL and creating the registry tlb reference. If you want to call a .NET dll from a non-.NET client you need to follow these steps:

  1. inside your DLL create an interface that contains your desired functions and have your class implement the interface (.NET classes are not exposed to unmanaged code and only interfaces are used to create the type library)
  2. In visual studio .NET go to your DLL project properties and under the Build tab check the Register for COM interop
  3. Step 2 will creates the required type library for your dll and registers it on the development machine, but to run it on another machine you need to go to Visual Studio .NET command line and use regasm.exe command line tool to register it before calling by an unmanaged code. Remember that it is a .NET dll, so you cannot register it with regsvr32.
  4. When you want to call it in your VB 6.0 application create the object variable of type interface that you created and then assign the class instance to the variable of type interface.
  5. Call any function like the normal com functions.

Important note: Not all your .NET functions will work in unmanaged code. Remember that the .NET specific parameters and return values are not supported in unmanaged code and functions with these return values or parameters will not work in unmanaged client.

Morale: Who cares about unmanaged code, in the near future everything will be .NET and I personally believe most of this hassle does not worth it.
If you need any help or additional explanation, just put a comment for this note.

By the way, a dll is nothing special. In any language that you can make a class and then compile it so that another application can call it, you have made a dll. So you can simply make DLLs out of anything (remember cupcakes in cat in the hat movies - lol).

37 comments by now. Add your comments
WSS prompt for User name and Password (9/10/2006)

I received this request from Shahid Hussein from Global Investment House.

Dear Ali Reza,
I am trying to install windows share point services 2.0. after the wss installation right after iisreset command, it opens browser and asking for the user name and password. Why it is asking for password.
SQL Server and IIS both services are running fine on that server.
Here is the reply
Dear Shahid
 The reason is very simple. In default installation of WSS the virtual server has disabled Anonymous Access and uses integrated windows authentication.

If you are using Internet Explorer to access the portal site by default IE uses automatic login for the integrated windows authentication from IIS side. Otherwise simply go to IE, tools menu -> Internet Options -> Security (Tab) -> Select the local Intranet and select the custom level. Once you scroll down you will find the user authentication options. Make sure one of the Automatic options is selected. You may need to do the same setting for the trusted sites.

If this does not solve the problem you should check the IIS and make sure that it is configured for Integrated Windows Authentication (not Basic Authentication).

15 comments by now. Add your comments
BizTalk server 2006, where to start! (8/18/2006)

I am trying to do a quick learning of Biztalk Server and may want to gradually give any MS Certification exams on the same. Could you please tell me where to start? Can I install biztalk in my laptop (toshiba tecra s1, 20 GB hdd free, 2gb ram) Which book/online resource should I use? Do you have any installable tutorials on it? 
Thanks, Manjit

Dear Manjit
The first answer is yes. You can install BizTalk on your laptop with mentioned configuration, but don’t try it with less that one GB memory or you will really suffer. While doing the installation for BizTalk 2006 make sure that you have a proper internet connection that can afford around 50MB download during the installation. This is critical. During the installation of BizTalk 2006 it will install a couple of prerequisites and it has to download it from Internet. The disgusting part is that during the installation of those prerequisites, it doesn’t show you any feedback on the download progress. The only indicator that you can rely at this step is just checking your network monitor to see the download is going on. On my first installation I restarted the process 3 times and in all times I had the impression that the system crashed, while it was downloading the required elements.
By the way, before you install BizTalk 2006 you need to install SQL Server 2005 (or SQL Server 2000 with SP4), Visual Studio .NET 2005 and Windows SharePoint Services version 2.0 and preferably Microsoft Office 2003. If you are not installing office at least you need to install OWC (Microsoft Office Web Components), otherwise your Health and Activity Tracking will not work and BizTalk development without health and activity tracking is literally a nightmare.
The best training pack that I can recommend is free BizTalk server 2006 Tutorials. Just download it from the provided link and have fun. I studied the same tutorial for BizTalk 2004 and when I did the MCTS exam for BizTalk 2004 almost all the questions were there. The other very nice resource to warm up is Clinic 2954: First Look: Microsoft® BizTalk® Server 2006 for Developers. This online training is a wonderful free training. I myself completed it and it has lots of wonderful presentation demos and walkthroughs. This training is also free (at least for the time being). 
 Apart from all these things an instructor let training with an experienced BizTalk consultant will change the entire image. Simply the things that you may learn in 3 months with self study, with the help of an instructor you can get it in one day (No exaggeration at all). So if it is a corporate requirement also consider attending a course even for 20 hours introduction to biztalk server. Remember apart from a product, business integration is a concept that you cannot learn it by only learning the BizTalk server. To learn this part, the book Microsoft BizTalk Server 2004 unleashed (SAMS publications) has a wonderful introduction that will help a lot. Unfortunately at the moment I cannot recommend any book like this for BizTalk 2006.
 Also try, you will find lots of videos that help and teach you tricks. 
 I wish you best of luck and I am sure you will enjoy BizTalk a lot more that COM+. I seriously believe that BizTalk server is the sweetest product that Microsoft has ever released.

10 comments by now. Add your comments
I am starting SharePoint community (7/29/2006)

I finally made up my mind to setup a community for SharePoint developers, consultants and administrators. SPS 2007 is almost there and there are so many features that it is really difficult to grab. As we have already learnt, let's learn form each other. At the moment I need to setup the core team to have the first session and approach the vendors to have their support. If you feel that you are interested to learn SPS 2007 ins and outs, and also ready to help the others learn more about what you know, probably you are the right person to start this community. Kindly submit you comments about this community and if you are interested to be the first people to join this community drop me an e-mail to
 Waiting to receive your replay in the following days.

6 comments by now. Add your comments
Web deployment clarification! (6/29/2006)

This is the clarification request I received form our dear friend Mr. Moustafa Arafa.
Dear Ali
 regarding your article "Typical deployment scenario", you have mentioned that we will create a domain account to be used by the application poll for our web application, but the question here is : most of companies, they have policies to renew the password for all AD accounts maybe within 2 months max..... should I have to go to the IIS again and re-type the new password every renewal process from AD ?

Dear Moustafa
 The answer is NO. When you create a domain account or even a windows account you have a checkbox as Password never expires that once checked it overrides the group policy for password change. So let's say regardless of group security policy settings, a typical account assigned to an application pool or even a service account MUST be configured as follows:

- Make sure you put a Description that tells the network administrators that this is a service account or an application pool account so they do not delete it by mistake.
- User must change password at next login MUST be unchecked. Simply because an application pool cannot reset it's password. I just mention it because it if the default network administrators mentality that the user must reset his/her password at first login and usually as a developer you do not create user. If this option is not checked you web application stops working when the password expires and when you reset the password in this case you have to reset in for the application pool again.
- Password never expires should be checked to override the group policy for changing the password after a certain duration.
This setting is good enough for an application pool account, but if you want to use an active directory account for a service you still need some more settings that I will cover it in my next post.

7 comments by now. Add your comments
I finished the article I promissed!! (6/21/2006)
After I submitted my post titled as "ASP .NET deployment sucks!", I received a couple of e-mails from friends waiting for this article to be published. Although I was very lazy last week, the article was ready the 3 days after that post, but I was too busy adding the screen captures and organizing the article to be useable. Now it is ready. Enjoy it!!
6 comments by now. Add your comments
About MCDBA (6/7/2006)

 This is the E-mail I received today from an old friend in Canada and I want to share the content and reply with all of you.

 I was exploring in Microsoft website to find more about MCDBA. I was confusing about the new certificate "MCTS" which it's books aren't available yet. I thought you are the best person who can help me. How can I start to study for DBA certificate. As you know, I'm in Canada. Please introduce me the books. I will find them here and start to read as soon as possible. Thanks

Dear Nazanin
Let’s take a look to the role of a Database Administrator. I believe we’d better be more specific and just talk about SQL Server administration.
SQL Server is a service that works with integration with Windows (2000 or 2003) server. So as an efficient administrator one should have a solid knowledge about windows 2003 server. So as a starting point the best place I believe is the book MCSA/MCSE Self-Paced Training Kit (Exam 70-290): Managing and Maintaining a Microsoft® Windows Server™ 2003 Environment, Second Edition. If you have the chance to attend a course, the courses 2274 and 2275 are better choices. If you have a good knowledge of Active Directory it is always considered as a plus, but I believe what you get from these courses out of active directory will be enough.
 Now it is the right time to start with real SQL Server. I assume that as a person who decides on a career in SQL server administration has a good background in SQL language. If so the next step is starting SQL Server administration courses. The courses 2779 and 2780 are decent courses. But anyway considering that now .NET Framework is embedded in SQL Server 2005, it is always expected from a database Administrator to have at least the .NET knowledge to read the .NET code. Consider any course or book that can give you a clear idea about .NET Framework. Worst case scenario, you can take the MS 2559 which I believe it is enough to start SQL Server 2005.

Some Friendly Advices for DBAs
 Don't forget that a Database administrator gets a high salary for almost doing nothing! but gets fired with the FIRST mistake. Make sure you will be quite confident in what ever you read. A DBA must know at least one thing down to the last details which is "
HOW TO RESTORE A DATABASE". Remember for anything you have time to go through the training materials, articles and references and you have lots of free time to do them. But in a case of a database disaster, you will have a very limited time under extreme pressure to have the server up and running in minimum duration to minimize the production down time.
Best of luck

14 comments by now. Add your comments
Using stored procedures (2/23/2006)
Question from Diaa
I want to know why stored procedure faster than select statement
Stored procedures are faster in execution than add-hoc queries (not only select statement). There are a couple of reasons behind it that I just mention some of them.
The steps of executing any SQL statement by SQL Server are as follows:
Parse --> Validate à Optimize --> Compile --> Execute. These steps come one after another when you submit any add-hoc query to SQL Server. When you make a Stored Procedure after the first execution the compiled query is stored in the procedure cache in memory, which means all the four first steps are bypassed for the next execution.
The other very simple reason is that by doing a significant part of the application login on server using stored procedures you are actually minimizing client-server round trips which significantly enhances the performance.
The only disadvantage of using stored procedures is that you have to accept what ever the stored procedure returns while sometimes we need to sort or filter the data returned by a request. If this is your case consider using User-defined functions.
By the way if you need more info about user-defined functions just let me know in your comments.
78 comments by now. Add your comments


As a consequence, I believe much more than pleasant making up what exactly simply an important girl's fake omega which can be, designed for at a minimum various individuals, decent rolex replica sale for one individual. As expected, this is often an intriguing technology, pretty much female's rolex replica sale are instead slighter products in you will be able fake omega, additionally, the inverted is kind of hard to find.