Friday, April 22, 2005

What is WebDAV and DeltaV

* WebDAV: RFC 2518. Extends the standard HTTP methods to make web servers behave as traditional fileservers, complete with a locking model and meta-data properties.
* DeltaV: RFC 3253. Adds more HTTP methods to WebDAV, introducing versioning concepts. Provides a number of flexible versioning models that servers can support, and some backwards-compatibility modes for older WebDAV or HTTP/1.1 clients.

Tuesday, April 19, 2005

Top Ten Tips for Web Services Interoperability

Top Ten Tips for Web Services Interoperability
I thought it might be fun to put together a "Top Ten Tips for Web Services Interoperability" - especially between .NET and IBM WebSphere, BEA WebLogic and some of the open source toolkits. I'd love to add other people's experiences, findings and comments to this list...
Here goes (from the bottom):
10. Watch out for Empty Arrays
Sending empty arrays over Web Services can create issues some toolkits recognize an empty array as a single null value. If you are sending arrays of objects over a Web Service, always ensure that the array contains valid data.
9. Use Package and Type Name Options when Generating Client Proxies
Many Java based tools have the option of specifying a unique package and type name when generating client proxies (for example, BEA WebLogic uses clientgen parameters to do this). This is essential when you are creating proxies for Web Services that share the same data type.
8. Testing Generated Java Beans for Null
When using tools or an IDE to generate Java Beans from an XSD file, always make sure that you know how to test to see if the object is null. In some instances this is done using the
isNil() method on the bean itself.
7. Null Dates and Times are recognized by Java, but not by .NET
In Java,
java.util.Date and java.util.Calendar are classed as reference types. In .NET, System.DateTime is considered a value type. Reference types can be null, whereas value types cannot. If you are planning to send null date values across a Web Service, always send the value in a complex type, and set the value of the complex type to null. This will help prevent the null date value being interpreted incorrectly (and raising an exception).
6. Always use compareTo() when comparing dates/times
If sending dates and times over a Web Service between .NET and Java, always use the appropriate
compareTo() method in Java to compare dates (as opposed to date == value). This will help ensure accuracy for date comparisons between the platforms, especially when trying to compare those milliseconds values.
5. Use Trace Tool to Investigate
A Trace Tool can be invaluable for investigating SOAP requests and responses between Web Services. It can help validate data types and the construct of the message, and also report SOAP faults that you may miss in a browser. Using one that intercepts the request is more difficult to setup, but easier to use than looking through trace files.
4. Add Option to Change Host and Port
When designing your Web Service client, consider adding a helper method to change the host and port values of the Web Service location. This makes it easy if the location of the Web Service changes in the future or you want to redirect the output to a trace tool.
3. Ensure Document/Literal when generating Web Services
Many toolkits have the option of choosing either RPC/Encoding or Document/Literal as the default format when generating Web Services. To help ensure compliance with the WS-I Basic Profile 1.0, select Document/Literal as the default encoding mechanism for all of your Web Services.
2. Use Unit Tests to Test Interoperability
Unit tests (using NUnit for .NET and JUnit for Java) are invaluable for testing interoperability of multiple data types over a Web Service. Re-running the tests if data types change (or if you change versions of Web Services toolkits!) will give you the confidence that the Web Services that you design are fully interoperable.
1. Use XSD First
When designing for interoperability, always start with defining the data first. Deciding on what data will be sent, creating the data type in XSD first, and then using tools to generate classes from the XSD file will help guarantee data type interoperability on the wire.

Getting Multiple Virtual PCs to Work Together

I'm a big fan of using multple Microsoft Virtual PC images, especially for demos and development. My current machine has a second hard disk that is dedicated to images that I use for such work.
One of the problems I've run into in the past is getting multiple Virtual PC instances to talk nicely together over a network - regardless of whether the host machine is connected or not. On frequent occasions I've turned up to do demos only to find out that Virtual PC #1 cannot see Virtual PC #2 on the network - even though they are on the same machine!
This week I've been putting together a demo that involves 4 Virtual PCs talking to each other simultaneously (showing interop between different vendors). I put in some time working out a foolproof way to get each Virtual PC to talk to each other, and also be able to use the network adapter of the host machine.

