How to enable session state in web services

Some days back I was writing a few web services. I have coded web services many times, but never required to use Session State before. This time I required to check a few session variables before returning the correct data from the web service. I tried using the HttpSession like in a normal web page but got an error. After a little search found the right way to use HttpSession in webmethods. The simple trick is to enable the Session State before using it directly. This can be done by using the following attribute

[WebMethod(EnableSession = true)] // C#

<WebMethod(EnableSession:=true)> // VB .Net

Once you specify these lines over your web method you can use the session object naturally.

Advertisements

Failed to initialize the AppDomain:/LM/W3SVC/1/Root/WebSite1

I have installed IIS and registered asp .net worker process on many machines now. But today while setting up and my new laptop I recieved two weird errors. The first one was

Event Source: ASP.NET 2.0.50727.0
Failed to initialize the AppDomain:/LM/W3SVC/1/Root/WebSite1

Exception: System.IO.FileLoadException
Message: Could not load file or assembly ‘System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ or one of its dependencies. Access is denied.
StackTrace: at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Activator.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(String assemblyName, String typeName)
at System.AppDomain.CreateInstance(String assemblyName, String typeName)
at System.AppDomain.CreateInstance(String assemblyName, String typeName)
at System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironment(String appId, IApplicationHost appHost, HostingEnvironmentParameters hostingParameters)
at System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironmentAndReportErrors(String appId, IApplicationHost appHost, HostingEnvironmentParameters hostingParameters)

Followed by two more errors

Failed to execute the request because the ASP.NET process identity does not have read permissions to the global assembly cache. Error: 0x80070005 Access is denied.

and

aspnet_wp.exe (PID: 3720) stopped unexpectedly.

Upon some investigations I found out that this error occurs if you do not restart the machine after installing IIS. What I did wrong was I installed IIS and immediately after that installed Visual Studio which must have registered the asp .net 2.0 on IIS. To overcome the problem I took the following steps

  1. Uninstalled the IIS
  2. Restarted the machine
  3. Installed the IIS
  4. Restarted the machine
  5. Re-register the asp.net : using aspnet_regiis.exe -i

While this solved this problem, I then started to encounter another weird error, which I could not believe. All I was seein g when I used to run an asp.net application locally was Server not available error.

When I checked the system event logs I saw an error entry

Event Type: Error
Event Source: W3SVC
Event Category: None
Event ID: 115
Date: 24/09/2007
Time: 5:44:08 PM
User: N/A
Computer: BITG022-NB
Description:
The service could not bind instance 1. The data is the error code.
For additional information specific to this message please visit the Microsoft Online Support site located at: http://www.microsoft.com/contentredirect.asp.

This error is caused and will occur if some application is already running and utilising Port 80,which is the default Http port. In my case I was running skype; In skype there is an option where you can use. Check the image below for reference.

skype

Hindi font on Mac

A few months back I bought myself a macbook pro. Really i think it was a good decision. I am very happy with the quality of hardware and some of the cool features that Mac OS X Tiger offers. So today while I was browsing, I came across webdunia.com. It publishes it’s content in 9 different Indian languages including Hindi, my mother tounge. I was using Firefox 2.0.07 and all I could see on the site was images and ????. All the hindi text appeared as question marks. I immediately thought that hindi fonts are not installed. I decided to install the font set to see my favourite curvy characters. I search very hard on the internet, googling this afternoon to get Hindi working on my Mac. But to no avail.

After my evening tea I sat again and decided to give it another try. But this time to my surprise I could read everything without doing anything. I had no clue what was going on. Then I realised I was using Safari, the pre installed browser. After some more search on net I came to know that Indic rendering of Firefox on Mac OS X is not up to the mark yet, but is perfect on Safari.

To sum up:

On Safari with Mac OS X 10.4 Tiger the handling of Indian scripts is amazingly flawless.
On Firefox unfortunately as of today Indian scripts can’t be rendered well enough.

If you wish to type in Hindi:
1) Go to System Preferences
2) Click on International
3) Click on the Input tab and select Devanagari and/or Devanagari-QWERTY
4) Check the Show Input Menu in Menu Bar for easy switching

And this is how to write word Hindi using hindi scripthindi lang

Last day at Elcom

Today was my last day at Elcom. This was my first job after moving to Sydney. Elcom is a fantastic company to work in. I had a great time and learned a lot from the team. Working at Elcom was fun. The team is very closely knitted. Guys are very technology focussed and help each other. Elcom had become a family to me. We went out to “pub-lunch” and later in the evening had a few drinks. Pawan, my close friend and our HR/Admin Manager gave a heart filled speech and handed me farewell card signed by team mates. Each and every word in the card reflects their love.

Yesterday I spend an hour with John Anstey, CEO and talked about the new directions Elcom wants to move in. At Elcom we have developed Community Manager(CM) – a world class enterprise content management system. Now John wants to move into Microsoft Office SharePoint Server 2007, develop Silverlight modules for CM and possibly start a Silverlight .Net User group. All the best John. A week back at Elcom, Craig Bailey has joined as new CTO. Craig brings with him his vast knowledge and experience on Microsoft Technologies. Boy, is Elcom thrilled to have him!!! Unfortunately for me for this time I didn’t have much time to work with him. But believe it or not the man has left a deep impression on me.

And for all Elcomites I could not thank you enough for your support and affection. I wish you all the best in your future endevours.

Hello weblog!

This is my first post, into my weblog. I have been thinking about starting this for a while now. But today at my last day at Elcom I was motivated by two great guys Anthony Milner and Craig Bailey to start and write my own blog. So here I am with a few words about my work and this blog and what I plan to post in the future.I have now been working with Microsoft technologies for about 5 yrs. I am a solution architect and my day to day work involves designing, implementing and developing web applications with ASP .Net, C#, VB .Net and SQL Server.

I will like this blog line to be technology focussed as much as possible. My future posts will talk about my daily experiences at work & my experiments with new technology.