Pagination in ASP.Net DataGrid
Quick steps to work out pagination in your datagrid.. Go to your data grid properties... Set AllowPaging property to true... Set the PageSize to your desired page size... Now go to events section in the properties... You have to override PageIndexChanged Event... In the event handler... Write code similar to the one below:
private void dgdImages_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
//Change the current page index to the new one
dgdImages.CurrentPageIndex = e.NewPageIndex;
//Update your data if required
dgdImages.DataSource = CreateDataSource();
//bind the data again
dgdImages.DataBind();
}
That's it... Your datagrid does not need to make your page long scrollable now... Do note though that if you change the data in the background and the new data does not contain as many pages as your current page index now you might land up getting exceptions... So make sure that you do the necessary work there...
PS: I was driving my car today, trying to rush home from work, had to do some groceries and go to library to return books and read a martin fowler's new design pattern discussion and cook and have dinner and then go to photocopy some legal documents... Oh!! I felt... 24 hours are just not enough sometime... Then I saw a guy casually walking his dog and listening to his discman... I passed by and then pulled over... Thought for while...where was I actually going wrong, why was his life so different and nicer than mine... Why life has to be unjust, just to me.. And you know what I did next... Drove to Starbucks coffee house... Took a nice tall mocha and spent 30 minutes thinking of my own design pattern... I am paying $2 fine on the library books now and I spent $5 extra at the coffee house but then Ahh!! what a realization... My life was not much different than his, it was just in the way I looked at it...
Monday, October 11, 2004
Sunday, October 10, 2004
VJs Tip Of The Day - October 8th 2004
switch case statement
If you face an error like "Control Cannot fall from one case lable ('case:1') to another" while using switch statement in C# then the reason for that is you are not using a break statement after every case and compiler tells you that in case of switch statement the flow cannot continue from one case to annother...
Well VB.Net folks don't have that problem... Btw do make sure that you always have a default:break; statement for failover situations in the switch...
PS: I know this tip has silly, (everyone knows kind of) information but I got a little bit busy with my photography... The same no work on weekend philosophy...
If you face an error like "Control Cannot fall from one case lable ('case:1') to another" while using switch statement in C# then the reason for that is you are not using a break statement after every case and compiler tells you that in case of switch statement the flow cannot continue from one case to annother...
Well VB.Net folks don't have that problem... Btw do make sure that you always have a default:break; statement for failover situations in the switch...
PS: I know this tip has silly, (everyone knows kind of) information but I got a little bit busy with my photography... The same no work on weekend philosophy...
Thursday, October 07, 2004
VJs Tip Of The Day - October 7th 2004
Serializing Exceptions for Special Purposes
We should be aware that Exception class implements ISerializable interface for its serialzing needs. If we derive our own exception from ApplicationException and we anticipate chances of our exceptions to be marshalled across process boundaries we need to add [Serializable] attribute to our custom exception... Along with that we might have to implement ISerializable which can be done in the following way:
Have this special contructor and add each private member variable that you want to persist
protected customException(SerializationInfo info, StreamingContext context):base(info,context)
{
_myProperty = info.GetString("_myProperty")
}
Override the GetObjectData method
public override void GetObjectData(SerializationInfo info, Streamingcontext context)
{
info.AddValue("_myProperty", _myProperty)
base.getObjectData(info, context)
}
PS: While browsing through the Microsoft site I found that MS is offering a free skill assesment for .Net (usually worth $40) to everyone... Click Here for details
We should be aware that Exception class implements ISerializable interface for its serialzing needs. If we derive our own exception from ApplicationException and we anticipate chances of our exceptions to be marshalled across process boundaries we need to add [Serializable] attribute to our custom exception... Along with that we might have to implement ISerializable which can be done in the following way:
Have this special contructor and add each private member variable that you want to persist
protected customException(SerializationInfo info, StreamingContext context):base(info,context)
{
_myProperty = info.GetString("_myProperty")
}
Override the GetObjectData method
public override void GetObjectData(SerializationInfo info, Streamingcontext context)
{
info.AddValue("_myProperty", _myProperty)
base.getObjectData(info, context)
}
PS: While browsing through the Microsoft site I found that MS is offering a free skill assesment for .Net (usually worth $40) to everyone... Click Here for details
Wednesday, October 06, 2004
VJs Tip Of The Day - October 6th 2004
Error Redirection in case of Html or ASP Pages
I am not sure how many of you remember our old tip somewhere in the month of June... It was about the way to set Error Redirection page from web.config and how SmartNavigation options makes it goes crazy and work around for that... Well Click here if you want to read it...
What I wanted to add on to that tip today was that the settings that you do in the web.config files do not work for any .htm or .asp pages... i.e. If a user requests an .htm or .asp page which is not available then then your setting statuscode="404" redirect="pagenotfound.htm" in the webconfig will not work for that you will have to go within IIS metabase to configure the same.
The other interesting fact here is that if you did a xcopy deployment of your applyication then these settings will have to be manually copied to the deployment web server...:-)
PS: When things don't turn out the way you want them to be try and think "Today is the first day of the rest of my life... Let me start afresh with new determination and vigour..."
I am not sure how many of you remember our old tip somewhere in the month of June... It was about the way to set Error Redirection page from web.config and how SmartNavigation options makes it goes crazy and work around for that... Well Click here if you want to read it...
What I wanted to add on to that tip today was that the settings that you do in the web.config files do not work for any .htm or .asp pages... i.e. If a user requests an .htm or .asp page which is not available then then your setting statuscode="404" redirect="pagenotfound.htm" in the webconfig will not work for that you will have to go within IIS metabase to configure the same.
The other interesting fact here is that if you did a xcopy deployment of your applyication then these settings will have to be manually copied to the deployment web server...:-)
PS: When things don't turn out the way you want them to be try and think "Today is the first day of the rest of my life... Let me start afresh with new determination and vigour..."
Tuesday, October 05, 2004
System.Data.OracleClient not working
This is third time that this question has come up and perhaps it is good to have solution up there at the blog...
Please read down to up...
hi vishal,
Thank you very much for your help. I downloded that dll and it worked by adding reference.
I also found 1 more solution. Similar to microsoft, oracle provides driver as well which is downloadable frm its site. Its abt 80 MB.
Regards,
veeral Oza
--------------------------------------------------------------------------------
From: Vishal Joshi [mailto:Vishal_Joshi@MVPs.org]
Sent: Wednesday, October 06, 2004 7:28 AM
To: Veeral Oza; gangadhara.deepadiah@morganstanley.com; 'Sarang Datye'; sdatye@yahoo.com; scripthappens@hotmail.com
Subject: RE:
Please go manually and add reference to Program Files\Microsoft.NET\OracleClient.Net\System.Data.OracleClient.dll it should work then... If you do not have the same dll on your machine then go to the below location to download and install it on your machine...
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=4F55D429-17DC-45EA-BFB3-076D1C052524
warm regards,
Vishal Joshi
Microsoft MVP .Net
If You Think YOU CAN... You Can...
--------------------------------------------------------------------------------
From: Veeral Oza [mailto:VeeralO@KPITCummins.com]
Sent: Tuesday, October 05, 2004 7:34 AM
To: gangadhara.deepadiah@morganstanley.com; Sarang Datye; sdatye@yahoo.com; vishal_joshi@mvps.org; scripthappens@hotmail.com
Subject:
Hi,
To connect to a oracle 9i database, we have to start with this syntax
Imports System.Data.OracleClient(for VB.Net)
I do hav dotnet framework 1.1 running on my PC, but it still gives me an error
"Namespace or type 'oracleclient' for the Imports
'System.Data.oracleclient' cannot be found."
The connectivity works fine with SQL server.
What might be the reason that I m getting this error?
Regards,
Veeral Oza
Systems Executive
Please read down to up...
hi vishal,
Thank you very much for your help. I downloded that dll and it worked by adding reference.
I also found 1 more solution. Similar to microsoft, oracle provides driver as well which is downloadable frm its site. Its abt 80 MB.
Regards,
veeral Oza
--------------------------------------------------------------------------------
From: Vishal Joshi [mailto:Vishal_Joshi@MVPs.org]
Sent: Wednesday, October 06, 2004 7:28 AM
To: Veeral Oza; gangadhara.deepadiah@morganstanley.com; 'Sarang Datye'; sdatye@yahoo.com; scripthappens@hotmail.com
Subject: RE:
Please go manually and add reference to Program Files\Microsoft.NET\OracleClient.Net\System.Data.OracleClient.dll it should work then... If you do not have the same dll on your machine then go to the below location to download and install it on your machine...
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=4F55D429-17DC-45EA-BFB3-076D1C052524
warm regards,
Vishal Joshi
Microsoft MVP .Net
If You Think YOU CAN... You Can...
--------------------------------------------------------------------------------
From: Veeral Oza [mailto:VeeralO@KPITCummins.com]
Sent: Tuesday, October 05, 2004 7:34 AM
To: gangadhara.deepadiah@morganstanley.com; Sarang Datye; sdatye@yahoo.com; vishal_joshi@mvps.org; scripthappens@hotmail.com
Subject:
Hi,
To connect to a oracle 9i database, we have to start with this syntax
Imports System.Data.OracleClient(for VB.Net)
I do hav dotnet framework 1.1 running on my PC, but it still gives me an error
"Namespace or type 'oracleclient' for the Imports
'System.Data.oracleclient' cannot be found."
The connectivity works fine with SQL server.
What might be the reason that I m getting this error?
Regards,
Veeral Oza
Systems Executive
VJs Tip Of The Day - October 5th 2004
Cache.Insert Method & Call Back function
System.Web.Cache has a Insert method where by you can insert values inside the cache. This method has various overloads and what is worth knowing about one of its overload is the Callback function it provides... You can provide your own callback function here which will be triggered when a the item you just inserted is removed from the cache. This callback function gives you the key of the item removed, the item itself as well as the reason why it was removed. The reason is given back as an enum which can be either dependency changed, expired, removed or underused...
You can use this callback function to write your custom logic on what you would want to do when the item gets removed. for e.g. To retrieve this item from where ever is a CPU intensive job, you do not want it to be done at runtime... Then within this call back function you can spawn another thread to restore this item into cache...
Alternatively if the item was dependant on a file and file change was the reason it got removed you can do you alternate processing... You can also do a logging of cache item removal by anyone in the application by using this callback...
In short this is a useful callback function and you should look upon the options...
Refer the link for further information: Click Here
PS: A friend of mine (Deepa C) sends a good morning mail every morning... She has some amazing information and my favorite Calvin & Hobbes cartoon strip in the mail every time, today she wrote a notable information which I thought I should share with you folks... "The slogan on New Hampshire license plates is 'Live Free or Die'. These license plates are manufactured by prisoners in the state prison in Concord." (for non-US readers - Vehicle plates in most of the states of US carry a slogan representing the state)
System.Web.Cache has a Insert method where by you can insert values inside the cache. This method has various overloads and what is worth knowing about one of its overload is the Callback function it provides... You can provide your own callback function here which will be triggered when a the item you just inserted is removed from the cache. This callback function gives you the key of the item removed, the item itself as well as the reason why it was removed. The reason is given back as an enum which can be either dependency changed, expired, removed or underused...
You can use this callback function to write your custom logic on what you would want to do when the item gets removed. for e.g. To retrieve this item from where ever is a CPU intensive job, you do not want it to be done at runtime... Then within this call back function you can spawn another thread to restore this item into cache...
Alternatively if the item was dependant on a file and file change was the reason it got removed you can do you alternate processing... You can also do a logging of cache item removal by anyone in the application by using this callback...
In short this is a useful callback function and you should look upon the options...
Refer the link for further information: Click Here
PS: A friend of mine (Deepa C) sends a good morning mail every morning... She has some amazing information and my favorite Calvin & Hobbes cartoon strip in the mail every time, today she wrote a notable information which I thought I should share with you folks... "The slogan on New Hampshire license plates is 'Live Free or Die'. These license plates are manufactured by prisoners in the state prison in Concord." (for non-US readers - Vehicle plates in most of the states of US carry a slogan representing the state)
Monday, October 04, 2004
VJs Tip Of The Day - October 4th 2004
Assembly.GetCallingAssembly() Method
GetCallingAssembly() is a static method of Assembly class. You can use this method within your class libraries to find out which assembly has actually made a call to your current assembly.
This method can be really useful in case you are doing Logging or tracing functionalities as you often would like to register who was the caller to your assembly. As GetCallingAssembly method returns an assembly to get a simple string format of the full name would be something like:
Assembly.GetCallingAssembly().FullName.ToString()
PS: I have started following a new little practice... Just before I go to sleep while lying in the bed, I spend just two-three minutes to talk to myself about how would I want my tomorrow to be... What can I do with given resources that would make it an ideal day, what are the tasks that I gotta do, what are ones which are out of scope... I do requirements gathering and project planning for my "Project Tomorrow" in these two-three minutes... Believe me its working well... Interesting enough it makes me wonder what good requirements gathering and project planning would do to software projects... :-)
GetCallingAssembly() is a static method of Assembly class. You can use this method within your class libraries to find out which assembly has actually made a call to your current assembly.
This method can be really useful in case you are doing Logging or tracing functionalities as you often would like to register who was the caller to your assembly. As GetCallingAssembly method returns an assembly to get a simple string format of the full name would be something like:
Assembly.GetCallingAssembly().FullName.ToString()
PS: I have started following a new little practice... Just before I go to sleep while lying in the bed, I spend just two-three minutes to talk to myself about how would I want my tomorrow to be... What can I do with given resources that would make it an ideal day, what are the tasks that I gotta do, what are ones which are out of scope... I do requirements gathering and project planning for my "Project Tomorrow" in these two-three minutes... Believe me its working well... Interesting enough it makes me wonder what good requirements gathering and project planning would do to software projects... :-)
Friday, October 01, 2004
VJs Tip Of The Day - October 1st 2004
Setting Timeouts for WebServices
If your webservice takes a long time to finish its expected task and you wish to increase the timeout values for your webservices following are few things you should look at:
Make sure that you set the desired timeout for your script. You can do that in your webservice by Server.ScriptTimeout = 2000 * 60 //(your value)
Also do note that the timeout for the proxy consuming the webservice should also be modified and should be made more than that the timeout of your webservice itself.
There is a timeout property created for the proxy class generated by WSDL tool you would have to set this property before you call your web service.
eg MyProxyClass objMyProxy = new MyProxyClass()
objMyProxy.Timeout = 5000 * 60 //(note the value is more than the web
// service timeout)
objMyProxy.MyWebMethod("take your time")
PS: At times I might not be able to reply to all the queries that you post to me... Believe me I keep them unread and will get back to them at the earliest leisure... I apologize for the inconvinience...
If your webservice takes a long time to finish its expected task and you wish to increase the timeout values for your webservices following are few things you should look at:
Make sure that you set the desired timeout for your script. You can do that in your webservice by Server.ScriptTimeout = 2000 * 60 //(your value)
Also do note that the timeout for the proxy consuming the webservice should also be modified and should be made more than that the timeout of your webservice itself.
There is a timeout property created for the proxy class generated by WSDL tool you would have to set this property before you call your web service.
eg MyProxyClass objMyProxy = new MyProxyClass()
objMyProxy.Timeout = 5000 * 60 //(note the value is more than the web
// service timeout)
objMyProxy.MyWebMethod("take your time")
PS: At times I might not be able to reply to all the queries that you post to me... Believe me I keep them unread and will get back to them at the earliest leisure... I apologize for the inconvinience...
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!!
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...
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.CreateInstance
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 http://www.microsoftelearning.com/security/.
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 http://www.microsoftelearning.com/security/. 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.
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 http://www.microsoftelearning.com/security/.
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 http://www.microsoftelearning.com/security/. 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
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..."
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...
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..."
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 {
[DllImport("user32")]
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 ");
Console.WriteLine(hwnd);
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... :-)
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 {
[DllImport("user32")]
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 ");
Console.WriteLine(hwnd);
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"...
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... :-)
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...
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... :-)
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...
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...
Tuesday, August 31, 2004
VJs Tip Of The Day - August 31st 2004
COM Callable Wrapper(CCW) - In simple terms -CCW is the special wrapper created over your .Net classes so that they appear as COM objects to other COM components... If your .Net application needs to be called by other COM components you need to make sure that CCW is created over your .Net classes...
Runtime Callable Wrapper (RCW) - In simple terms - RCW is a special wrapper created over COM components so that they appear as .Net components to other .Net components... If your .Net components call other COM components then you need to make sure that RCW is created over the COM components that your application calls...
PS: I will be shifting to Milwaukee, WI tomorrow... Till I get my new home set up, I might not be having any access to internet so probably would not be able to send in Tips for a while... I apologize in advance for the same and will try to get back to grove ASAP...
Runtime Callable Wrapper (RCW) - In simple terms - RCW is a special wrapper created over COM components so that they appear as .Net components to other .Net components... If your .Net components call other COM components then you need to make sure that RCW is created over the COM components that your application calls...
PS: I will be shifting to Milwaukee, WI tomorrow... Till I get my new home set up, I might not be having any access to internet so probably would not be able to send in Tips for a while... I apologize in advance for the same and will try to get back to grove ASAP...
Monday, August 30, 2004
VJs Tip Of The Day - August 30th 2004
Maintaining State Across ASP.Net Pages - Continued 4
Due to the weekend you might have lost touch... In that case do browse through the previous tips on the blog site... The current mail is in continuation of previous tips...
There is a possibility of InvalidCastException, which may come in case of using properties with Server.Transfer... If you think for a while you can very easily conclude the possible causes...
1.) SecondPage is called from a page other than the FirstPage
2.) SecondPage is directly loaded
3.) SecondPage is called from any other page using response.redirect
In such a scenario do make sure that you catch this exception and ignore it...
PS: You know blogspot has provided search facility for the blogs... So now if you want to search some specific tip in my blog you can use that search facility and you will get the tip right over there... :-)
Due to the weekend you might have lost touch... In that case do browse through the previous tips on the blog site... The current mail is in continuation of previous tips...
There is a possibility of InvalidCastException, which may come in case of using properties with Server.Transfer... If you think for a while you can very easily conclude the possible causes...
1.) SecondPage is called from a page other than the FirstPage
2.) SecondPage is directly loaded
3.) SecondPage is called from any other page using response.redirect
In such a scenario do make sure that you catch this exception and ignore it...
PS: You know blogspot has provided search facility for the blogs... So now if you want to search some specific tip in my blog you can use that search facility and you will get the tip right over there... :-)
Friday, August 27, 2004
VJs Tip Of The Day - August 27th 2004
Maintaining State Across ASP.Net Pages - Continued 3
Yesterday we discussed on NOT having second parameter to be true in Server.Transer() method while transferring data of first page to next page using properties... Visit the previous tips to follow up...
Now the answer to "WHY" not true... Well, I was trying that out yesterday and I got an exception message:
"The View State is invalid for this page and might be corrupted"...
On exploring more I discovered that: It is that "EnableViewStateMac"* property of the page(which we discussed few days back)is set to true by default... If this property is true ASP.Net makes a check to find out if the viewstate was modified or not when the page was posted from the client... Now as in case of Server.Transfer's second parameter being true what happens is that all the form variables (including viewstate) of the first page is preserved and sent to second page... Here due to EnableViewStateMac being true a check is made by ASP.Net but now as you are no more in first page so it is but obvious that this check will fail... And as in case of properties option without setting second parameter of Server.Transfer as true also the values are transferred so you can as well pass it to be false...
As such you can also make "EnableViewStateMac" as false but that would not be a good idea from security perspective...
*MAC stands for Message Authentication Check
PS: You know Sudhakar Sadasivuni, a fellow MVP has helped to get all our MVP blogs at one place at the site http://www.mvpblog.com... I bet you will find loads of information here so do visit it when you find time...
Yesterday we discussed on NOT having second parameter to be true in Server.Transer() method while transferring data of first page to next page using properties... Visit the previous tips to follow up...
Now the answer to "WHY" not true... Well, I was trying that out yesterday and I got an exception message:
"The View State is invalid for this page and might be corrupted"...
On exploring more I discovered that: It is that "EnableViewStateMac"* property of the page(which we discussed few days back)is set to true by default... If this property is true ASP.Net makes a check to find out if the viewstate was modified or not when the page was posted from the client... Now as in case of Server.Transfer's second parameter being true what happens is that all the form variables (including viewstate) of the first page is preserved and sent to second page... Here due to EnableViewStateMac being true a check is made by ASP.Net but now as you are no more in first page so it is but obvious that this check will fail... And as in case of properties option without setting second parameter of Server.Transfer as true also the values are transferred so you can as well pass it to be false...
As such you can also make "EnableViewStateMac" as false but that would not be a good idea from security perspective...
*MAC stands for Message Authentication Check
PS: You know Sudhakar Sadasivuni, a fellow MVP has helped to get all our MVP blogs at one place at the site http://www.mvpblog.com... I bet you will find loads of information here so do visit it when you find time...
Thursday, August 26, 2004
VJs Tip Of The Day - August 26th 2004
Maintaining State Across ASP.Net Pages - Continued 2
Hi Folks,
I apologize for abruptly stopping the tips... I was not having any access to internet for the last few days... I am shifting to Milwaukee, Wisconsin to join in as a .Net System Architect in an MNC... I will remain busy during this transition but will ensure that I do not display this abrupt behavior again... The tips of Aug 23rd, 24th and 25th are up there on my blog site(Click Here) The current tip is in continuation of the previous tips so please do visit the site and catch up before you move ahead...
4.) Using Properties with Server.Transfer: Make your first page in such a way that you expose the required values in next page as properties in the first page... Then use Server.Transfer to go to the next page(keep the second parameter as false here, WHY SO WE WILL TALK TOMORROW)... Now in the next page using context handler you can get all the properties of the first page...
I am not writing the first page code as it is just simply adding values into properties and calling Server.Transfer and I believe you all know how to do that...
CODE SNIPPET
NextPage Code:
if(Context.Handler != null)
{
string strInternalVariableOfNextPage;
FirstPage objFirstPage = new FirstPage();
objFirstPage = (FirstPage)Context.Handler;
//Note that SomeValue is a public property of First Page
strInternalVariableOfNextPage = objFirstPage.SomeValue;
}
PS: I like receiving mails that blast me on not sending the tips... This keeps me motivated so thanks to all those who wrote in those mails...
Hi Folks,
I apologize for abruptly stopping the tips... I was not having any access to internet for the last few days... I am shifting to Milwaukee, Wisconsin to join in as a .Net System Architect in an MNC... I will remain busy during this transition but will ensure that I do not display this abrupt behavior again... The tips of Aug 23rd, 24th and 25th are up there on my blog site(Click Here) The current tip is in continuation of the previous tips so please do visit the site and catch up before you move ahead...
4.) Using Properties with Server.Transfer: Make your first page in such a way that you expose the required values in next page as properties in the first page... Then use Server.Transfer to go to the next page(keep the second parameter as false here, WHY SO WE WILL TALK TOMORROW)... Now in the next page using context handler you can get all the properties of the first page...
I am not writing the first page code as it is just simply adding values into properties and calling Server.Transfer and I believe you all know how to do that...
CODE SNIPPET
NextPage Code:
if(Context.Handler != null)
{
string strInternalVariableOfNextPage;
FirstPage objFirstPage = new FirstPage();
objFirstPage = (FirstPage)Context.Handler;
//Note that SomeValue is a public property of First Page
strInternalVariableOfNextPage = objFirstPage.SomeValue;
}
PS: I like receiving mails that blast me on not sending the tips... This keeps me motivated so thanks to all those who wrote in those mails...
Wednesday, August 25, 2004
VJs Tip Of The Day - August 25th 2004
Maintaining State Across ASP.Net Pages - Continued 1
3.) Using HttpContext/RequestParams with Server.Transfer: We discussed adding to session yesterday, similarly you can add to HttpContext as well and this eliminates the cleaning code required in the next page like the way it is required in Session... There are other advantages too...
If you use Server.Transfer then all your control values are automatically transferred to the next page you do not have to add anything to the context explicitly here rather just access the values in the coming page... The code example will show this more clearly...
If you have certain values other than the above mentioned then you have to do certain special operations to explicitly add them in the first page and retrieve them in the second...
CODE SNIPPET
FirstPage Code:
//These are the special values being added to context
//we will retrieve them in the next page
context.Items.Add("specialVariableName", "specialVariableValue");
//We set the second parameter of Server.Transfer to True this will help
//sending certain values automatically
Server.Transfer("NextPage.aspx", True);
NextPage Code:
string strValueOfFirstPageTextBox;
string strSpeciallyAddedValue;
//Use Request.Params to get values of the standard variables
//which get automatically transferred
strValueOfFirstPageTextBox = Request.Params.Get("firstPageTextBox")
//Use HttpContext to get the values specially added
strSpeciallyAddedValue = context.Items("specialVariableName")
3.) Using HttpContext/RequestParams with Server.Transfer: We discussed adding to session yesterday, similarly you can add to HttpContext as well and this eliminates the cleaning code required in the next page like the way it is required in Session... There are other advantages too...
If you use Server.Transfer then all your control values are automatically transferred to the next page you do not have to add anything to the context explicitly here rather just access the values in the coming page... The code example will show this more clearly...
If you have certain values other than the above mentioned then you have to do certain special operations to explicitly add them in the first page and retrieve them in the second...
CODE SNIPPET
FirstPage Code:
//These are the special values being added to context
//we will retrieve them in the next page
context.Items.Add("specialVariableName", "specialVariableValue");
//We set the second parameter of Server.Transfer to True this will help
//sending certain values automatically
Server.Transfer("NextPage.aspx", True);
NextPage Code:
string strValueOfFirstPageTextBox;
string strSpeciallyAddedValue;
//Use Request.Params to get values of the standard variables
//which get automatically transferred
strValueOfFirstPageTextBox = Request.Params.Get("firstPageTextBox")
//Use HttpContext to get the values specially added
strSpeciallyAddedValue = context.Items("specialVariableName")
Tuesday, August 24, 2004
VJs Tip Of The Day - August 24th 2004
Maintaining State Across ASP.Net Pages
We will talk about two standard methods of maintaining state across ASP.Net pages today... The more sophisticated methods will be discussed from tomorrow onwards...
1) Using QueryString : You can pass values of one page to another page using Query strings... This is an old ASP custom but for security reason not always recomended in ASP.Net
2) Using Session : You can also pass values of one page to another by storing them in session... Use of session is pretty simple and we have discussed that earlier as well (Click Here)... But do understand the fact that Session variables are to store user specific information which is unique to each user and not each page... Also do note that if you forget to clean the session variables in the next page you might land up increasing the session size like anything effecting performance of your application...
We will talk about two standard methods of maintaining state across ASP.Net pages today... The more sophisticated methods will be discussed from tomorrow onwards...
1) Using QueryString : You can pass values of one page to another page using Query strings... This is an old ASP custom but for security reason not always recomended in ASP.Net
2) Using Session : You can also pass values of one page to another by storing them in session... Use of session is pretty simple and we have discussed that earlier as well (Click Here)... But do understand the fact that Session variables are to store user specific information which is unique to each user and not each page... Also do note that if you forget to clean the session variables in the next page you might land up increasing the session size like anything effecting performance of your application...
Monday, August 23, 2004
VJs Tip Of The Day - August 23rd 2004
Steps to Enable Automatic Transactions in .Net
We have discussed all these steps earlier but now we will club them together to see how you go about doing it....
1. Add TransactionAttribute to your class
2. Derieve your class from ServicedComponents class
3. Give strong name to your assembly
4. Register your class for COM+ services using Regsvcs.exe
We have discussed all these steps earlier but now we will club them together to see how you go about doing it....
1. Add TransactionAttribute to your class
2. Derieve your class from ServicedComponents class
3. Give strong name to your assembly
4. Register your class for COM+ services using Regsvcs.exe
Friday, August 20, 2004
VJs Tip Of The Day - August 20th 2004
Transactions in .Net - Using Services of COM+
To use the services of COM+ and transactions you need to register the assembly that contains you class (transactional) with the COM+... You can do so manually by using .Net Services Installation Tool (Regsvcs.exe)... Well if your client is managed client then you do not need to do this registeration as CLR will do it for you but if you know that at sometime your clients can be unmanaged then it is always useful to register your assembly manually...
To use the services of COM+ and transactions you need to register the assembly that contains you class (transactional) with the COM+... You can do so manually by using .Net Services Installation Tool (Regsvcs.exe)... Well if your client is managed client then you do not need to do this registeration as CLR will do it for you but if you know that at sometime your clients can be unmanaged then it is always useful to register your assembly manually...
Thursday, August 19, 2004
VJs Tip Of The Day - August 19th 2004
TransactionOption
We are getting into the details of TransactionOption today...
1. TransactionOption.Disabled implies that automatic transactions cannot control the object... Still if you want this object to support transaction then it can be done by manual transactions...
2. TransactionOption.NotSupported implies that object context will always be created without transaction for this object no matter whether a transaction is already existing...
3. TransactionOption.Supported implies that if transaction exists the object will run under it, if it does not exist it will run without transaction...
4. TransactionOption.Required implies that if transaction exists the object will run under it, if it does not exist a new transaction will be created...
5. TransactionOption.RequiresNew implies that the a new trasaction is started for every request...
PS: Trivandrum User Group in India launches its own site... First bold move by any User Group in India and I bet it is for good... visit
http://www.t-mug.org/membersite.aspx to see for yourself...
We are getting into the details of TransactionOption today...
1. TransactionOption.Disabled implies that automatic transactions cannot control the object... Still if you want this object to support transaction then it can be done by manual transactions...
2. TransactionOption.NotSupported implies that object context will always be created without transaction for this object no matter whether a transaction is already existing...
3. TransactionOption.Supported implies that if transaction exists the object will run under it, if it does not exist it will run without transaction...
4. TransactionOption.Required implies that if transaction exists the object will run under it, if it does not exist a new transaction will be created...
5. TransactionOption.RequiresNew implies that the a new trasaction is started for every request...
PS: Trivandrum User Group in India launches its own site... First bold move by any User Group in India and I bet it is for good... visit
http://www.t-mug.org/membersite.aspx to see for yourself...
Wednesday, August 18, 2004
VJs Tip Of The Day - August 18th 2004
Transaction Attribute for your class
We discussed that for our class to participate in transactions we need to do certain things... Now we will talk about what those certain things have to be...
One of the things that you need to do is to apply Transaction attribute to your class... You would apply it just before your class declaration... It would look something like:
[Transaction(TransactionOption.Supported)]
Now if you are familiar with COM+ transactions then TransactionOption has values which are very similar to COM+ transaction options...
The TransactionOption values can be Disabled, NotSupported, Supported, Required, RequiresNew... Out of these Required is the default...
We discussed that for our class to participate in transactions we need to do certain things... Now we will talk about what those certain things have to be...
One of the things that you need to do is to apply Transaction attribute to your class... You would apply it just before your class declaration... It would look something like:
[Transaction(TransactionOption.Supported)]
Now if you are familiar with COM+ transactions then TransactionOption has values which are very similar to COM+ transaction options...
The TransactionOption values can be Disabled, NotSupported, Supported, Required, RequiresNew... Out of these Required is the default...
Tuesday, August 17, 2004
VJs Tip Of The Day - August 17th 2004
Transactions in .Net
We talked about Transactions in .Net a few days back... We learnt that how they can be automatic or manual...Now ,we will talk about Automatic Transactions this whole week... Hopefully it will be interesting and useful...
Automatic Transaction manages transaction boundaries for you... But again it manages the boundaries on the basis of what you suggest it to do (you do that by attributes which we will talk in a couple of days... ) The transaction flows from one object to other as instructed... Within its scope, it includes, the objects that are suppose to participate in transactions and leaves out the objects that are not suppose to participate...
Note: Nested transactions are not possible in Automatic model...
PS: I sent a document to my team for review... Two days later a friend/collegue wrote to me that I had sent the wrong document... Till now no reviewer other than her has got back (out of 6-7 in the list)... I was wondering about the chances of reviewers not opening the review attachments which someone sends and also chances of them getting mad if the document was never sent, interstingly both the chances are equally bright... :-)
We talked about Transactions in .Net a few days back... We learnt that how they can be automatic or manual...Now ,we will talk about Automatic Transactions this whole week... Hopefully it will be interesting and useful...
Automatic Transaction manages transaction boundaries for you... But again it manages the boundaries on the basis of what you suggest it to do (you do that by attributes which we will talk in a couple of days... ) The transaction flows from one object to other as instructed... Within its scope, it includes, the objects that are suppose to participate in transactions and leaves out the objects that are not suppose to participate...
Note: Nested transactions are not possible in Automatic model...
PS: I sent a document to my team for review... Two days later a friend/collegue wrote to me that I had sent the wrong document... Till now no reviewer other than her has got back (out of 6-7 in the list)... I was wondering about the chances of reviewers not opening the review attachments which someone sends and also chances of them getting mad if the document was never sent, interstingly both the chances are equally bright... :-)
Monday, August 16, 2004
VJs Tip Of The Day - August 16th 2004
Design Days: Caching and Performance
Usually we assume that Caching is done to improve performance, well it is true but at the same time it may deteriorate the performance as well... It many a times depends on the Cache Hit Ratio... And you should definitely consider your Cache Hit Ratio [CHR] before considering your caching strategy...
To make it more clear consider a scenario in which you cache the state list of a country... Now if user has to select one of the available states then there are bright chances that your cache hit is a success.... It might be a good idea to cache the list instead of retrieving it from the data source all the time...
Now consider that you cache product list for a store like Walmart... You might have millions of product in the database and it is very unlikely that the product selection will lie in the correct category and type... There are more likely chances of miss than of hit, but you will lose time in searching the cache, so here is when you should consider hitting the data source instead of caching...
Now there are options other than caching and there might be other factors governing the decisions, this is just a design suggestion...
PS: 15th August was India's Independence Day... Please accept my belated wishes for a Happy Independence Day... Jai Hind... (Hail India!!)
Usually we assume that Caching is done to improve performance, well it is true but at the same time it may deteriorate the performance as well... It many a times depends on the Cache Hit Ratio... And you should definitely consider your Cache Hit Ratio [CHR] before considering your caching strategy...
To make it more clear consider a scenario in which you cache the state list of a country... Now if user has to select one of the available states then there are bright chances that your cache hit is a success.... It might be a good idea to cache the list instead of retrieving it from the data source all the time...
Now consider that you cache product list for a store like Walmart... You might have millions of product in the database and it is very unlikely that the product selection will lie in the correct category and type... There are more likely chances of miss than of hit, but you will lose time in searching the cache, so here is when you should consider hitting the data source instead of caching...
Now there are options other than caching and there might be other factors governing the decisions, this is just a design suggestion...
PS: 15th August was India's Independence Day... Please accept my belated wishes for a Happy Independence Day... Jai Hind... (Hail India!!)
Friday, August 13, 2004
VJs Tip Of The Day - August 13th 2004
If you want to use the services provided by COM+ in your .Net then you write Serviced Components...
To write serviced components you will have to include the namespace of System.EnterpriseServices... You will also have to inherit you class from ServicedComponent
PS: For My Records(FMR) - I am travelling to Omaha, NE to celebrate my friends Birthday...
To write serviced components you will have to include the namespace of System.EnterpriseServices... You will also have to inherit you class from ServicedComponent
PS: For My Records(FMR) - I am travelling to Omaha, NE to celebrate my friends Birthday...
Wednesday, August 11, 2004
VJs Tip Of The Day - August 12th 2004
ViewState Encryption- Considerations
Well to add to yesterday's tip, there are few more tips, rather considerations to come on the way related to viewstate encryption...
If you are using SSL for your webpages then you would want to reconsider whether you need this encryption of ViewState seperately or not as your whole data will be encrypted anyways...
The other point is webfarm scenario... When deploying your webapp to Webfarm without sticky sessions if AutoGenerate option is on (which is by default) then there are chances that your each request will go to different machine and ViewState decryption will fail there... You will have to do synchronization activities in this scenario...
Note: Sticky session is a scenario in which, once the first request in a session is served by a particular server all the consecutive requests for that session will be directed to the same server...
PS: I was wondering that if someone reads one useful article from MSDN daily, (note: JUST ONE useful article) how many days would it take for him/her to become "Most Knowledgeable Person" around there... Think about this, I smile when I come up with a number out of my hat... :-)
Well to add to yesterday's tip, there are few more tips, rather considerations to come on the way related to viewstate encryption...
If you are using SSL for your webpages then you would want to reconsider whether you need this encryption of ViewState seperately or not as your whole data will be encrypted anyways...
The other point is webfarm scenario... When deploying your webapp to Webfarm without sticky sessions if AutoGenerate option is on (which is by default) then there are chances that your each request will go to different machine and ViewState decryption will fail there... You will have to do synchronization activities in this scenario...
Note: Sticky session is a scenario in which, once the first request in a session is served by a particular server all the consecutive requests for that session will be directed to the same server...
PS: I was wondering that if someone reads one useful article from MSDN daily, (note: JUST ONE useful article) how many days would it take for him/her to become "Most Knowledgeable Person" around there... Think about this, I smile when I come up with a number out of my hat... :-)
Tuesday, August 10, 2004
VJs Tip Of The Day - August 11th 2004
Encrypting View State
Few days back we talked about ViewState being Base64 Encoded and that it moves back and forth from client to server... Now if you wish to encrypt the ViewState for security reasons then below is the way to achieve the same...
You have to change your web.config file... In the system.web section of the web.config file you need to add the below tags
<pages enableViewStateMAC="true"/>
<machineKey validation="3DES"/>
PS: Note that here validation="3DES" causes the encryption... enableViewStateMAC causes the check that ViewState is not actually tampered...
Few days back we talked about ViewState being Base64 Encoded and that it moves back and forth from client to server... Now if you wish to encrypt the ViewState for security reasons then below is the way to achieve the same...
You have to change your web.config file... In the system.web section of the web.config file you need to add the below tags
<pages enableViewStateMAC="true"/>
<machineKey validation="3DES"/>
PS: Note that here validation="3DES" causes the encryption... enableViewStateMAC causes the check that ViewState is not actually tampered...
VJs Tip Of The Day - August 10th 2004
Processing Transactions in .Net
.Net components do support transactions, the only thing is that you have to do some extra work to achieve the same... .Net framework supports two kind of transactions models
1.) Manual Transactions
2.) Automatic Transactions
Manual Tranactions is used in case of ADO.Net, message queuing etc... Automatic Transactions are available for ASP.Net, Web Services, .Net Components etc... .Net classes can also use the services of COM+ but they need to be registered with COM+ for doing so... We will talk more about Transactions in .Net in time to come...
PS: Is it a good idea to send in some code snippets in Tips?? If so do let me know, I do not want the tips to be cumbersome to read...
.Net components do support transactions, the only thing is that you have to do some extra work to achieve the same... .Net framework supports two kind of transactions models
1.) Manual Transactions
2.) Automatic Transactions
Manual Tranactions is used in case of ADO.Net, message queuing etc... Automatic Transactions are available for ASP.Net, Web Services, .Net Components etc... .Net classes can also use the services of COM+ but they need to be registered with COM+ for doing so... We will talk more about Transactions in .Net in time to come...
PS: Is it a good idea to send in some code snippets in Tips?? If so do let me know, I do not want the tips to be cumbersome to read...
Monday, August 09, 2004
VJs Tip Of The Day - August 9th 2004
Changing Reference to different version of external assembly
Consider a scenario when your application is referencing version 1.0.1.1 of "SomeAssembly" in GAC... Now you realize that there are some major bugs in that assembly and you want your assembly to reference the new version of the assembly (say 1.0.2.0) and you do not want to go ahead and recompile your code for that... What would you do... Well here is the answer... You would go and change the configuration file with similar updates to the ones I am writing below...
<configuration>
<runtime>
<assemblybinding xmlns="urn:schemas-microsoft-com:asmv1">
<publisherpolicy apply="no">
<dependantassembly>
<assemblyidentity publickeytoken="whatever" name="SomeAssembly">
<publisherpolicy apply="no">
<bindingredirect newversion="1.0.2.0" oldversion="1.0.1.1">
</dependantassembly>
</assemblybinding>
</runtime>
</configuration>
PS: You can achieve the same with different methods as well this is just one of them
Consider a scenario when your application is referencing version 1.0.1.1 of "SomeAssembly" in GAC... Now you realize that there are some major bugs in that assembly and you want your assembly to reference the new version of the assembly (say 1.0.2.0) and you do not want to go ahead and recompile your code for that... What would you do... Well here is the answer... You would go and change the configuration file with similar updates to the ones I am writing below...
<configuration>
<runtime>
<assemblybinding xmlns="urn:schemas-microsoft-com:asmv1">
<publisherpolicy apply="no">
<dependantassembly>
<assemblyidentity publickeytoken="whatever" name="SomeAssembly">
<publisherpolicy apply="no">
<bindingredirect newversion="1.0.2.0" oldversion="1.0.1.1">
</dependantassembly>
</assemblybinding>
</runtime>
</configuration>
PS: You can achieve the same with different methods as well this is just one of them
Friday, August 06, 2004
VJs Tip Of The Day - August 6th 2004
Common Type System - Value Types vs Reference Types
Value Types and Reference Types are two basic types of CTS... Value Types are allocated on the stack and Reference Types are allocated on Managed heap... How this thing works is that the value of the "Value Types" is allocated on the stack where as in case of "Reference Types" the value i.e. the object itself resides in the heap but there is a pointer to the object in the memory...
Considering this differences value types are faster but consume the process memory....
"Reference types don't consume this process memory but then they become slower... When value types are copied then the value is copied as a whole on the stack, when reference types are copied then only the references are copied on the stack..., when to use Reference Types as compared to Value Types and visa-versa is based on various other factors also so do take time to decide when to use what..."
Value types are usually native data types like int, float, char, enums etc... Reference types mostly include string, classes and some other user defined types...
PS: I wrote Value types to be allocated on heap in my second paragraph only Kathleen was able to find that out... You guys do write back when you see such gross errors... Thanks Kathleen...
Value Types and Reference Types are two basic types of CTS... Value Types are allocated on the stack and Reference Types are allocated on Managed heap... How this thing works is that the value of the "Value Types" is allocated on the stack where as in case of "Reference Types" the value i.e. the object itself resides in the heap but there is a pointer to the object in the memory...
Considering this differences value types are faster but consume the process memory....
"Reference types don't consume this process memory but then they become slower... When value types are copied then the value is copied as a whole on the stack, when reference types are copied then only the references are copied on the stack..., when to use Reference Types as compared to Value Types and visa-versa is based on various other factors also so do take time to decide when to use what..."
Value types are usually native data types like int, float, char, enums etc... Reference types mostly include string, classes and some other user defined types...
PS: I wrote Value types to be allocated on heap in my second paragraph only Kathleen was able to find that out... You guys do write back when you see such gross errors... Thanks Kathleen...
Thursday, August 05, 2004
VJs Tip Of The Day - August 5th 2004
Design Days: View State Performance Tips
In controls like listbox controls, items added to the list are carried between client and server via view state... When the list of items become considerably large it starts hitting the performance and increasing the traffic between client and server... To avoid this set the EnableViewState property of the control to be false... By this unnecessary data will not move back and forth to the server... Though, do note that by doing so your selected items will no longer remain selected after postback and you will have to write special code to achieve this functionality...
The same problems are also faced in controls like Datagrid so do ensure that you use View State judiciously and give enough thoughts while designing your application...
To see the view state of a page right click on displayed page and 'view source', here you will see a long line of junk characters for __VIEWSTATE property... This is the encrypted view state of your controls... Well, that makes me add one more point the performance... All the viewstate data that passes to and comes back from server goes through the cycles of encryption and decryption which in itself is also a costly affair hitting performance...
Note: Ben Miller from Microsoft corrected my silly mistake here... view state is Base64 encoded when it moves back and forth from client to server.... It is not encrypted... Thanks for the correction Ben... Btw, Ben Miller is also ASP.Net MVP Lead of North America... !!
PS: Did you read my suggestion to Microsoft long time back... You will like it... Click Here
In controls like listbox controls, items added to the list are carried between client and server via view state... When the list of items become considerably large it starts hitting the performance and increasing the traffic between client and server... To avoid this set the EnableViewState property of the control to be false... By this unnecessary data will not move back and forth to the server... Though, do note that by doing so your selected items will no longer remain selected after postback and you will have to write special code to achieve this functionality...
The same problems are also faced in controls like Datagrid so do ensure that you use View State judiciously and give enough thoughts while designing your application...
To see the view state of a page right click on displayed page and 'view source', here you will see a long line of junk characters for __VIEWSTATE property... This is the encrypted view state of your controls... Well, that makes me add one more point the performance... All the viewstate data that passes to and comes back from server goes through the cycles of encryption and decryption which in itself is also a costly affair hitting performance...
Note: Ben Miller from Microsoft corrected my silly mistake here... view state is Base64 encoded when it moves back and forth from client to server.... It is not encrypted... Thanks for the correction Ben... Btw, Ben Miller is also ASP.Net MVP Lead of North America... !!
PS: Did you read my suggestion to Microsoft long time back... You will like it... Click Here
Wednesday, August 04, 2004
VJs Tip Of The Day - August 4th 2004
Assemblies Details Introduction
•Assembly has a four part name that uniquely identifies it – Name, Version, Culture & develope
•Version – Major.Minor.Build.Revision
•Culture – Satellite Assemblies contain culture info attribute that indicates the spoken language and country-code
•Public Keys – Used to uniquely identify the developer of a component and provide protection from getting tampered by external sources
using System.Reflection;
[assembly: AssemblyVersion(“1.2.3.4”)]
[assembly: AssemblyCulture(“en-US”)]
[assembly: AssemblyKeyFile(“mykey.snk”)]
PS: Naveeth Krishnan from Trivandrum .Net User Group has suggested me to start writing more about Assemblies so this is the beginning... We will deviate once in a while so that none of us get bored but still we will touch more about Assemblies now...
PPS: Did you read my suggestion to Microsoft long time back... You will like it.. Click Here
•Assembly has a four part name that uniquely identifies it – Name, Version, Culture & develope
•Version – Major.Minor.Build.Revision
•Culture – Satellite Assemblies contain culture info attribute that indicates the spoken language and country-code
•Public Keys – Used to uniquely identify the developer of a component and provide protection from getting tampered by external sources
using System.Reflection;
[assembly: AssemblyVersion(“1.2.3.4”)]
[assembly: AssemblyCulture(“en-US”)]
[assembly: AssemblyKeyFile(“mykey.snk”)]
PS: Naveeth Krishnan from Trivandrum .Net User Group has suggested me to start writing more about Assemblies so this is the beginning... We will deviate once in a while so that none of us get bored but still we will touch more about Assemblies now...
PPS: Did you read my suggestion to Microsoft long time back... You will like it.. Click Here
Tuesday, August 03, 2004
VJs Tip Of The Day - August 3rd 2004
Design Days - Data Access Ways
This is just a small little thought, which I thought, can be shared... When we try to access data from a table in DataSet many a times we have to use the name of the columns... We have multiple Datagrids bound to each table and many other controls of your page also access data from these tables... Now, just in case your column name changes in the table you would want to have minimum impact on the stuff that you have to change...
As a solution to this you can have DataDefinition class... This class can just return back the name of the columns as properties, you can define these light weight classes if you have less number of tables to be accessed... In any case if you do not follow this approach then it is always advisable to have constants declared at a common location and store your column names in there....
You can later use either these constants or light weight classes to get the column names...
PS: Do note that by introducing such things you can make your design more maintainable but sometimes loose on performance... Take decisions on the basis of what is ideal for your situation... Don't sue a poor fella like me for suggesting, you anyways won't get much... :-)
Kathleen Dollard, Microsoft MVP adds the below:
Use enums. Much faster and far more maintainable....
This is just a small little thought, which I thought, can be shared... When we try to access data from a table in DataSet many a times we have to use the name of the columns... We have multiple Datagrids bound to each table and many other controls of your page also access data from these tables... Now, just in case your column name changes in the table you would want to have minimum impact on the stuff that you have to change...
As a solution to this you can have DataDefinition class... This class can just return back the name of the columns as properties, you can define these light weight classes if you have less number of tables to be accessed... In any case if you do not follow this approach then it is always advisable to have constants declared at a common location and store your column names in there....
You can later use either these constants or light weight classes to get the column names...
PS: Do note that by introducing such things you can make your design more maintainable but sometimes loose on performance... Take decisions on the basis of what is ideal for your situation... Don't sue a poor fella like me for suggesting, you anyways won't get much... :-)
Kathleen Dollard, Microsoft MVP adds the below:
Use enums. Much faster and far more maintainable....
Monday, August 02, 2004
VJs Tip Of The Day - August 2nd 2004
A design consideration to access Web.Config
If you are going to access Web.config file for various configuration settings of yours e.g. ConnectionString.... Then sometimes it would be a good idea to develop a class specially to access configuration settings, something like a ConfigManager... what this class can inturn do is to access Web.Config file in its constructor to retrieve your configuration settings and fill up private variables and in turn expose them as properties...
The advantage of having this approach is that if you decide to change your source for these settings then you do not have to go to every page and change the way you access the settings you just change your class... Other than this there can be potential situations in which you might decide to encrypt some values in your web.config file later... This security enhancement would otherwise cause all your pages accessing this information change... During such situations it would be ideal to have a class like this...
To add icing to the cake you can make required member variables static so that the class's instance need not be created everytime... Also do try to make sure that every call to your property should not need to query web.config file to access values or else they may degrade performance...
PS: This is a design tip, it may not be perfect design for all situations these are just some of my generic thoughts, if you have anything to dispute please feel free to drop me an email
Binu from Trivendrum User Group has added the below thoughts...
There is one more advantage to this. if you want to deploy the application in different environments (developer sand box/ integration/ QA / production) it would be easy to have this App.Config . The possibility of using different encryption keys / SQL server in different environments is pretty high in real scenario and with the number of builds we deploy before pushing to production corroborates this.
-- Binu
If you are going to access Web.config file for various configuration settings of yours e.g. ConnectionString.... Then sometimes it would be a good idea to develop a class specially to access configuration settings, something like a ConfigManager... what this class can inturn do is to access Web.Config file in its constructor to retrieve your configuration settings and fill up private variables and in turn expose them as properties...
The advantage of having this approach is that if you decide to change your source for these settings then you do not have to go to every page and change the way you access the settings you just change your class... Other than this there can be potential situations in which you might decide to encrypt some values in your web.config file later... This security enhancement would otherwise cause all your pages accessing this information change... During such situations it would be ideal to have a class like this...
To add icing to the cake you can make required member variables static so that the class's instance need not be created everytime... Also do try to make sure that every call to your property should not need to query web.config file to access values or else they may degrade performance...
PS: This is a design tip, it may not be perfect design for all situations these are just some of my generic thoughts, if you have anything to dispute please feel free to drop me an email
Binu from Trivendrum User Group has added the below thoughts...
There is one more advantage to this. if you want to deploy the application in different environments (developer sand box/ integration/ QA / production) it would be easy to have this App.Config . The possibility of using different encryption keys / SQL server in different environments is pretty high in real scenario and with the number of builds we deploy before pushing to production corroborates this.
-- Binu
Friday, July 30, 2004
VJs Tip Of The Day - July 30th 2004
Global Asssembly Cache (GAC) & CLR
When your assembly is ready to go to GAC (implies you need to do some steps like strong name generation etc, before it can... :-) ) you can use Gacutil.exe provided by .Net Framework SDK to install your assembly into GAC...
Alternatively you can just drag and drop an assembly in "WINNT\ASSEMBLY" folder in your windows explorer; The CLR does run the Gacutil in the back-ground and so your assembly gets intstalled in the GAC...
PS: The weekend has nearly started so pardon this silly tip... Remember our mass movement: "No working on weekends... Do what you enjoy!!"... Btw, If you find me in office on weekends don't feel I am breaching the contract rather assume that: I enjoy work... :-)
When your assembly is ready to go to GAC (implies you need to do some steps like strong name generation etc, before it can... :-) ) you can use Gacutil.exe provided by .Net Framework SDK to install your assembly into GAC...
Alternatively you can just drag and drop an assembly in "WINNT\ASSEMBLY" folder in your windows explorer; The CLR does run the Gacutil in the back-ground and so your assembly gets intstalled in the GAC...
PS: The weekend has nearly started so pardon this silly tip... Remember our mass movement: "No working on weekends... Do what you enjoy!!"... Btw, If you find me in office on weekends don't feel I am breaching the contract rather assume that: I enjoy work... :-)
Thursday, July 29, 2004
VJs Tip Of The Day - July 29th 2004
Fragment Caching
Fragment caching is a technique to cache only partial part of the page... This technique is used to improve performance of your page, but it needs to be decided at design time...
You can achieve Fragment caching by developing a part of your web page as User Control... User Control can then cache itself independant of the page... User Controls provides many more benefits other than Fragment Caching so while going for User Controls there are other factors to be considered...
Fragment caching is a technique to cache only partial part of the page... This technique is used to improve performance of your page, but it needs to be decided at design time...
You can achieve Fragment caching by developing a part of your web page as User Control... User Control can then cache itself independant of the page... User Controls provides many more benefits other than Fragment Caching so while going for User Controls there are other factors to be considered...
Wednesday, July 28, 2004
VJs Tip Of The Day - July 28th 2004
ASP.Net Server Controls Categories
ASP.Net Server Control can be broadly classified into 4 categories...
ASP.Net Server Control can be broadly classified into 4 categories...
- Intrinsic Controls -These controls correspond to their HTML counterpart... eg Textbox control, Button control
- Data-Centric Controls - These controls are used for data display, binding, modification purposes... They bind to various data sources... eg. DataGrid control
- RichControls - Usually do not have HTML counterparts... These are usually composite controls which in themselves contain other controls... eg. Calendar control
- Validation Controls - As the name suggest they are used for validation purposes and can validate many type of user inputs.... eg. RegularExpressionValidator
Tuesday, July 27, 2004
VJs Tip Of The Day - July 27th 2004
SQL Server Session State Does It Again
Well did you wonder yesterday, that if your session data was stored in permanent tables on SQL server and there would be "n" number of sessions running for your application all the time how much data would get collected in the SQL Server???
So, there has to be a mechanism to clean this data every once in a while right!!... And ofcourse there is... When SQL Server support for session gets installed a job to delete the expired session is also installed, this job runs every minute and is called ASPState_Job_DeleteExpiredSessions...; It requires SQLServerAgent service to be running in order to work...
PS: To visit earlier tips click on the right side "Archives" menu of the blog site...
Well did you wonder yesterday, that if your session data was stored in permanent tables on SQL server and there would be "n" number of sessions running for your application all the time how much data would get collected in the SQL Server???
So, there has to be a mechanism to clean this data every once in a while right!!... And ofcourse there is... When SQL Server support for session gets installed a job to delete the expired session is also installed, this job runs every minute and is called ASPState_Job_DeleteExpiredSessions...; It requires SQLServerAgent service to be running in order to work...
PS: To visit earlier tips click on the right side "Archives" menu of the blog site...
Monday, July 26, 2004
VJs Tip Of The Day - July 26th 2004
Again Session State
Well this time we will get into little details... ASP.Net provides two pair of SQL scripts to create/delete the SQLServer Session DB... The first pair of script creates TempDB where ASP.Net session state is stored, but as the name specifies this DB will loose its value if SQL server is re-started...the script are named InstallSqlState.sql and UninstallSqlState.sql...
If you wish to keep your session data even more secure, you would do so by running the other pair of scripts... These scripts create permanent tables on SQL Server... These scripts are called InstallPersistSqlState.sql and UninstallPersistSqlState.sql...
All the above mentioned scripts are located in the same folder as the session state NT service...
Well this time we will get into little details... ASP.Net provides two pair of SQL scripts to create/delete the SQLServer Session DB... The first pair of script creates TempDB where ASP.Net session state is stored, but as the name specifies this DB will loose its value if SQL server is re-started...the script are named InstallSqlState.sql and UninstallSqlState.sql...
If you wish to keep your session data even more secure, you would do so by running the other pair of scripts... These scripts create permanent tables on SQL Server... These scripts are called InstallPersistSqlState.sql and UninstallPersistSqlState.sql...
All the above mentioned scripts are located in the same folder as the session state NT service...
Sunday, July 25, 2004
Friday, July 23, 2004
VJs Tip Of The Day - July 23rd 2004
mode="SQLServer" for sessionState
When you choose your sessionState to be SQLServer, ASP.Net uses the default DB and initial catalogs for storing your session information into SQLServer... That is the reason you are not allowed to pass tokens such as Database and Initial Catalog in the connection string... Finally your entry in the web.config file will look like
<configuration>
<system.web>
<sessionState
mode="SQLServer"
sqlConnectionString="server=127.0.0.1;uid=<user id>pwd<password>" />
</system.web>
</configuration>
user id and password can be replaced by integrated security settings...
When you choose your sessionState to be SQLServer, ASP.Net uses the default DB and initial catalogs for storing your session information into SQLServer... That is the reason you are not allowed to pass tokens such as Database and Initial Catalog in the connection string... Finally your entry in the web.config file will look like
<configuration>
<system.web>
<sessionState
mode="SQLServer"
sqlConnectionString="server=127.0.0.1;uid=<user id>pwd<password>" />
</system.web>
</configuration>
user id and password can be replaced by integrated security settings...
Thursday, July 22, 2004
VJs Tip Of The Day - July 22nd 2004
Session State in ASP.Net
ASP.Net supports three different providers for Session State... They are:
InProc - Session values are kept live in the memory of ASP.Net worker process
StateServer - Session values are serialized to store in the memory of a seperate proces i.e. aspnet_state.exe
SQLServer - Session values are stored on SQL Server...
You can read more about operational information and performance of session variables at
http://vishaljoshi.blogspot.com/2003_10_01_vishaljoshi_archive.html
ASP.Net supports three different providers for Session State... They are:
InProc - Session values are kept live in the memory of ASP.Net worker process
StateServer - Session values are serialized to store in the memory of a seperate proces i.e. aspnet_state.exe
SQLServer - Session values are stored on SQL Server...
You can read more about operational information and performance of session variables at
http://vishaljoshi.blogspot.com/2003_10_01_vishaljoshi_archive.html
Wednesday, July 21, 2004
VJs Tip Of The Day - July 21th 2004
Performance with static variables as compared to Application variables
Sometimes if you want to share a value of a type across pages then it is sensible to use static variables instead of Application variable... The advantages from performance perspective by taking this approach are:
Storing and reading a value can be many times faster with static variables as they do not require to lookup into application variables collection when you refer to them...
You also do not need to cast from object to a specific type, as you need to do with Application variables, but you need to make sure that you declare the static variable of same type as the object that needs to be stored... By this you can also avoid the overhead casting, boxing and unboxing...
Sometimes if you want to share a value of a type across pages then it is sensible to use static variables instead of Application variable... The advantages from performance perspective by taking this approach are:
Storing and reading a value can be many times faster with static variables as they do not require to lookup into application variables collection when you refer to them...
You also do not need to cast from object to a specific type, as you need to do with Application variables, but you need to make sure that you declare the static variable of same type as the object that needs to be stored... By this you can also avoid the overhead casting, boxing and unboxing...
Monday, July 19, 2004
VJs Tip Of The Day - July 20th 2004
HttpResponse.RemoveOutputCacheItem
It is possible to forcibly remove a page from output cache... You can do so by a static method called HttpResponse.RemoveOutputCacheItem("Page path")...
If you are running on a web farm environment then you would have to call this method on each server as cache is not shared across servers...
It is possible to forcibly remove a page from output cache... You can do so by a static method called HttpResponse.RemoveOutputCacheItem("Page path")...
If you are running on a web farm environment then you would have to call this method on each server as cache is not shared across servers...
VJs Tip Of The Day - July 19th 2004
DataReader Object
ADO.Net objects are broadly divided into two sections:
Connected Objects
Disconnected Objects
The DataReader is one of the connected objects of ADO.Net... It helps you examine the rows that are fetched by your query, one at a time... It discards every row after you have gone through it and so it is extreamly fast...
It also contains read-only data, so no updates are allowed using DataReader objects...
ADO.Net objects are broadly divided into two sections:
Connected Objects
Disconnected Objects
The DataReader is one of the connected objects of ADO.Net... It helps you examine the rows that are fetched by your query, one at a time... It discards every row after you have gone through it and so it is extreamly fast...
It also contains read-only data, so no updates are allowed using DataReader objects...
Friday, July 16, 2004
VJs Tip Of The Day - July 16th 2004
Const vs readonly in C#
const (Constants) are variables whose values are set at compile time, either by the programmer or by the compiler... It cannot be modified there after, so if you need a field whose value is known at compile time and should not be changed anytime later then you should declare that field as const... Intersting note is that const fields are statis by default and so you do not need to instantiate a class to access them...
readonly (Read Only) are variables whose values are set at run time, but only once... The value of such variables are set in the constructors and cannot be modified there on... These variables are useful when you want the value of the variable to be fixed but fixed to a value which is known only at run time...
Now if you need a static variable whose value is known only at runtime then make it static readonly... :-)
Sudhir from TCS wanted to add the tip above below is his note:
Hi Vishal a little addition in yr Tip What is the difference between CONST and READONLY? Both are meant for constant values. A const field can only be initialized at the declaration of the field. A readonly field can be initialized either at the declaration or in a constructor. Therefore, readonly fields can have different values depending on the constructor used. readonly int b; public X() { b=1; } public X(string s) { b=5; } public X(string s, int i) { b=i; } Also, while a const field is a compile-time constant, the readonly field can be used for runtime constants
const (Constants) are variables whose values are set at compile time, either by the programmer or by the compiler... It cannot be modified there after, so if you need a field whose value is known at compile time and should not be changed anytime later then you should declare that field as const... Intersting note is that const fields are statis by default and so you do not need to instantiate a class to access them...
readonly (Read Only) are variables whose values are set at run time, but only once... The value of such variables are set in the constructors and cannot be modified there on... These variables are useful when you want the value of the variable to be fixed but fixed to a value which is known only at run time...
Now if you need a static variable whose value is known only at runtime then make it static readonly... :-)
Sudhir from TCS wanted to add the tip above below is his note:
Hi Vishal a little addition in yr Tip What is the difference between CONST and READONLY? Both are meant for constant values. A const field can only be initialized at the declaration of the field. A readonly field can be initialized either at the declaration or in a constructor. Therefore, readonly fields can have different values depending on the constructor used. readonly int b; public X() { b=1; } public X(string s) { b=5; } public X(string s, int i) { b=i; } Also, while a const field is a compile-time constant, the readonly field can be used for runtime constants
Thursday, July 15, 2004
VJs Tip Of The Day - July 15th 2004
MemberwiseClone Method Contd...
Well I got a couple of posts yesterday that if MemberwiseClone method does Shallow Copy, is there anything like Deep Copy... Well these are just terms, if you want the copy of the object also to have copy of all the object it references then we can say that its Deep Copy and to achieve Deep Copy we must implement ICloneable interface in our objects and do manual cloning... :-)
Well I got a couple of posts yesterday that if MemberwiseClone method does Shallow Copy, is there anything like Deep Copy... Well these are just terms, if you want the copy of the object also to have copy of all the object it references then we can say that its Deep Copy and to achieve Deep Copy we must implement ICloneable interface in our objects and do manual cloning... :-)
Wednesday, July 14, 2004
VJs Tip Of The Day - July 14th 2004
MemberwiseClone Method
MemberwiseClone Method is a protected method of the object class which all the types in .Net inherit (everthing inherits from Object!!)... This method returns an object and basically does a Shallow Copy of the object, i.e. copy of the object does not contain the copy of the objects it refrences....
MemberwiseClone Method is a protected method of the object class which all the types in .Net inherit (everthing inherits from Object!!)... This method returns an object and basically does a Shallow Copy of the object, i.e. copy of the object does not contain the copy of the objects it refrences....
Tuesday, July 13, 2004
VJs Tip Of The Day - July 13th 2004
Lazy Initialization
Lazy Initialization is an optimizing technique whereby some of a class's members are not initalized until they are needed...
This is in particular useful when you have class that contains members that are not used often and whose initalization might consume a lot of resources... Some examples would be accessing File System or network objects or databases...
Well you would be doing this already, now you know the technical term for it... :-)
Lazy Initialization is an optimizing technique whereby some of a class's members are not initalized until they are needed...
This is in particular useful when you have class that contains members that are not used often and whose initalization might consume a lot of resources... Some examples would be accessing File System or network objects or databases...
Well you would be doing this already, now you know the technical term for it... :-)
Monday, July 12, 2004
VJs Tip Of The Day - July 12th 2004
Code Pitching and EconoJITer
EconoJITer is one the three kindof JIT compilers available in .Net... It discards compiled code out of the memory to release some space when system is running on low memory...
EconoJIT compilation is the option which should be chosen when there is scarcity of memory like in case of small handheld devices like Pocket PC, PDA etc...
The process of releasing memory by discarding the already compiled code (from MSIL) is called as Code Pitching
EconoJITer is one the three kindof JIT compilers available in .Net... It discards compiled code out of the memory to release some space when system is running on low memory...
EconoJIT compilation is the option which should be chosen when there is scarcity of memory like in case of small handheld devices like Pocket PC, PDA etc...
The process of releasing memory by discarding the already compiled code (from MSIL) is called as Code Pitching
Friday, July 09, 2004
VJs Tip Of The Day - July 9th 2004
HelpProvider Class
HelpProvider Class in Windows form has a method SetHelpString()... This method will associate a string that you provide with the control specified... This help will be shown when the user presses F1 while the control has focus...
Example
Private objhelpProvider As System.Windows.Forms.HelpProvider
Me.objhelpProvider.SetHelpString(Me.txtZipCode, "Just enter the first 5 digits for Zip code, this applies to US only...")
Me.objhelpProvider.SetShowHelp(Me.txtZipCode, True)
HelpProvider Class in Windows form has a method SetHelpString()... This method will associate a string that you provide with the control specified... This help will be shown when the user presses F1 while the control has focus...
Example
Private objhelpProvider As System.Windows.Forms.HelpProvider
Me.objhelpProvider.SetHelpString(Me.txtZipCode, "Just enter the first 5 digits for Zip code, this applies to US only...")
Me.objhelpProvider.SetShowHelp(Me.txtZipCode, True)
Thursday, July 08, 2004
VJs Tip Of The Day - July 8th 2004
Application Domains Basics
Inter process communication is always painful... The memory pointer in one process many a times does not make a lot of sense in the other process... To tackle this problem and many others Application Domains are introduced in .Net... There can be more than one Application Domain running under the same process... Application Domain provides nearly equivalent level of isolation as would a separate process and at the same time saves the hits of cross-process communications... By having high isolation you can prevent failure of one application to affect other application...
Note: There is lot more to application domains and its a very interesting topic, do give it some time of yours it will be worthwhile..
Inter process communication is always painful... The memory pointer in one process many a times does not make a lot of sense in the other process... To tackle this problem and many others Application Domains are introduced in .Net... There can be more than one Application Domain running under the same process... Application Domain provides nearly equivalent level of isolation as would a separate process and at the same time saves the hits of cross-process communications... By having high isolation you can prevent failure of one application to affect other application...
Note: There is lot more to application domains and its a very interesting topic, do give it some time of yours it will be worthwhile..
Wednesday, July 07, 2004
VJs Tip Of The Day - July 7th 2004
DataGrid.ItemDataBound Event
The ItemDataBound event is raised after an item is data bound to the DataGrid control... This event provides you with the last opportunity to access the data item before it is displayed on the client. After this event is raised, the data item is nulled or no longer available...
You would land up using this event if you are making changes to the display of your data grid... Read more about the event and sample code in MSDN...
The ItemDataBound event is raised after an item is data bound to the DataGrid control... This event provides you with the last opportunity to access the data item before it is displayed on the client. After this event is raised, the data item is nulled or no longer available...
You would land up using this event if you are making changes to the display of your data grid... Read more about the event and sample code in MSDN...
Tuesday, July 06, 2004
VJs Tip Of The Day - July 6th 2004
To utilize the Add/Remove Programs feature in Control Panel, you must add a key to
the Registry under
HKEY_LOCAL_MACHINES\Software\Microsoft\Windows\CurrentVersion\Uninstall\UniqueName
where UniqueName will be any Unique name that you can use for your program identification
Note: Goto Start->Run = "Regedit" and browse to the location to see for yourself...
the Registry under
HKEY_LOCAL_MACHINES\Software\Microsoft\Windows\CurrentVersion\Uninstall\UniqueName
where UniqueName will be any Unique name that you can use for your program identification
Note: Goto Start->Run = "Regedit" and browse to the location to see for yourself...
Friday, July 02, 2004
VJs Tip Of The Day - July 2nd 2004
<pages> tag in web.config
<pages> element is located at the below defined position in web.config
<configuration>
<system.web>
<pages>
It contains a attribute called enableSessionState which specifies whether session state is enabled or not.
It can take following three values:
true - Indicates that session state is enabled.
false - Indicates that session state is not enabled.
ReadOnly - Specifies that an application can read but cannot modify session state variables.
<pages> element is located at the below defined position in web.config
<configuration>
<system.web>
<pages>
It contains a attribute called enableSessionState which specifies whether session state is enabled or not.
It can take following three values:
true - Indicates that session state is enabled.
false - Indicates that session state is not enabled.
ReadOnly - Specifies that an application can read but cannot modify session state variables.
Thursday, July 01, 2004
VJs Tip Of The Day - July 1st 2004
Split Functions in .Net
There are multiple Split functions available in .NET...
U can use System.String.Split if you need to split a string based on a collection
of specific characters. Each individual character is its own delimiter. Here there are chances of getting white spaces when you would not expect them to come...
Use System.Text.RegularExpressions.RegEx.Split to split based on some specific formats... You can use this in case the earlier one does not work for you...
At the end if you remember the good old days you can reference the Microsoft.VisualBasic assembly in your program and can use the Strings.Split function to split a string based on a word... The favorite way of VB6 programmer... :-)
There are multiple Split functions available in .NET...
U can use System.String.Split if you need to split a string based on a collection
of specific characters. Each individual character is its own delimiter. Here there are chances of getting white spaces when you would not expect them to come...
Use System.Text.RegularExpressions.RegEx.Split to split based on some specific formats... You can use this in case the earlier one does not work for you...
At the end if you remember the good old days you can reference the Microsoft.VisualBasic assembly in your program and can use the Strings.Split function to split a string based on a word... The favorite way of VB6 programmer... :-)
Just for my records -MCP ASP.Net
Today I used the free coupon, which all MVPs got last year to appear MCP exam... Microsoft wanted their MVPs to be certified... So I fulfilled their wish...
Became MCP in ASP.Net... :-)
PS: Wonder what's the use of the certifications, when such things never ever effect my pay package...
Became MCP in ASP.Net... :-)
PS: Wonder what's the use of the certifications, when such things never ever effect my pay package...
Wednesday, June 30, 2004
VJs Tip Of The Day - June 30th 2004
Installer for Globalization
If you have different versions of your web application built for different languages and you have seperate resource files for each language when you need to deploy your application according to the language settings of the server then in that case make an Installer that has Custom Action to install only location-specific files...
If you have different versions of your web application built for different languages and you have seperate resource files for each language when you need to deploy your application according to the language settings of the server then in that case make an Installer that has Custom Action to install only location-specific files...
Tuesday, June 29, 2004
VJs Tip Of The Day - June 29th 2004
allowOverride Attribute
If you have a common server where you are going to host your website and you do not want anyone to override your configuration settings after the site is deployed then within your web.config file, use <location> tag and set allowOverride attribute to false....
If you have a common server where you are going to host your website and you do not want anyone to override your configuration settings after the site is deployed then within your web.config file, use <location> tag and set allowOverride attribute to false....
Monday, June 28, 2004
VJs Tip Of The Day - June 28th 2004
Virtual/Abstract members of a class
Virtual or Abstract members of a class cannot be private... Well just think, if you make them private why would you make them virtual or abstract anyways...:-)
PS: This tip is suffering from "Case of Monday" syndrome... :-)
Virtual or Abstract members of a class cannot be private... Well just think, if you make them private why would you make them virtual or abstract anyways...:-)
PS: This tip is suffering from "Case of Monday" syndrome... :-)
Friday, June 25, 2004
VJs Tip Of The Day - June 25th 2004
Interface vs Abstract classes
For Abstract class one method of the class must have an abstract method that means, it may have concrete methods...
Various access modifiers such as abstract, protected, internal, public, virtual, overrides etc are not useful in case of Interface but they are in case of Abstract classes
Class implementing Interface has to implement all the methods of the Interface, this is not required in case of Abstract classes
Interfacescannot have constructors and destructors like the way Abstract classes can...
Interface cannot contain a static method whereas an Abstract class can have...
There are few more points which I can recollect but I think that this is enough for a tip... If anyone needs more info do write back to me... :-)
* pure virtual method is a method which has just definition but not implementation...
PS: Many of us work on weekends, I don't think (current thought!!) that its a good practice doing that, atleast if you are being guaged on the basis of your willingness to work on weekends then its surely very bad... I am trying to start a movememt to abolish this social evil of working on weekends, so no tips on weekends...:-)
BONUS TIP: Spend time with your family this weekend... :-)
For Abstract class one method of the class must have an abstract method that means, it may have concrete methods...
Various access modifiers such as abstract, protected, internal, public, virtual, overrides etc are not useful in case of Interface but they are in case of Abstract classes
Class implementing Interface has to implement all the methods of the Interface, this is not required in case of Abstract classes
Interfacescannot have constructors and destructors like the way Abstract classes can...
Interface cannot contain a static method whereas an Abstract class can have...
There are few more points which I can recollect but I think that this is enough for a tip... If anyone needs more info do write back to me... :-)
* pure virtual method is a method which has just definition but not implementation...
PS: Many of us work on weekends, I don't think (current thought!!) that its a good practice doing that, atleast if you are being guaged on the basis of your willingness to work on weekends then its surely very bad... I am trying to start a movememt to abolish this social evil of working on weekends, so no tips on weekends...:-)
BONUS TIP: Spend time with your family this weekend... :-)
Thursday, June 24, 2004
VJs Tip Of The Day - June 24th 2004
Call to Static Methods
You cannot call static method of a class using the object of the class*... You would have to call it using the Class name itself..
eg.You cannot call base class's static method using base.StaticMethod(); that shall result into an error...
the way you do it is:
//Class having Static Method
public class MyClass
{
public static string StaticMethod()
{
return "Vishal_Joshi@MVPs.org";
}
}
//Class using Static Method
public class ClientClass
{
public string GetHelpLineEmailId()
{
return MyClass.StaticMethod();
}
}
* This is applicable only to C# in case of VB.Net you can access static methods even using the object of the class... (This is what happens to a C# fan.... Thanks to Jacob Cynamon, MS and Kathleen Dollard, MVP for reminding... )
You cannot call static method of a class using the object of the class*... You would have to call it using the Class name itself..
eg.You cannot call base class's static method using base.StaticMethod(); that shall result into an error...
the way you do it is:
//Class having Static Method
public class MyClass
{
public static string StaticMethod()
{
return "Vishal_Joshi@MVPs.org";
}
}
//Class using Static Method
public class ClientClass
{
public string GetHelpLineEmailId()
{
return MyClass.StaticMethod();
}
}
* This is applicable only to C# in case of VB.Net you can access static methods even using the object of the class... (This is what happens to a C# fan.... Thanks to Jacob Cynamon, MS and Kathleen Dollard, MVP for reminding... )
Wednesday, June 23, 2004
VJs Tip Of The Day - June 23rd 2004
Static Members of a class
A static member of a class can be accessed without creating an instance of the class... Everyone knows this right!! so what next...??
A static member cannot be marked as abstract or virtual, trying to do so will result into an error...
Inside a static member you cannot call any non-static member, trying to do so will also result in an error...
A static member of a class can be accessed without creating an instance of the class... Everyone knows this right!! so what next...??
A static member cannot be marked as abstract or virtual, trying to do so will result into an error...
Inside a static member you cannot call any non-static member, trying to do so will also result in an error...
Tuesday, June 22, 2004
VJs Tip Of The Day - June 22nd 2004
@Page directive
@Page directive of ASP.Net Page in visual studio accepts only fully qualified name for "Inherits" attribute whereas giving just the required cs file name for "Codebehind" attribute is good enough...
eg < %@ Page language="c#" Codebehind="UnExpectedError.aspx.cs" AutoEventWireup="false" Inherits="SubtleEye.Administration.UnExpectedError" % >
@Page directive of ASP.Net Page in visual studio accepts only fully qualified name for "Inherits" attribute whereas giving just the required cs file name for "Codebehind" attribute is good enough...
eg < %@ Page language="c#" Codebehind="UnExpectedError.aspx.cs" AutoEventWireup="false" Inherits="SubtleEye.Administration.UnExpectedError" % >
Monday, June 21, 2004
VJs Tip Of The Day - June 21st 2004
Redirecting to Default Error Html in case of Error
You might have many errors handled in your application but still there would be few of them always left out, so what's the solution??... Well here it is... Go and do the setting in the web.config file of your web application...
< customErrors defaultRedirect="UrProblemUnknownError.htm" mode="RemoteOnly" >
< error statusCode="404" redirect = "MyProblemServerNotFound.htm"/>
< /customErrors >
Now interesting fact is in conjunction to our previous tip on "SmartNavigation"... In case of pages for which you allow SmartNavigation the defaultRedirect does not work and Microsoft has confirmed it to be a bug... At the same time there is a work around...
Change your page directive a little bit when you use "SmartNavigation" as follows
< %@Page Language="C#" smartNavigation="True" ErrorPage="UrProblemUnknownError.htm" %>
The ErrorPage here will help you in that scenario... Don't ask me why so, You should not ask embarrassing questions... :-)
PS: I celebrate Mother's day today as it's my mom's birthday today... Happy Mother's Day!!
You might have many errors handled in your application but still there would be few of them always left out, so what's the solution??... Well here it is... Go and do the setting in the web.config file of your web application...
< customErrors defaultRedirect="UrProblemUnknownError.htm" mode="RemoteOnly" >
< error statusCode="404" redirect = "MyProblemServerNotFound.htm"/>
< /customErrors >
Now interesting fact is in conjunction to our previous tip on "SmartNavigation"... In case of pages for which you allow SmartNavigation the defaultRedirect does not work and Microsoft has confirmed it to be a bug... At the same time there is a work around...
Change your page directive a little bit when you use "SmartNavigation" as follows
< %@Page Language="C#" smartNavigation="True" ErrorPage="UrProblemUnknownError.htm" %>
The ErrorPage here will help you in that scenario... Don't ask me why so, You should not ask embarrassing questions... :-)
PS: I celebrate Mother's day today as it's my mom's birthday today... Happy Mother's Day!!
Thursday, June 17, 2004
VJs Tip Of The Day - June 17th 2004
Smart Navigation
"SmartNavigation" is a boolean property which can be set in the page's code behind or in the @page directive... This property is really helpful in case you want to enhance user experience... Set this property to true and you will get following advantages in navigation if your browser is IE 5.5 and above...
1.) Maintaining the scroll bar position (useful in long length pages)
2.) Set focus to the same control on which it was before navigation (useful in pages with lots of controls)
3.) saving last page state in the browser history (useful when a page does not changes considerably across frequent postbacks... eg chaning control values on change of dates in calendar control)
4.) The flash effect caused during navigation (useful when your page is pretty heavy to load)
"SmartNavigation" is a boolean property which can be set in the page's code behind or in the @page directive... This property is really helpful in case you want to enhance user experience... Set this property to true and you will get following advantages in navigation if your browser is IE 5.5 and above...
1.) Maintaining the scroll bar position (useful in long length pages)
2.) Set focus to the same control on which it was before navigation (useful in pages with lots of controls)
3.) saving last page state in the browser history (useful when a page does not changes considerably across frequent postbacks... eg chaning control values on change of dates in calendar control)
4.) The flash effect caused during navigation (useful when your page is pretty heavy to load)
Wednesday, June 16, 2004
VJs Tip Of The Day - June 16th 2004
Our Simple Response.Redirect method
Whenever Response.Redirect line is executed the browser gets a HTTP staus code of 302 from the server indicating it to GET/POST again to the new URL provided... This means that the page does one more round trip to the server with different URL... Most of the browser use GET request to comply with HTTP standards and if they use POST then they would have to prompt the user for permission... In anycase there is a performance hit of posting twice... Most of the cases it is not visible to the user...
If you are very high on performance then use Server.Transfer instead... Also note that your form variables are not available in the next page in case of Response.Redirect; in case of Server.Transfer the data submitted by the user is preserved...
Well I think this is long enough for a tip, so rest of the info I will include in a small article...
Whenever Response.Redirect line is executed the browser gets a HTTP staus code of 302 from the server indicating it to GET/POST again to the new URL provided... This means that the page does one more round trip to the server with different URL... Most of the browser use GET request to comply with HTTP standards and if they use POST then they would have to prompt the user for permission... In anycase there is a performance hit of posting twice... Most of the cases it is not visible to the user...
If you are very high on performance then use Server.Transfer instead... Also note that your form variables are not available in the next page in case of Response.Redirect; in case of Server.Transfer the data submitted by the user is preserved...
Well I think this is long enough for a tip, so rest of the info I will include in a small article...
Tuesday, June 15, 2004
VJs Tip Of The Day - June 15th 2004
AlternateText Property
"AlternateText" property in the Image control is for narrator to read when a disabled person is trying to access the page via Narrator... Remember this when you are trying to develop an application for disabled people as well...
"AlternateText" property in the Image control is for narrator to read when a disabled person is trying to access the page via Narrator... Remember this when you are trying to develop an application for disabled people as well...
Thursday, May 27, 2004
Difference between Application Variables and Session Variables
-----Original Message-----
From: Vishal Joshi
Sent: Thursday, May 27, 2004 1:54 PM
To: Rakesh Ambudkar
Subject: RE: What does this mean
I presume that there are 2 types of variables in the discussion below:
Session
Application
Application variables are the variables which remain common for the whole application… Their value can be used across the whole application… And they die only when the application stops or probably when they are killed forcibily… The ideal example for these kindof variables are site counter… We can find out how many people accessed a particular site since the time it went live via application variables and incrementing the same on ever session start..
Session variables are variables which remain common for the whole application but for one particular user. They also can be used across the whole application… But they die when a particular user session ends or probably when they are killed forcibily… The ideal example for this kindof variable are user id… You might want to show "Welcome Vishal" on every page of your site till vishal logs off… So in session start you set a variable to "Welcome Vishal" and kill it on session end…
All these methods like session start, session end, application start, application end are found in global.asax and that’s the reason global.asax is one for the whole ASP.Net application…
I hope this provides you with the info that you needed…
Warm regards,
Vishal Joshi
Ph#: +1-309-763-2242.
If You Think YOU CAN.. You Can...
-----Original Message-----
From: Rakesh Ambudkar
Sent: Thursday, May 27, 2004 12:57 PM
To: Vishal Joshi
Subject: What does this mean
If you use objects with Application scope ,you should be aware that ASP.NET process request concurrently and the applicationobject can be accessed by multiple threads. Therefore following is dagerous and may not produce the desired result ,if the page is repeatedly requested by different clients at the same time.
Thanks
____________________________
Rakesh Ambudkar
From: Vishal Joshi
Sent: Thursday, May 27, 2004 1:54 PM
To: Rakesh Ambudkar
Subject: RE: What does this mean
I presume that there are 2 types of variables in the discussion below:
Session
Application
Application variables are the variables which remain common for the whole application… Their value can be used across the whole application… And they die only when the application stops or probably when they are killed forcibily… The ideal example for these kindof variables are site counter… We can find out how many people accessed a particular site since the time it went live via application variables and incrementing the same on ever session start..
Session variables are variables which remain common for the whole application but for one particular user. They also can be used across the whole application… But they die when a particular user session ends or probably when they are killed forcibily… The ideal example for this kindof variable are user id… You might want to show "Welcome Vishal" on every page of your site till vishal logs off… So in session start you set a variable to "Welcome Vishal" and kill it on session end…
All these methods like session start, session end, application start, application end are found in global.asax and that’s the reason global.asax is one for the whole ASP.Net application…
I hope this provides you with the info that you needed…
Warm regards,
Vishal Joshi
Ph#: +1-309-763-2242.
If You Think YOU CAN.. You Can...
-----Original Message-----
From: Rakesh Ambudkar
Sent: Thursday, May 27, 2004 12:57 PM
To: Vishal Joshi
Subject: What does this mean
If you use objects with Application scope ,you should be aware that ASP.NET process request concurrently and the applicationobject can be accessed by multiple threads. Therefore following is dagerous and may not produce the desired result ,if the page is repeatedly requested by different clients at the same time.
Thanks
____________________________
Rakesh Ambudkar
Friday, April 30, 2004
Ever Thought of Triggering an IMS Transaction from MSMQ Message in VB
Well wondering how I am writing anything else than .Net... Btw, I also work on Asynchrounous Architecture a lot nowdays and thats another area which I have started liking other than .Net...
To tell you the truth we have figured out a way of triggering IMS Transaction by sending a MSMQ Message from VB6, if this gets you interested, drop me an email at Vishal_Joshi@MVPs.org and I shall write to you back about it... Meanwhile I am intending to compile a nice KB article on that...
To tell you the truth we have figured out a way of triggering IMS Transaction by sending a MSMQ Message from VB6, if this gets you interested, drop me an email at Vishal_Joshi@MVPs.org and I shall write to you back about it... Meanwhile I am intending to compile a nice KB article on that...
Wednesday, April 28, 2004
10 THINGS "YOU SHOULD KNOW" WHEN UPGRADING TO VS.Net 2003 & .NET FRAMEWORK V1.1
The answer to the below question might be something which would probably hit the bull's eye.. :-)
What promts me to write a column on this topic ?
A friend of mine has a big web application built in Visual Studio .Net 2002... Needless to say after a long a difficult process they finish their round of testing and launch their application to production... Now the enterprise decides to upgrade their software and get Visual Studio .Net 2003, which as appearing everywhere is better in all the perspective than VS.Net 2002... Well, accepted but now here we have a healthy running project, relatively large one, already in production we do not want to fiddle around with it... But the service team of this application get their new machines with VS.Net 2003 installed and here is where the problem starts... And here are the considerations that I would like to put forward for folks who are in similar situations...
10 THINGS "YOU SHOULD KNOW" WHEN UPGRADING TO VS.Net 2003 & .NET FRAMEWORK V1.1
1.) You should know that Visual Studio .Net 2002 targets .Net Framework Version 1.0
2.) You should know that Visual Studio .Net 2003 targets .Net Framework Version 1.1... Framework Version 1.1 has lots of enhancements over 1.0 so definitely the change is for good...
3.) You should know that if you open an application created in VS.Net 2002 in VS.Net 2003, it will prompt for the conversion or if application is recompiled in VS.Net 2003 it will start targetting .Net Framework 1.1...
4.) You should know that if you do not recompile application will continue targetting .Net Framework 1.0, but then if you are servicing the application made in VS.Net 2002, you expect it to change in some way right!!... And if you change it to recompile, :-) refer point 3.)
5.)You should know that sometimes its big deal about targetting .Net Framework Version 1.1 for applications which were built in 1.0... well, its a big deal sometimes coz there are changes in the latest Framework version as compared to earlier... Many of the method signatures are obselete now and just to catch your attention few of them are listed below...
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataCommonDbDataAdapterClassICloneableCloneTopic.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataOleDbOleDbPermissionClassctorTopic1.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataSqlClientSqlClientPermissionClassctorTopic1.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWebUIObjectConverterClassctorTopic.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatacommondataadapterclasscloneinternalstopic.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemnetipaddressclassaddresstopic.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWebUIObjectConverterClassConvertValueTopic.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataOdbcOdbcPermissionClassctorTopic1.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWebServicesProtocolsSoapHeaderAttributeClassRequiredTopic.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemxmlxslxsltransformclassloadtopic7.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemxmlxslxsltransformclasstransformtopic1.asp
Now what about the applications which have been using the stuff that's obselete now... Think whether you want to use the latest version and upgrade your code or use old version and live as you are living...
6.) You should know that if you use VS.Net 2003 to open your project once and save it, it cannot be reopened in VS.Net 2002... Well ofcourse no one should expect back-ward compatibility, but you should be aware of certain things before hand right!!
7.) You should also know that both the .Net Framework versions can run side by side and you can configure which application targets which Framework version... If you think I should write a column on that configuration and way to do it then drop me a mail at Vishal_Joshi@MVPs.org
8.) You should also know that both Visual Studio .Net 2002 and Visual Studio .Net 2003 can exist side by side on the same machine as well... Even Whidbey can still co-exist with those two... But mind you don't try it... I tried doing all those things and some supernatural powers made all my applications stop working, finally I did what a frustrated developer does, i.e. uninstall everything and install only VS.Net 2002 with .Net Framework 1.0... Well this is just Vishal Joshi, I did everything possible and nothing worked out, you may try might be you do it right!!
9.) You should know that if .Net Framework V1.1 is installed on your machine ASP.Net and Web Services will automatically target .Net Framework V1.1 unless otherwise configured... A gentleman called Denis Bauer developed a utility called ASP.Net Version switcher, which is available free for download... This utility is really useful at times to switch the Framework version your ASP.Net application is targetting and if you need to get it Click Here... Well you can do this configuration manually as well but aren't we moving towards automation :-)
10.) You should know that rest of the applications made in any Version will run with the version they were made to target, unless they are configured otherwise... As mentioned earlier applications built to taget V1.1 will not work on V1.0 (disclaimer: unless otherwise designed & configured)
Feel free to write in your comments to me at Vishal_Joshi@MVPs.org... I am ready to make the title "More than 10 Things you should know when upgrading to VS.Net 2003 and .Net Framework V1.1"
Should I copyright this??? Just kidding!!
What promts me to write a column on this topic ?
A friend of mine has a big web application built in Visual Studio .Net 2002... Needless to say after a long a difficult process they finish their round of testing and launch their application to production... Now the enterprise decides to upgrade their software and get Visual Studio .Net 2003, which as appearing everywhere is better in all the perspective than VS.Net 2002... Well, accepted but now here we have a healthy running project, relatively large one, already in production we do not want to fiddle around with it... But the service team of this application get their new machines with VS.Net 2003 installed and here is where the problem starts... And here are the considerations that I would like to put forward for folks who are in similar situations...
10 THINGS "YOU SHOULD KNOW" WHEN UPGRADING TO VS.Net 2003 & .NET FRAMEWORK V1.1
1.) You should know that Visual Studio .Net 2002 targets .Net Framework Version 1.0
2.) You should know that Visual Studio .Net 2003 targets .Net Framework Version 1.1... Framework Version 1.1 has lots of enhancements over 1.0 so definitely the change is for good...
3.) You should know that if you open an application created in VS.Net 2002 in VS.Net 2003, it will prompt for the conversion or if application is recompiled in VS.Net 2003 it will start targetting .Net Framework 1.1...
4.) You should know that if you do not recompile application will continue targetting .Net Framework 1.0, but then if you are servicing the application made in VS.Net 2002, you expect it to change in some way right!!... And if you change it to recompile, :-) refer point 3.)
5.)You should know that sometimes its big deal about targetting .Net Framework Version 1.1 for applications which were built in 1.0... well, its a big deal sometimes coz there are changes in the latest Framework version as compared to earlier... Many of the method signatures are obselete now and just to catch your attention few of them are listed below...
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataCommonDbDataAdapterClassICloneableCloneTopic.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataOleDbOleDbPermissionClassctorTopic1.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataSqlClientSqlClientPermissionClassctorTopic1.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWebUIObjectConverterClassctorTopic.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatacommondataadapterclasscloneinternalstopic.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemnetipaddressclassaddresstopic.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWebUIObjectConverterClassConvertValueTopic.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataOdbcOdbcPermissionClassctorTopic1.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWebServicesProtocolsSoapHeaderAttributeClassRequiredTopic.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemxmlxslxsltransformclassloadtopic7.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemxmlxslxsltransformclasstransformtopic1.asp
Now what about the applications which have been using the stuff that's obselete now... Think whether you want to use the latest version and upgrade your code or use old version and live as you are living...
6.) You should know that if you use VS.Net 2003 to open your project once and save it, it cannot be reopened in VS.Net 2002... Well ofcourse no one should expect back-ward compatibility, but you should be aware of certain things before hand right!!
7.) You should also know that both the .Net Framework versions can run side by side and you can configure which application targets which Framework version... If you think I should write a column on that configuration and way to do it then drop me a mail at Vishal_Joshi@MVPs.org
8.) You should also know that both Visual Studio .Net 2002 and Visual Studio .Net 2003 can exist side by side on the same machine as well... Even Whidbey can still co-exist with those two... But mind you don't try it... I tried doing all those things and some supernatural powers made all my applications stop working, finally I did what a frustrated developer does, i.e. uninstall everything and install only VS.Net 2002 with .Net Framework 1.0... Well this is just Vishal Joshi, I did everything possible and nothing worked out, you may try might be you do it right!!
9.) You should know that if .Net Framework V1.1 is installed on your machine ASP.Net and Web Services will automatically target .Net Framework V1.1 unless otherwise configured... A gentleman called Denis Bauer developed a utility called ASP.Net Version switcher, which is available free for download... This utility is really useful at times to switch the Framework version your ASP.Net application is targetting and if you need to get it Click Here... Well you can do this configuration manually as well but aren't we moving towards automation :-)
10.) You should know that rest of the applications made in any Version will run with the version they were made to target, unless they are configured otherwise... As mentioned earlier applications built to taget V1.1 will not work on V1.0 (disclaimer: unless otherwise designed & configured)
Feel free to write in your comments to me at Vishal_Joshi@MVPs.org... I am ready to make the title "More than 10 Things you should know when upgrading to VS.Net 2003 and .Net Framework V1.1"
Should I copyright this??? Just kidding!!
Wednesday, April 14, 2004
Creating COM Callable Wrapper (CCW)
Query on using .Net components in VB6
-----Original Message-----
From: Anup Ganji
Sent: Wednesday, April 14, 2004 10:05 AM
To: Vishal Joshi
Subject: Help Required!!
Hi Vishal!
I request for a small help from you, for which I would be talking some time of your's.
A friend of mine is facing a problem in accessing a dot net (C#) coded component in VB6.0, I heard that if could come up with a wrapper around the dot net coded component you can access it from lower versions.
Waiting for more inputs from you.
Thanks,
Anup
A Quick Solution
-----Original Message-----
From: Vishal Joshi
Sent: Wednesday, April 14, 2004 10:33 AM
To: Anup Ganji
Subject: RE: Help Required!!
Hi Anup,
It is very true that by making minor changes to C# component it can be made visible to com components… There are certain attributes and steps that we need to follow for this…. These attribute informs the CLR to generate CCW(Com Callable Wrapper) which creates the Interface by which VB6 components can call C# components…
Its been long time since I wrote such component but the basic steps should be as follows…
In you C# component use using System.Runtime.InteropServices;
Now we need to create a interface with the same name as your .Net class only with "_" in the beginning… Precisely speaking in this interface you will write only those methods which have to be exposed out of your .Net component
Eg
using System.Runtime.InteropServices;
using System;
namespace SameAsClassesNamespace
{
[Guid("use GUIDGen.exe to create GUID for urself")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface _MyNetComponent
{
//ur method signatures will come here
}
}
Remember the attribute InterfaceType is important here as it tells which kindof ComInterface is required…
Now in your class following are the modifications to be made…
using System.Runtime.InteropServices;
using System;
namespace SameAsClassesNamespace
{
[Guid("use GUIDGen.exe to create GUID for urself")]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("SameAsClassesNamespace.MyNetComponent")]
public class MyNetComponent : _MyNetComponent
{
//ur method definition will come here
}
}
Now go to project properties --> Configuration Properties and set last two properties (Register for Com Interop & Create Debug information) to true… Well this can be done manually but no big reason to go about doing it… {Find out more about Regasm.exe, sn.exe, gacutil.exe if you are interested in doing it manually, but better don't…}
Now as you compile your component should be visible to COM… And ofcourse you know the ProgId above to use your component...
Enjoy!!
Warm regards,
Vishal Joshi
Ph#: +1-309-763-2242.
If You Think YOU CAN.. You Can...
-----Original Message-----
From: Anup Ganji
Sent: Wednesday, April 14, 2004 10:05 AM
To: Vishal Joshi
Subject: Help Required!!
Hi Vishal!
I request for a small help from you, for which I would be talking some time of your's.
A friend of mine is facing a problem in accessing a dot net (C#) coded component in VB6.0, I heard that if could come up with a wrapper around the dot net coded component you can access it from lower versions.
Waiting for more inputs from you.
Thanks,
Anup
A Quick Solution
-----Original Message-----
From: Vishal Joshi
Sent: Wednesday, April 14, 2004 10:33 AM
To: Anup Ganji
Subject: RE: Help Required!!
Hi Anup,
It is very true that by making minor changes to C# component it can be made visible to com components… There are certain attributes and steps that we need to follow for this…. These attribute informs the CLR to generate CCW(Com Callable Wrapper) which creates the Interface by which VB6 components can call C# components…
Its been long time since I wrote such component but the basic steps should be as follows…
In you C# component use using System.Runtime.InteropServices;
Now we need to create a interface with the same name as your .Net class only with "_" in the beginning… Precisely speaking in this interface you will write only those methods which have to be exposed out of your .Net component
Eg
using System.Runtime.InteropServices;
using System;
namespace SameAsClassesNamespace
{
[Guid("use GUIDGen.exe to create GUID for urself")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface _MyNetComponent
{
//ur method signatures will come here
}
}
Remember the attribute InterfaceType is important here as it tells which kindof ComInterface is required…
Now in your class following are the modifications to be made…
using System.Runtime.InteropServices;
using System;
namespace SameAsClassesNamespace
{
[Guid("use GUIDGen.exe to create GUID for urself")]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("SameAsClassesNamespace.MyNetComponent")]
public class MyNetComponent : _MyNetComponent
{
//ur method definition will come here
}
}
Now go to project properties --> Configuration Properties and set last two properties (Register for Com Interop & Create Debug information) to true… Well this can be done manually but no big reason to go about doing it… {Find out more about Regasm.exe, sn.exe, gacutil.exe if you are interested in doing it manually, but better don't…}
Now as you compile your component should be visible to COM… And ofcourse you know the ProgId above to use your component...
Enjoy!!
Warm regards,
Vishal Joshi
Ph#: +1-309-763-2242.
If You Think YOU CAN.. You Can...
Thursday, April 08, 2004
A Quick Tip on long length URLs
You must have faced problems about line wraps when you send a really long URL... Well, might be many of you know this but just FYI...
When a URL is pretty long and you need to send it in an email or paste in in a word doc, all you need to do is to put a start the url with "<" and end with ">"... Everything included within these operators will be considered as a single URL...
When a URL is pretty long and you need to send it in an email or paste in in a word doc, all you need to do is to put a start the url with "<" and end with ">"... Everything included within these operators will be considered as a single URL...
Monday, April 05, 2004
MVP Global Summit 2004 - A Melting Pot
MVP Global summit going on from 3rd April 2004 to 7th April 2004 is truely a melting pot of different thoughts and same passion - Microsoft Technologies...
Just in two days I have met people from more than 20 different countries and all of them were such amazing guys/gals...
I am just coming after attending a session by Don Box and Chris Anderson, and there are no words to express how you feel listing technology from the guys who make it...
I am overwhelmed thats all I can say... More on MVP Global Summit to come...
Just in two days I have met people from more than 20 different countries and all of them were such amazing guys/gals...
I am just coming after attending a session by Don Box and Chris Anderson, and there are no words to express how you feel listing technology from the guys who make it...
I am overwhelmed thats all I can say... More on MVP Global Summit to come...
Wednesday, March 31, 2004
My New Suggestions to Microsoft:
After listning to my clients complains and people who talk to me about Microsoft Technologies, I felt I can suggest some punch lines to Microsoft... I will take royalties if MS starts using them :-)
"With Microsoft: You are always Obselete"
and
"Learning is a Life Long Process: If you don't believe, here's our NEXT UPDATED VERSION"
Well, I am really passionate about Microsoft Technologies and I understand that the changes are for good, but our clients demand stability and their primary aim is buisness not upgrading to latest technologies always... Being a MVP I feel its important to let MS know about this serious concern that comes up to us everytime...
"With Microsoft: You are always Obselete"
and
"Learning is a Life Long Process: If you don't believe, here's our NEXT UPDATED VERSION"
Well, I am really passionate about Microsoft Technologies and I understand that the changes are for good, but our clients demand stability and their primary aim is buisness not upgrading to latest technologies always... Being a MVP I feel its important to let MS know about this serious concern that comes up to us everytime...
Secure you SQL Server
This is a note is for SQL Server Administrators... Read further to see if your SQL Server is vulnerable...
As you must be aware that by default SQL server opens port 1433 to the internet when services are installed... And ofcourse the celebrated "sa" account with all rights and no password is world famous... :-) The SPIDA worm took advantage of these two things and made TCP/IP hits on various IP addresses on the internet... Ofcourse, it was bound to find one or another IP who had its 1433 port open and SQL Server "sa" account having password blank... That was it, a silly mistake and what all can happen is to our imagination... Though some of the things worth noting are that the worm deletes certain fields and tries similar other IPs... There can be no end to this...
Also it changes the password to 4 characters, which are ofcourse sent to the hacker and adds guest account into the adminstrator group... You can now imagine what else can happen to your system...
As you must be aware that by default SQL server opens port 1433 to the internet when services are installed... And ofcourse the celebrated "sa" account with all rights and no password is world famous... :-) The SPIDA worm took advantage of these two things and made TCP/IP hits on various IP addresses on the internet... Ofcourse, it was bound to find one or another IP who had its 1433 port open and SQL Server "sa" account having password blank... That was it, a silly mistake and what all can happen is to our imagination... Though some of the things worth noting are that the worm deletes certain fields and tries similar other IPs... There can be no end to this...
Also it changes the password to 4 characters, which are ofcourse sent to the hacker and adds guest account into the adminstrator group... You can now imagine what else can happen to your system...
Wednesday, March 24, 2004
Bloomington, IL gets a MSDN Event
Blooomington, IL which is the headquarter of State Farm Insurance (one of the largest insurance companies of US), head quarters of Country Insurance, houses Illinois State University (ISU), Illinois Wesleyan University - finally gets due importance and has a MSDN event...
The event is being conducted at a local hotel (Radisson) and is scheduled to run from 1 pm to 5 pm on March 24th 2004... The topic of the discussion will be "Security Briefings"... You can register for the event @ http://www.microsoft.com/seminar/events/inperson/default.mspx ... I am hopeful that more such events would be conducted in the future...
I shall be trying that .Net Bloomington User Group (.Net- BUG) gets involved in the activities and gets support from Microsoft for conducting similar events in the future...
The event is being conducted at a local hotel (Radisson) and is scheduled to run from 1 pm to 5 pm on March 24th 2004... The topic of the discussion will be "Security Briefings"... You can register for the event @ http://www.microsoft.com/seminar/events/inperson/default.mspx ... I am hopeful that more such events would be conducted in the future...
I shall be trying that .Net Bloomington User Group (.Net- BUG) gets involved in the activities and gets support from Microsoft for conducting similar events in the future...
Saturday, February 21, 2004
Adding your Assembly in GAC + Making it VS.Net Visible
I just wanted to update you all about some useful information:
You can assume these to be my quick and dirty notes... I am gonna now explain you the process of having a .Net assembly put in GAC and then making it GAC visible...
1.) To put your assembly into GAC you need to have it strong named.... So first step is to go and create a key using the strong name exe of Visual Studio tools.... Go to Visual studio tools and open the command prompt.... Next step is type "sn -k
2.) By doing this you will get a key file on your machine... You now need to bind it with your assembly... Note that the key file in normal scenario will have a "lock" as icon...
3.) Go to assemblyinfo file of your class library (or whatever :-)) and give the path of your this key file in AsemblyKeyFile ibute eg. [assembly: AssemblyKeyFile("C:\\delete\\ClassLibrary1\\bin\\Debug\\somekeyfile.snk")]... Remember ideally you should give a relative path here...
4.) Now again go to VS commond prompt and run gacutil... GacUtil is present in "root directory\Windows\Microsoft .Net\Framework\ the version that you work on" folder... Give the complete path while you run Gacutil... use the switch as "/i"... Now run the Gacutil and your assembly will get entered in the GAC....
5.) Alternatively a simple solution is copying your strong named dll directly in Windows\Assembly, but I feel acedamically you should know about Gacutil too...
6.) Now even after doing all this and having your assembly in GAC you shall not be able to see it when you try to open add referenes... For that there is another trick... See the point is Add Reference is a IDE specific stuff and so you need to alter those setting... for that reason you need to create certain keys in the Registry
7.)To display your assembly in the Add Reference dialog box, you can add a registry key, such as the following, which points to the location of the assembly
[HKEY_CURRENT_USER\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\Debug]@="C:\\MyProjects\\ClassLibrary1\\Bin\\Debug\\" where Debug is nothing but the name of the folder in which the assemblies resides. You will not file any enteries here in case you have never tempered this area... so create this whole structure in the registry... You can create these registry entries under the HKEY_LOCAL_MACHINE root key also. This will change the setting for all of the users on the system. If you create this registry entry under HKEY_CURRENT_USER, this entry will affect the setting for only the current user. Inshort if you want anyone logging the machine is able to see your assembly in the Add References section make the key under HLM or else make it under HCU... When you then next time restart VS.Net you shall be able to find your assembly....
I shall polish this scribbled notes sometimes, but currently it gives sufficient info right!!
So Enjoy!!
You can assume these to be my quick and dirty notes... I am gonna now explain you the process of having a .Net assembly put in GAC and then making it GAC visible...
1.) To put your assembly into GAC you need to have it strong named.... So first step is to go and create a key using the strong name exe of Visual Studio tools.... Go to Visual studio tools and open the command prompt.... Next step is type "sn -k
2.) By doing this you will get a key file on your machine... You now need to bind it with your assembly... Note that the key file in normal scenario will have a "lock" as icon...
3.) Go to assemblyinfo file of your class library (or whatever :-)) and give the path of your this key file in AsemblyKeyFile ibute eg. [assembly: AssemblyKeyFile("C:\\delete\\ClassLibrary1\\bin\\Debug\\somekeyfile.snk")]... Remember ideally you should give a relative path here...
4.) Now again go to VS commond prompt and run gacutil... GacUtil is present in "root directory\Windows\Microsoft .Net\Framework\ the version that you work on" folder... Give the complete path while you run Gacutil... use the switch as "/i
5.) Alternatively a simple solution is copying your strong named dll directly in Windows\Assembly, but I feel acedamically you should know about Gacutil too...
6.) Now even after doing all this and having your assembly in GAC you shall not be able to see it when you try to open add referenes... For that there is another trick... See the point is Add Reference is a IDE specific stuff and so you need to alter those setting... for that reason you need to create certain keys in the Registry
7.)To display your assembly in the Add Reference dialog box, you can add a registry key, such as the following, which points to the location of the assembly
[HKEY_CURRENT_USER\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\Debug]@="C:\\MyProjects\\ClassLibrary1\\Bin\\Debug\\" where Debug is nothing but the name of the folder in which the assemblies resides. You will not file any enteries here in case you have never tempered this area... so create this whole structure in the registry... You can create these registry entries under the HKEY_LOCAL_MACHINE root key also. This will change the setting for all of the users on the system. If you create this registry entry under HKEY_CURRENT_USER, this entry will affect the setting for only the current user. Inshort if you want anyone logging the machine is able to see your assembly in the Add References section make the key under HLM or else make it under HCU... When you then next time restart VS.Net you shall be able to find your assembly....
I shall polish this scribbled notes sometimes, but currently it gives sufficient info right!!
So Enjoy!!
Monday, January 26, 2004
MVP Regional Summit, Chicago
On 17th January 2004 there was a MVP Regional Summit in Chicago... Around 30+ MVPs from across US had come down for this event which happened in 'W' Central Chicago Hotel, Chicago...
MVP Summits have recently started occurring in US and the main agenda of the same was interaction between Microsoft Team, which is dedicated to community and Microsoft MVPs who too are closely associated with community...
Lots of the stuff that happened in the summit is covered under Non-Disclosure Agreement (NDA) of Microsoft with MVPs so I shall not be able to write much but still I shall jot down some salient points of the summit which are outside the perview of NDA...
Well!! quite a few celebrated people had come down from Microsoft for the summit, to name a few of them would be Sean O'Driscoll, Director, MVP & Community; Ricardo Wanger, Regional Manager USA; Mike Hernandez, VSTO Team; Emily Freet, Program Manager, Academic Communities; Ben Miller, MVP Lead ASP.Net; Jacob Cynamon, Developer Community; Vinny Pasceri, Longhorn Team; Martin Holladay, ADS Team; Brad Rhodes, Yuknon Team; Mike Sampson, Office MVP Lead; Brian Boston, Windows Client MVP Lead
John Buscher, Windows Server MVP Lead & also "The Host" of the Summit; And Susan Leiter, MVP Program Event Coordinator... (Thanks Brain for filing up the list... !!)
The major technical sessions which happened were:
1.) Session on Automated Deployment Services (ADS) by Martin Holladay
2.) Session on Windows Roadmap & Longhorn by Vinny Pasceri
3.) Session on Visual Studio Tools for Office by Mike Hernandez
4.) Session on Data Story for Whidbey by Brad Rhodes
A believe me all the above sessions were very useful... I could not relate to ADS a lot as its not my area but I am sure that those who were related must have found it pretty useful... About the next three sessions, I had heard about longhorn and Yukon a lot earlier in TechEds and other Microsoft Events in India but here it was much free environment, you see the best analogy would be a college class and a personal tution :-)
But the VSTO part was the most catchy to me... I nearly feel in love with that product and would love to work in something like that, to enhance it to its best and make it a favorite product of many... I surely suggest you to read about it wherever possible... I would had filled up the whole blog with info about it but ususal MS stuff THE NDA... :-) Anyways, sometime soon when it will be worth mentioning I definitely shall...
Now about the best times of the meet... The fun part... We had a nice lunch discussion with Sean & Ricardo, where we talked about the MVP Program, the way it is and the way it should be etc... It was really nice to learn that Sean and Ricardo were actually in a very receptive mode... When it comes to technology I can relate what will fall into NDA and what will not, in such informal discussions its nearly impossible to predict so I better not tell more... India MVPs if you want to know more do drop in a mail and I shall write specially to you, but in short it was a nice long close to 2+ hours session...
We also had a nice social evening where all of us could get together and have some good time... Wish I could upload pictures on my blog...
I also met with Jacob Cynamon from Developer Community... got really pally with him, hope we shall work closely in the time to come and do something useful... Got an oppoutunity to talk again with Ben, who always reminds me of Deepak, my India MVP Lead.. Both Deepak and Ben are full of energy and enthusiam... Thats what comprises of a MVP lead perhaps... I also got to spend some time with Emilly and discuss about my ideas of community model, hope so that such a wonderful discussion will ultimately yeild into something, I need to do some homework here... And ya one good progress was talk with Andrew Flick the Student Ambassador to Microsoft from Bradly University, Peoria, IL... I believe Andrew can join hands to work for growth of .Net Community & groups like .Net-BUG
Last but not the least was drink and dine which I had together with Vinny, Ricardo, Mike, Dian & Greg Chapman (Great MVPs)... That time will be one of the most cherished time for me to remember... I learn that all those Techhie guys out there are actually musicians and above all very nice human beings...
Moral of the story: Regional Summit was amazing, fun & learn experience and I shall look forward to more of those types in the future...
-Vishal Joshi
MVP Summits have recently started occurring in US and the main agenda of the same was interaction between Microsoft Team, which is dedicated to community and Microsoft MVPs who too are closely associated with community...
Lots of the stuff that happened in the summit is covered under Non-Disclosure Agreement (NDA) of Microsoft with MVPs so I shall not be able to write much but still I shall jot down some salient points of the summit which are outside the perview of NDA...
Well!! quite a few celebrated people had come down from Microsoft for the summit, to name a few of them would be Sean O'Driscoll, Director, MVP & Community; Ricardo Wanger, Regional Manager USA; Mike Hernandez, VSTO Team; Emily Freet, Program Manager, Academic Communities; Ben Miller, MVP Lead ASP.Net; Jacob Cynamon, Developer Community; Vinny Pasceri, Longhorn Team; Martin Holladay, ADS Team; Brad Rhodes, Yuknon Team; Mike Sampson, Office MVP Lead; Brian Boston, Windows Client MVP Lead
John Buscher, Windows Server MVP Lead & also "The Host" of the Summit; And Susan Leiter, MVP Program Event Coordinator... (Thanks Brain for filing up the list... !!)
The major technical sessions which happened were:
1.) Session on Automated Deployment Services (ADS) by Martin Holladay
2.) Session on Windows Roadmap & Longhorn by Vinny Pasceri
3.) Session on Visual Studio Tools for Office by Mike Hernandez
4.) Session on Data Story for Whidbey by Brad Rhodes
A believe me all the above sessions were very useful... I could not relate to ADS a lot as its not my area but I am sure that those who were related must have found it pretty useful... About the next three sessions, I had heard about longhorn and Yukon a lot earlier in TechEds and other Microsoft Events in India but here it was much free environment, you see the best analogy would be a college class and a personal tution :-)
But the VSTO part was the most catchy to me... I nearly feel in love with that product and would love to work in something like that, to enhance it to its best and make it a favorite product of many... I surely suggest you to read about it wherever possible... I would had filled up the whole blog with info about it but ususal MS stuff THE NDA... :-) Anyways, sometime soon when it will be worth mentioning I definitely shall...
Now about the best times of the meet... The fun part... We had a nice lunch discussion with Sean & Ricardo, where we talked about the MVP Program, the way it is and the way it should be etc... It was really nice to learn that Sean and Ricardo were actually in a very receptive mode... When it comes to technology I can relate what will fall into NDA and what will not, in such informal discussions its nearly impossible to predict so I better not tell more... India MVPs if you want to know more do drop in a mail and I shall write specially to you, but in short it was a nice long close to 2+ hours session...
We also had a nice social evening where all of us could get together and have some good time... Wish I could upload pictures on my blog...
I also met with Jacob Cynamon from Developer Community... got really pally with him, hope we shall work closely in the time to come and do something useful... Got an oppoutunity to talk again with Ben, who always reminds me of Deepak, my India MVP Lead.. Both Deepak and Ben are full of energy and enthusiam... Thats what comprises of a MVP lead perhaps... I also got to spend some time with Emilly and discuss about my ideas of community model, hope so that such a wonderful discussion will ultimately yeild into something, I need to do some homework here... And ya one good progress was talk with Andrew Flick the Student Ambassador to Microsoft from Bradly University, Peoria, IL... I believe Andrew can join hands to work for growth of .Net Community & groups like .Net-BUG
Last but not the least was drink and dine which I had together with Vinny, Ricardo, Mike, Dian & Greg Chapman (Great MVPs)... That time will be one of the most cherished time for me to remember... I learn that all those Techhie guys out there are actually musicians and above all very nice human beings...
Moral of the story: Regional Summit was amazing, fun & learn experience and I shall look forward to more of those types in the future...
-Vishal Joshi
Subscribe to:
Posts (Atom)