Here's how I nailed it:
1. Shutdown all of the Virtual PCs that you want to connect together (they must be turned off - suspend state is not good enough).
2. In the Virtual PC console, select one of the Virtual PCs and select "Settings"
3. In the Setting window, go down to "Networking"
4. Under the "Number of network adapters", select "2" from the combo box.
5. Set the first adapter to the network interface of your machine (e.g. Intel/PRO/1000 MT Mobile Connection).
6. Set the second adapter to "Local only"
7. Start the Virtual PC - log in and make sure that two network adapters have been recognized.
8. Assign the first network adapter (Local Area Connection) to DHCP - or whatever settings you use on the network connected to your host machine.
9. Set the second network adapter (Local Area Connection 2) to a static, private class C IP address (e.g. 192.168.200.1, with a subnet mask of 255.255.255.0). Set the default gateway to 192.168.200.254. Don't worry about DNS settings.
10. Repeat Steps 2 - 9 for all your Virtual PCs - make sure you give each Virtual PC a unique IP address in step 9, but within the range of your subnet (e.g. 192.168.200.2, 192.168.200.3 etc. for my example).
11. On each Virtual PC edit the hosts file (found in c:\windows\system32\drivers\etc directory). Add the name of all the other Virtual PCs, together with their IP address.
12. Make sure that the Internet Firewall on adapter #2 is set correctly for the type of applications that you want to work between the Virtual PCs.
That's it! - from any Virtual PC you will now be able to both access any other Virtual PC using the hostname and/or IP address you allocated on the second network card. You should also be able to access the outside world using the first network adapter.

Monday, April 18, 2005

What is the difference between a CLS and non-CLS compliant object?

What is the difference between a CLS and non-CLS compliant object?
CLS Compliant "things" can be consumed by all .NET languages that are themselves CLS compliant--IronPython,
Boo, etc
.Things that aren't CLS Compliant tend to be things that are only available to a certain language--
for instance, Boo's
duck type is not CLS compliant and probably shouldn't be exposed in any public API,
because it only has meaning within the Boo language itself.

Friday, April 15, 2005

Wahoooooooo ! Visual Studio.NET 2005 Beta 2 in Out

This new is made my day...
Currently Visual Studio.NET 2005 Beta 2 is available for MSDN Subcribers

I'm lucky I have one. It is Really a great News for lot of developers

Thursday, April 14, 2005

Check the links below on April 14

Middle-Tier Hosting: Enterprise Services, IIS, DCOM, Web Services, and RemotingBy Rockford Lhotka


The Perfect Service - Part 1By J. Ambrose Little

The Perfect Service - Part 2By J. Ambrose Little

http://blog.magenic.com/andym/

http://jelle.druyts.net/
http://jelle.druyts.net/SyndicationService.asmx/GetRssCategory?categoryName=Blog

http://jelle.druyts.net/SyndicationService.asmx/GetRss

Wednesday, April 13, 2005

Be careful when doing lot of operations on strings

If your code has lot of string manipulation within it, you have to take a gentle care of the way you write your code. For example take a look at the following code snippet.
string str = Hello Bob;
str += & Alice;
As you see, you may assume that your code will allocate memory for only two strings. Actually your assumption is too bad this time. In .Net when you concatenate two strings it returns a COPY of the modified string. Therefore there will be 3 allocations for 3 strings in the above code execution.
I'm pretty sure now you be wondering "why make a big fuzz for a single string concatenation line?" Actually your thinking is quiet good this time. Your code will not gain any significant performance issue with a single operation. But as the number of string operations grows up you code will tend to notice performance issues. The reason for this is, the runtime allocates memory for each any every copy of string.
Thanx to microsoft,
StringBuilder class, alternative approach to overcome this problem, is there. Always try to use StringBuilder class when you are dealing with string operations.
StringBuilder provides a rich set of functionality to do almost everything that you wanna do with a string. You could do the above operation as follows with the StringBuilder class.

