Thursday, September 30, 2004

VJs Tip Of The Day - September 30th 2004

Generating Proxies for WebServices

If you have created web services and wish to generate proxy classes for your webservices then there is a tool in VS.Net called "WSDL"... This tool will take the location of your .asmx file as a parameter and will dynamically generate proxy class for your web service.
There are various switches used by this class like for eg \l:vb will create the proxy class in vb; \o:C:\MyProxyClass.vb will create the proxy class at a particular location. There are many other options check out MSDN for further information. Click here

PS: I have got infected by new kind of psychological disorder... When I am working I look forward to having fun... When I am having fun I look forward to work... During weekdays I wait for weekends, during weekends I wait for Monday to come and rush back to work... I know such situations are called "Circular referencing" or "Cyclic dependencies" technically but I wonder what is psychological term... Pointers would be appreciated!!

Wednesday, September 29, 2004

VJs Tip Of The Day - September 29th 2004

Build Vs Rebuild in VS.Net

A very basic but a less know question for today... What is the difference between Build and Rebuild solution in VS.Net or why at all we have two...
Well the difference is that Build solution will build only those projects which are changed since the last build... It will not get the changes of the updated embedded resource files...
Rebuild solution will cause everything to be rebuilt no matter whether it was changed or not...

If you are making small projects the differences would not matter much but for large builds these are really useful...
There are advanced differences though but these are something which all should know...

PS: If you wish to add few of your discoveries shoot me an email and I will update folks with tomorrow's tip...

PS:Swapnil B has added to the list and made it explicit that Rebuild will bydefault update your refrences too...

Tuesday, September 28, 2004

VJs Tip Of The Day - September 28th 2004


Activator is a class in System namespace... This class is one of the most widely used class to create instances at runtime, of types locally or remotely defined... Usually it returns back an object or an objecthandle... There are lots of overloads of this method and in local scenarios mostly take System.Type() as one of the parameter... Its certain overloads also take typename as string and return back an object handle... This objecthandle then needs to be unwrapped to get back the object... The overload which returns objecthandle is mostly used in remoting...

CreateInstance is a static member of the class and so can be accessed directly without object creation...

PS: Abhishek, Microsoft India MVP lead has helped us get the below information:

Announcing Security Guidance Hands-On Labs Online
Microsoft Learning is pleased to announce the free, worldwide availability of Hands-On Labs 2811, Applying Microsoft Security Guidance, at
This offering consists of four 90-minute labs that allow students to apply information and guidance to improve security in a network based on Microsoft Windows. These labs have been enormously successful at live events since their original release in April 2004, with over 12,000 deliveries through Certified Partners for Learning Solutions (CPLS). In addition, these labs have been offered at conferences and events worldwide, including TechEd US, TechEd Europe (highest-scoring labs).
Lab 1: Managing Security Updates

Lab 2: Implementing Server Security

Lab 3: Implementing Client Security for Windows 2000 and Windows XP

Lab 4: Implementing Application Security

Customers can now take these labs for free at home or in the office by registering at The labs are conducted using real hardware in a safe online environment built on Microsoft Virtual Server technology. These are the first free hands-on labs online offered by Microsoft Learning and these will be followed by additional free labs on Windows XP Service Pack 2.

Monday, September 27, 2004

VJs Tip Of The Day - September 27th 2004

SoapInclude Attribute

In case of webservice programming you can allow SoapInclude Attribute on your webmethod to make sure that the specific type gets passed by... You use this attribute on your webmethod when in normal circumstances that type would not get passed...
For instance, if you have a class inheriting for a base class and a member is declared of the type base class and later instantiated as derieved, then the derieved class will not get passed across in that scenario on your webmethod you would apply this attribute...

Look at the example below...

<WebMethod(), SoapInclude(GetType(Circle)), XmlInclude(GetType(Circle))> _
Public Function ReturnSomething(ByVal key As String) As Shape
If (key = "Circle") Then
Dim circl As Shape = New Circle()
circl.area = 2
Return circl
End If
End Function

<Serializable()> _
Public Class Shape
Public area As Double
End Class

