Posted by Manoj Garg on May 12, 2009
While surfing around I can across a term called “null-coalescing operator”. After searching about it, I came to know that C# has an operator ?? . well I didn’t new about it before so thought of writing about it.
The ?? operator is called the null-coalescing operator and is used to define a default value for a nullable value types as well as reference types. It returns the left-hand operand if it is not null; otherwise it returns the right operand.
int? x = null;
string str = "Hello World !!";
int y = x ?? -99; // Here Y will be -99 since X is null
string newStr = str ?? "Default Hello World !!"; // here newStr will be "Hello World !!"
PS: This operator reminded me of similar functions available in SQL Server like ISNULL, COALESCE
Posted in C# | Tagged: ??, null-coalescing operator | Leave a Comment »
Posted by Manoj Garg on May 6, 2009
Yesterday, a team mate of mine sent an email regarding a problem with his Visual Studio 2005. ASP.NET web server wasn’t allowing him to debug any Web services. Following is the complete description of his problem:
In short, the ASP.NET 2.0 development web server (webdev.webserver.exe) on my machine broke after I installed and uninstalled NDoc some days ago. IIS still works fine. I’ve tried re-registering ASP.NET 2.0 (aspnet_regiis –r from the 2.0 directory) to no avail. Other than re-installing VS 2005, could you recommend a quick fix?
I am on XP. I had VS 2005 with v2.0 of the framework. Then I installed NDoc recently and that supports only v1.1, so it installed v1.1 on top of v2.0. That is fine because both versions can co-exist but what it did was screw up some settings with:
a) The web server that comes with ASP.NET, the one you run your web services on in debug mode.
b) SQL Server’s active CLR settings (but this isn’t bothering me as much)
c) IIS settings (but I fixed this by re-registering IIS with 2.0)
What’s bothering me to the hilt now is the broken ASP.NET web server won’t allow me to debug my Web services or even have another project in the same solution create a web reference to it.
I can’t generate proxies in Visual Studio because of this, nor can I set a web reference to a web service in the same solution (as it involves generating a proxy).
Note that I can call wsdl.exe though. My web services compile, and if I generate a proxy myself through wsdl.exe, deploy my WS locally on IIS, and change the url in the proxy’s constructor to my locally deployed WS, and add the proxy to my client project, it all works fine.
But I don’t want to deploy my service yet. I just want all projects in the same solution referencing the ws like well-behaved little kids.
When I do try to create a web reference to the WS project in my solution, I keep getting this error:
Server Error in ‘/’ Application.
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not create type ‘DaWS.PhoneDirectory’.
Line 1: <%@ WebService Language="C#" CodeBehind="PhoneDirectory.asmx.cs"
Line 2: Class="DaWS.PhoneDirectory" %>
Source File: /PhoneDirectory.asmx Line: 2
Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082
It’s been nagging me for days now and I’ve been managing with deploying in IIS.
Other than re-install Visual Studio, does anyone have a better solution?
Here’s what the Event Log says:
Event Type: Warning
Event Source: ASP.NET 2.0.50727.0
Event Category: Web Event
Event ID: 1310
Time: 12:04:33 AM
Event code: 3006
Event message: A parser error has occurred.
Event time: 06/05/2009 12:04:33 AM
Event time (UTC): 05/05/2009 6:34:33 PM
Event ID: c41a610193fa4c2e810dad096709b0b0
Event sequence: 4
Event occurrence: 1
Event detail code: 0
Application domain: a54e0deb-1-128860220726250000
Trust level: Full
Application Virtual Path: /
Application Path: C:\Me\rnd\DotNet\DoIndexersGetSerialized\DaWS\
Machine name: ABCD
Process ID: 660
Process name: webdev.webserver.exe
Account name: Domain\Me
Some one finally caught the issue, following are his observations and solution:
Just wondering if you are using a fixed port or not for the web service that you try to reference. Because Web Dev by default always host the app on different port and if that the case you will not be able to get it working ever.
If you are not using the fixed port I would suggest you to use the “External Tool” options present in the VS’s Tool menu and create a fixed web dev location that is associated with you web service and you should be able get it working.
I may be telling you the thing that you might have tried but just incase if you haven’t please give it a try.
Please have a look at this URL and probably give you the solution you are looking for.
This did the trick. The problem was solved. So I thought to write it here as someone else may face the same issue.
Posted in .Net 2.0, ASP.Net, VS 2005 | Tagged: fixed ports, IIS, ndoc issue, webdev.webserver.exe | 4 Comments »