Standing on the shoulders of giants. RSS 2.0
Previous Page Page 2 of 2 in the DevelopmentC category
# Friday, January 05, 2007

public class A {
    public virtual void AA(){}
}

public abstract class B : A{
    public abstract override void AA();
}


If you now would define a class C : B, then C must implement the method AA again.
Friday, January 05, 2007 2:23:52 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0] - Trackback
Codesnippet | C#
# Saturday, December 30, 2006

This is a short walkthrough on how to get the REST and POX sample from the Vista SDK to work on IIS. I assume VS 2005 with SP 1 and IIS 5.1, but the changes required on IIS 6 are the same.

Before we begin make sure you have .Net 3.0 installed and either the Vista SDK or the WCF Samples. And IIS, with the mappings for Asp.Net and WCF.

The sample we'll modify to work with IIS is located in "TechnologySamples\Scenario\PoxMessaging\CS" directory. And since there are no code changes the VB sample should work too.

First load the solution and make sure the it actually compiles and works, so we have a known base system we can work from. Do this by first starting the server and next the client, if you don't get any un-handled exceptions, then everything works, so we're good to go.

Next create a new Web Application Project, names ServiceHost in the solution and make sure it uses IIS for hosting in the Properties Web tab.

Remove all files VS created in your new project, except for the web.config and copy all files from the service project, except for program.cs and app.config. Finally add a reference to the System.Runtime.Serialization and the System.ServiceModel assemblies. Now the project should compile, but won't do anything interesting.

To register the endpoint, we have to copy the serviceModel configuration from the app.config in the service project to the web.config. So add the following to the web.config file:

 










contract="Microsoft.ServiceModel.Samples.IUniversalContract" />


This is the same as the config in the app.config, with the baseAddresses node removed, since those are supplied by IIS.

Now add a new file to the web project named: "customers.svc" with the following content:

<%@ ServiceHost Language="C#" debug="true" service="Microsoft.ServiceModel.Samples.CustomerService" %>

Save all files and if you surf to http://localhost/servicehost/customers.svc/customers/1 , you should see the following:

http://tempuri.org/Customer" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">

100 Main Street

Bob

Do note how the "/customers" part maps to the endpoint you specified in the web.config and the "/1" to the id of the customer. If you leave off the "/1" you should get a list of customers.

Which indicates the GET HttpMethod is working, to get the other methods working, we have to make some changes to the IIS configuration. In the properties of the ServiceHost virtual directory in IIS, click the Configuration button.

 

Now find the .svc mapping in the Application Mappings, click Edit and select "All Verbs".

That's all there is to it. To test it you'll need to make some changes to the client project, to make sure it uses the correct URLs to access the service. See the attached solution for details.

 POX-REST-IIS-Sample.zip (11.69 KB)

Saturday, December 30, 2006 3:51:43 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0] - Trackback
C# | Services
# Wednesday, August 02, 2006

They have been around for a bit, hiding as delegates, but they're getting some much deserved attention from Joel [0] and Raymond [1].

Joel is critical about the implementation in C#; while Raymond Chen is starting a series about their implementation and subtle errors. I'm not sure I can totally agree with Joel, since I like the obviousness (and typesafe-ness) of defining delegates and calling them as methods, while the compiler handles the plumbing.

links:
[0] Can your programming language do this?
[1] The implementation of anonymous methods in C# and its consequences (part 1)

[update 2006-08-05]

Ramond added 2 new entries to his anonymous methods series:

The implementation of anonymous methods in C# and its consequences (part 2)
The implementation of anonymous methods in C# and its consequences (part 3)

Wednesday, August 02, 2006 1:59:09 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [0] - Trackback
C#
Ads
About
© Copyright 2012
Paul van Brenk
Sign In
newtelligence dasBlog 2.3.2011.0
All Content © 2012, Paul van Brenk
DasBlog theme 'Business' created by Christoph De Baene (delarou)