<Serializable()> _
Public Class Circle
Inherits Shape
Public radius As Double
End Class

Thursday, September 23, 2004

VJs Tip Of The Day - September 23rd 2004

Asynchronous Programming in WebServices

Callback functions are the way to implement Asynchrounous programming in Webservices... We will get into details of this topic sometime but now just an overview...
A client calls the Begin method on the server object and passes a reference to the callback method... The asynchrounous method on the server object finishes execution and gives a call back to the method on the client object... This method in client object now causes the call to End method on the server object.... The End Method then returns the result to the client...
Well why would you do such a thing??... The simple reason can be when your server side execution is really going to take long and you do not want to wait for all that processing to happen...

PS: I just remembered a saying from a wise man, thought I would remind you all of that too...
"If Everything is under control... Then you are not moving fast enough..."

Wednesday, September 22, 2004

VJs Tip Of The Day - September 22nd 2004

Application Domanis

Application Domains are the boundaries within which applications run... Application domains provide an isolated environment to applications, the kindof isolation level that is very similar to process isolation levels, though what is worth nothing is that a process can have multiple application domains within itself... An application running in one app domain cannot directly access code running under other app domain...

Monday, September 20, 2004

VJs Tip Of The Day - September 20th 2004

App Config File not being picked up

Some times you would have done nearly everything right in the windows application but still on trying to access configuration file you would get back null or nothing... Well the problem might be the name that you have used for the config file...

You should know that for a windows based application to pick up app.config file following should be taken care of...
1.) The app.config name should match your assembly name... i.e. if you have myapp.exe then the config file name should be myapp.exe.config...
2.) Also you should know that the config file is picked up for the main or the application which is the starting point... So your app.config file should be attached to that...

PS: There is a small correction to the above tip... Thanks to Darya, an old colleague of mine for pointing it out... I have corrected the blog if anyone can tell me what I corrected then a virtual candy from me to him/her... :-)

PS: I counted that close to 37 people asked me "How are you?" today... Out of these only 7-8 actually waited for me to respond, rest all just walked by... I wondered why such formalities when no one really cares to know, but then I thought - This is atleast a good way of proving our kids that "Man is a social being..."

Thursday, September 16, 2004

VJs Tip Of The Day - September 17th 2004

Callback functions

Callback functions are powerful tools and we should know how to use them... In general a callback function is a reference to a method that you pass to another method... When the second method calls the referenced method , it actually calls back to the first method... This might be a confusing terminology but a code snippet from MSDN will probably help make it clearer...

using System;
using System.Runtime.InteropServices;

public delegate bool CallBack(int hwnd, int lParam);

public class EnumReportApp {

public static extern int EnumWindows(CallBack x, int y);

public static void Main()
CallBack myCallBack = new CallBack(EnumReportApp.Report);
EnumWindows(myCallBack, 0);

public static bool Report(int hwnd, int lParam) {
Console.Write("Window handle is ");
return true;

Here is the link for you to explore more.... Click Here

PS: I have coined a new term called "Developer's Superstition"... I suffer from this problem often - When code does not seem to behave the way I want it to, knowingly/unknowingly I try things which I know will not work, which I know are technically impossible but still I do just to make myself feel good that I have left no stones unturned... I wonder whether you guys also do such thing... A classic example would be trying to call GC.Collect() method when a StreamReader is not releazing a file even after calling close()...{usually its some other process holding the reference...:-)} I wonder has MS Technologies made me superstitious or is this same everywhere... :-)

VJs Tip Of The Day - September 16th 2004

Xcopy Deployment

Xcopy command is used to easily copy all the files of a .Net application to a target installation directory... For applications that do not require any further registration Xcopy is command is the simplest way to distribute your .Net applications...

Do note that Xcopy command does not copy the hidden and system files... Also note that Xcopy creates files with the archive attribute set, whether or not this attribute was set in the source file...If you have a disk that contains files in subdirectories and you want to copy it to a disk that has a different format, you should use the Xcopy command instead of Diskcopy. Since the Diskcopy command copies disks track by track, it requires that your source and destination disks have the same format. Xcopy has no such requirement. In general, use Xcopy unless you need a complete disk image copy or you wish to copy the system files.

