During the development of the new version of our applications using distributed architectures with WCF I found the following problems in the Visual Studio tools that I want to share here.
The first one, which many will have identified, is that when generating the code using the new WCF library option in visual basic it generates a datacontract1 class that does not have any of its properties marked as datamember, so when the service is published and the proxy is generated this class has no public property that can be transmitted over the wire, this is easily solved by marking the generated property as datamember so that it looks like this: (in bold what needs to be added)
<DataContract()> _
Public Class DataContract1
Private m_firstName As String
Private m_lastName As String
<DataMember()> _
Public Property FirstName() As String
Get
Return m_firstName
End Get
Set(ByVal value As String)
m_firstName = value
End Set
End Property
Enjoying this? Get more like it, once a week.
<DataMember()> _
Public Property LastName() As String
Get
Return m_lastName
End Get
Set(ByVal value As String)
m_lastName = value
End Set
End Property
End
Class
The second one has to do with the default name for the namespace that Visual Studio places on projects, this namespace generates a problem in the serialization of objects marked as datacontract since they arrive correctly at the service but are not initialized, if you debug the client you see the object correctly created but in the service the values are not there.
This point can be resolved using one of the following procedures:
a. Removing the default namespace placed in the client, the host and the service. (using the project properties inside visual studio).
b. when generating the service proxy using the svcutil.exe tool use the /n modifier to indicate that you want to generate a proxy with the client's namespace, something like this:
svcutil.exe *.wsdl *.xsd /namespace:*,MyNamespace /language:VB
where MyNamespace is the name of the service client's namespace.
These problems do not occur when using services with basic CRL types such as strings or integers or in some other type of contract (operation, fault, etc), it is only for when you have data contracts of the datacontract type, nor do they occur in C#.
I hope it is useful.
Juan Carlos Peláez
MCTS
KeyWords: WCF, svcutil, Visual Basic, Framework, net, Architecture, Distributed Components, Client, Service, Host, Microsoft