Implementing Generices in WFC?

Declaring service contract interfaces of type <T> does not seem to work when it comes to specifying the configuration in XML, especially the Contract tag does not like IContract<T>.

Interface IContract<T>
Void AddNew(T val)
ReadOnlyCollection<T> GetList()

MyServiceClass : IContract<Address>
.....
.....
.....


Specifying EndPoints Programatically works great but specifying in a config seems to crap out?
Is this a bug in WFC framework or its just by design that services should not be generic in nature?

[590 byte] By [msdate] at [2007-12-25]
# 1

// its just by design that services should not be generic in nature?

ServiceContract, Operation contract and DataContract maps to WSDL ( wsdl:portType, wsdl:message and wsdl:types respectively) and your ServiceBehavior and OperationBehavior should be concrete types. Check out this simple sample

http://www.falafel.com/Blogs/tabid/110/articleType/ArticleView/articleId/284/WCF-A-Simple-Generic-Data-Serivce.aspx

# 2

Specifying contract programatically always works, how-ever the web config part does not.

<system.serviceModel>
<services>
<service name="TestWindowsApplication.AddressList" behaviorConfiguration="metadataSupport">
<endpoint address="svc" binding="basicHttpBinding" contract="TestWindowsApplication.IContract&lt;TestWindowsApplication.Address&gt;"/>
<endpoint address="net.tcp://localhost:8081/Address/svc" binding="netTcpBinding" contract="TestWindowsApplication.IContract&lt;TestWindowsApplication.Address&gt;"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="metadataSupport" IncludeExceptionDetailInFaults="true">
<serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>

Should'nt this work too ?

msdate at 2007-8-31 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 3
Hello.

You are using the C# notation for generics inside the config file "TestWindowsApplication.IContract<TestWindowsApplication.Address>"

You should use the "MSIL" notation instead:
"TestWindowsApplication.IContract`1[TestWindowsApplication.Address]"

Hope it helps
Pedro Felix


PedroFelix at 2007-8-31 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 4

Thank you so much.

Use reflection to get the exact type of using GetType() function and specify the full name

UnderlyingSystemType: {Name = "IContract`1" FullName = "TestWindowsApplication.IContract`1[[TestWindowsApplication.Address, TestWindowsApplication, Version=1.0.2466.25199, Culture=neutral, PublicKeyToken=null]]"}

Speficy type as contract="TestWindowsApplication.IContract`1[[TestWindowsApplication.Address, TestWindowsApplication, Version=1.0.2466.25199, Culture=neutral, PublicKeyToken=null]]" and this rocks!!!

msdate at 2007-8-31 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...

Visual Studio Orcas

Site Classified