PS: All I ever needed to Know, Most of what I needed to know about how to live, And what to do and how to be, I learnt in Kindergarten. Wisdom was not at the top of the Graduate school mountain, But there in the sandbox at Nursery school. These are the things I learned: Share everything. Play fair. Don’t hit people. Put things back where you found them. Clean up your own mess. Don’t take things that aren’t yours. Say sorry when you hurt somebody. ......Be aware of wonder. Remember the little seed in the plastic cup. The roots go down and the plant goes up and Nobody really knows how or why, but we are all like that....
These are the wonderful words of Robert Fulgam... Read his book "All I Need To Know, I Learnt in Kindergarten" and do remember- "Technology should not overwhelm you"...

Wednesday, September 15, 2004

VJs Tip Of The Day - September 15th 2004

Resource File Generator Tool

Resource file generator tool is used to convert resource file in the form of .txt or .resx files to common language runtime binary .resources files... These files can be compiled into satellite assemblies..

This utility can do conversions in other directions too and uses following classes to do the conversions
ResourceReader Class
ResourceWriter Class
ResXResourceReader Class
ResXResourceWriter Class

The exe name for the tool is ResGen.exe... If you search MSDN with the keyword you will find ample information...

PS: I was wondering when would people start using MSDN to search MSDN and not Google... I am trying to develop this good habit... :-)

Tuesday, September 14, 2004

VJs Tip Of The Day - September 14th 2004

Quick MultiThreading
This is some real quick good info for specific scenarios... If you are writing some workflow logic of yours and in-between you realize that you want to perform some tasks which would be time consuming but actually are also apart from your actual business logic and so you would not want your business logic to waste on performance by waiting for those tasks to complete... Some of the examples of such tasks would be printing, cleaning back-end, doing logging or tracing functionality etc...
Well this is when the System.Threading.ThreadPool class comes real handy... There is a static method called QueueUserWorkItem... You can call this method with the method that you want to execute Asynchronously... The Threadpool will use the first available thread to process your request... Now your main business logic does not need to wait for this function to finish...
Now this function can as well give a call back but then it depends upon your requirements...
Read more about it on MSDN... Click Here...
PS: This tip is a result of my discussions with Matt, a colleague of mine... We often discuss interesting technical stuff in our "Leisure At Work" (LAW can never be illegal right!!)

Note: Caution on multithreading... You should know that if different threads are gonna use the same resource then multithreading might cause performance hits as well... Thanks Kathleen for reminding...

Monday, September 13, 2004

VJs Tip Of The Day - September 13th 2004

ToolTip in Windows

Well if you have been doing Web development for a long time in .Net now, if you switch to windows it would pretty much possible for you to search for the standard ToolTip property for all the controls and guess what you won't find it... :-) Windows UI is much more richer than web and so the windows controls try to leverage that... For this reason there is a special ToolTip control which is provided to you in the windows environment which you can associate with any of your controls...
Now what are some of its advantages the code below will tell you:

ToolTip vjsTip = new ToolTip();
vjsTip .InitialDelay = 1500;
vjsTip .ReshowDelay = 1000;
vjsTip .SetToolTip(this.txtZipCode, "You need to provide a zip code only if you are in US or Canada");

Similarly you also have GetToolTip() method... Well so go ahead and try explore more on the ToolTip control...

PS: Hope you all are doing fine!!...How did it feel when a forcible mail did not drop into your mailbox for so many days??... Good!!..Bad!!...Well, after giving you a small break, I am back again to bug you, make you take your pill daily... But if you do not like the pills then drop me a mail I will try that they don't reach you... Otherwise, the second season has begun... :-)

Monday, September 06, 2004

Very Limited Access To Internet

Hi All,
I have very limited access to internet as of now and I will be getting a new connection set up at my home only by Sept 11th 2004... I have my entire mailing list as well all my work on my laptop/CDs... Only after my internet connection is up I would be able to update any further posts or send tips...
Please bear with me till then...
best wishes,
Vishal Joshi
If You Think YOU CAN... You Can...