Tuesday, December 16, 2008

My Visual Studio Error Puzzle

OK, here’s my small puzzle I came across today.

Start Visual Studio 2008. Select New Project -> Visual C# -> Windows -> Windows Forms Application. WindowsFormsApplication1 seems to be a good enough name. Hit OK.

Now, go to Solution Explorer, right-click WindowsFormsApplication1 and select ‘add Class’. Class1 seems to be a good enough name. Hit OK.

Now, make this class inherit from SoapHttpClientProtocol. For this purpose, add a reference to ‘System.Web.Services’ to References.

Now, decorate this new Class1 with the WebServiceBindingAttribute.
You’ll end up with code as simple as this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Services.Protocols;
using System.Web.Services;

namespace WindowsFormsApplication1
{
[WebServiceBindingAttribute(Name = "AsyncRequestSoap",
Namespace = "http://tempuri.org/")]
class Class1 : SoapHttpClientProtocol
{
}
}

The project builds without errors and, if actual code is added to Class1, it will execute without errors. However, if I double-click 'Class1.cs' in Solution Explorer, I would be presented with an error screen like this one:



This seems to be a bug in Visual Studio since it’s obvious that WebServiceBindingAttribute attribute is added to the class and the application will compile and execute regardless of the error screen. Seems to be safe to ignore. However, I did not find clarification on that yet. by . Also posted on my website

No comments: