次の方法で共有


WCF Sample ComplexTypeAjaxService

Today I decided to take a look at the WCF/WF Samples for .NET 4.  There are quite a lot of them but to be honest with you I have not found them to be very helpful.  In the spirit of trying to make things better I’m going to review the sample with you.

I decided to start with the WCF samples and the first one I’m starting with is the ComplexTypeAjaxService.

I went through the One-Time Set-Up Procedure for the Windows Communication Foundation Samples which is lengthy and enough to scare most people away but I made it through.

Now I open up ComplexTypeAjaxService.sln.  So far so good, but when I try to look at ComplexTypeClientPage.aspx it crashes VS2010 RC (I tried several times with the same result) so I looked it over in notepad.

So I decide to build the sample.  It has a Post-build command line that tries to create directories and copy files to the VRoot which requires admin privileges so it fails because I haven’t run VS2010 with admin privileges.

I start VS2010 again with Admin Privileges and build the sample.  Then I try to browse the file and get another error about the web.config.  I’m wondering why it doesn’t just run in the ASP.NET Development Server so I switch back to VS2010 and try to view the .aspx page in the browser (which should launch the development server) but instead I get a browser window that just hangs.

I decide to look at the project properties to see what is going on and I find that the project is not a web app.  It is a class library (which explains why it behaves so strangely).

I think I’m going to start a new project that doesn’t suffer from all these pains and give it a go.

So I do the following

  1. Create an Empty ASP.NET Application
  2. Add an AJAX-enabled WCF Service named Calculator
  3. Add a class named MathResult and copy over the class from the sample
  4. Remove DataContract / DataMember since they are no longer required but are optional
  5. Paste in the HTML from the original project (fixed up with table formatting so it looks better)
  6. Added some simple styling and page title
  7. Supplied default values

Now I’ve got a nice sample that works quite well and it took just a couple of minutes.  Check it out

Comments

  • Anonymous
    February 23, 2010
    Speaking of pain points with the WCF/WF samples for .NET 4, I am confused as to why some of the WF samples are using what I think are WF 3.5 constructs. The WFScenarioExternalRuleSetToolkit project is the one that is confusing me at the moment.  What am I missing? I have really liked the webcasts you have done on WF 4, so please keep them coming:)