StringBuilder sb = new StringBuilder("Hello Bob");
sb.Append("& Alice");
Even though you use StringBuilder, make sure you are aware of the reallocations. :-) So you can use
sb.Capacity = 20;
to specify the initial capacity you want for the final string. That makes sure that the reallocations happen when you reached the maximum number of characters.
Happy Programming!

Hiding your app when the close button is clicked!

Have you ever tried to hide your Windows Forms application when the close button is clicked? Well then you'd probably have encountered problems when shuttin down.
Actually if you try to hide your form in the Form_Closeing event Windows will not be able to close your application while shutting down. When you shut down windows, it will send WM_CLOSE message to each active window and closes them before shutting down. So if you avoid closing the application by adding some custom code, it will interrupt Windows being shut down.
So what exactly you have to do is, to check whether the form is being closed by the user or the system shut down op. Perhaps you must be wondering under which event of the Form class, you should do it. Well... the answer is there is no particuler event. As you may all know by now, neither Form_Closing nor Form_Closed event has a parameter to detect the source of the close command.
hmmm... now what?
Dont worry! Thanks to the .Net Fx we still have a method for that. Form class is the base class for all Windows Forms. It has a overideable method called WndProc(). This is the default window message handler. We can overide this to allert us when the WM_CLOSE message is sent by System shutdown op.
Following code snippet sets a public flag "on" if the WM_CLOSE is sent by shutdown op. If the flag is "on" then Form_Closing event will close form insead of hiding it.

private bool _isShuttingDown = false;
protected override void WndProc(ref Message m)
{
_isShuttingDown = (m.Msg == 0x11); // Detect if shutting down.
base.WndProc (ref m);
}
private void Form_Closing(object sender, CancelEventArgs e)
{
if(!_isShuttingDown) // Cancel closing if not shutting down.
{
e.Cancel = true;
this.Hide(); // Hide the form.
}
}

Hope this helps!

overriding WndProc will catch only messages for the form, not for contained controls. This will catch all messages for all forms and controls in your application:
partial class Form1 : Form, IMessageFilter
{
public Form1()
{ InitializeComponent(); }

private void Form1_Load(object sender, EventArgs e)
{
Application.AddMessageFilter(this);
}
public bool PreFilterMessage(ref Message m)
{
Control sender = Control.FromHandle(m.HWnd);
return false; // true to discard the message
}
}

Being productive when working

Recently I read an article about being productive when working.

Hope the following tips will help you too.

  1. Close all the messanger applications. [i.e. MSN, Yahoo, ICQ]

  2. Close your email client application [i.e. Outlook]

  3. Close your office room door and hang a notice "Do not disturb"

  4. Have some cool music playing in very low volume.

  5. Ask your assistant or the answering machine to pickup the phone.

  6. Just try to follow the rules atleast for 3 hours continuously and take a break.


Belive me it works!
Enjoy your work!

Inheritance! Inheritance! Inheritance!

One of the key concepts in object oriented programming paradigm is Inheritance. Today Im going to show you an interesting thing for most of the C++, OO and .Net guys.
In OO and C++ there are three levels of inheritance is available for the class members as public, protected and private.
And the accessibility of your base classs members depends on two factors.

The way the derived class declares its class head (public, protected or private)
Access speceifier given for the class member (public, protected or private)
If you mark members as private in your base class, those members are inaccessible regardless of the derivation access.
If you mark members as protected in your base class, and if you do private derivation those members become private in the derived class.
If you mark members as protected in your base class, and if you do protected derivation those members become protected in the derived class.
If you mark members as protected in your base class, and if you do public derivation those members become protected in the derived class.
If you mark members as public in your base class, and if you do private derivation those members become private in the derived class.
If you mark members as public in your base class, and if you do protected derivation those members become protected in the derived class.
If you mark members as public in your base class, and if you do public derivation those members become public in the derived class.


Well those rules are for the old C++ folks. Take a careful look at the 2 scenarios highlighted.
In .Net the way those two works is radically different. .Net supports public inheritance only.
But when a class is inherited with public access the base classs protected members will become private to the derived class.

Consider the following 3 classes in C++
#include
class A
{
protected: void fa()
{printf("fa called"); }
};
class B : public A
{
public: void fb(){fa();}
};
class C : public B
{
public: void fc(){fa();}
};
int main()
{
C c;
c.fc();
return 0;
}
In C++ it will just work fine according to the rules I just described above. But if you make them managed classes you will not be able to call fa() from class c.

Using SQL server as state server in ASP.NET

Choosing the correct place store the session state for web application is a real challenge.
The way the session data is store and how much session data is going to be used are some of the questions rise when dealing with it.
Over the past few years developers thought about using SQL server as their session state manager under certain circumstances.
Some of them were because :
1. The web application has to be deployed in a server farm.
2. High number of users targeted to use the application and higher demand for large session data

Out of the box ASP.Net brings a session state management integrated with SQL server. Developers can easily configure a SQL server to act as the Session management server. This also enables developers to implement a failover cluster, so that they can make sure that application is available even if one SQL server is down. Also this enables the application to be deployed in a web farm since the session is managed by SQL server running on a different process rather than the IIS process itself.

How to configure :
First run the InstallPersistSqlState.sql or InstallSqlState.sql you find in SystemFolder\Microsoft.NET\Framework\VersionBoth of these files do the same thing.
But they differ from where they create the tables to hold session data. If you use InstallSqlState.sql it will create the tables in the TempDB causing the data to be removed when, the SQL server is restarted. But if you use the InstallPersistSqlState.sql it will create the tables in the ASPState database and data will not be deleted when, the SQL server is restarted.

Once that is done your SQL server is ready to act as a session management server. Then you can simply add the following entry in Web.config to use it.


So making SQL server as a State server is simple as that. But there is one more thing you should pay attention when storing custom objects in the session. ASP.Net stores objects in SQL server by serializing them to a byte stream. Therefore your custom objects should be serializable in order to work with SQL session state server.

Friday, April 01, 2005

State of .NET development almost three years after

Posted by: Fabrice Marguerie on November 03, 2004 @ 09:30 AM
Almost three years after .NET 1.0 has been released, and before .NET 2.0 appears, it looks like .NET reached a momentum.Projects based on the .NET platform are now common, the material available to developers is quite impressive, and the number of developers keeps growing.Let's take a look at where we are now, and see some numbers.Three years after its official release in 2002, it looks like .NET reached a momentum. Several statistics could be used as evidences.Let's just consider the number of books, articles, code samples, web sites or forums dedicated to .NET...A sign is the number of developers who join the .NET community
keeps growing. Apparently, there are more than 2.5 million .NET developers world-wide.Showing how active the development sphere is, as of today more than 610 development tools, libraries and add-ins are referenced in the SharpToolbox.The most prospering categories are object/relational mapping products, all the other persistence and data-related tools, code generation, testing and profiling.Countless Integrated Development Environments (IDE) and add-ins for IDEs such as Visual Studio also exist.Language fanatics are not underprivileged, far from it with something like 70 programming languages compatible with .NET!The ability to target Linux with the release of Mono 1.0 this year is opening new horizons to .NET, without forgetting the various offerings for interoperability with other platforms or systems.Another indicator is the number of sites running ASP.NET. According to NetCraft, ASP.NET is currently on over 2.9 million active sites.After an important testing and validation phase, .NET becomes now widely adopted in enterprise. Numerous new developments are in progress, as well as heavy information systems migrations to the .NET platform.At first, companies were limiting themselves to a cautious adoption of the technology. But now .NET seems to be considered as valuable and as reliable as J2EE, and more than one enterprise uses both platforms at the same time.A lot has happened, but the future is still very promising. Next year will see the birth of .NET 2.0. In 2005 will also be released major products for .NET developers: Visual Studio 2005 and SQL Server 2005 (with .NET CLR integration), for example.