In my solution I have the webservice (backend) written in C# and served via WCF to the client which is the MVC3 web front-end with VB.NET. For one web service I need to send to the client a list of dynamic objects List<SerializableDynamicObject>
.
I implemented solution described here: WCF Serializaiont of DLR , Example code. In my test console application written in C# I can easily read dynamic properties served by WCF. Unfortunately in the VB.NET console application when I try to call one of the property I receive error message for first property "Public member 'TRIP_ID' on type 'SerializableDynamicObject' not found". The interesting thing is that I can see in the "Watch" and "Locals" windows dynamic properties for served objects in both C# and VB.NET.
Can anyone explain to me what is the problem and how to solve this ? Thanks...
The webservice code:
public class Service1 : IService1
{
public object Process(object value)
{
dynamic d = new SerializableDynamicObject();
d.TRIP_ID = Convert.ToInt64(1);
d.TRIP_NAM = "TRIP NAM";
d.TRIP_USR_CRE_DTE = DateTime.Now;
d.TripValue = new SerializableDynamicObject();
d.TripValue.TPVL_TRIP_ID = Convert.ToInt64(1);
d.TripValue.TPVL_VAL = "TPVL VAL";
return d;
}
}
The C# version to read WCF dynamic objects (works), the dynamic properties are visible and can be called:
class Program
{
static void Main(string[] args)
{
dynamic d = new SerializableDynamicObject();
d.Testing = "this is a test.";
DynService.Service1Client client = new DynService.Service1Client();
dynamic res = client.Process(d);
Int64 TRIP_ID = res.TRIP_ID;
string TRIP_NAM = res.TRIP_NAM;
DateTime TRIP_USR_CRE_DTE = res.TRIP_USR_CRE_DTE;
Int64 TPVL_TRIP_ID = res.TripValue.TPVL_TRIP_ID;
string TPVL_VAL = res.TripValue.TPVL_VAL;
}
}
The VB.NET version to read WCF dynamic objects (not working)
Option Strict Off
Option Infer On
Imports System.Linq
Imports DynSrv
Module Module1
Sub Main()
Dim d As Object = New SerializableDynamicObject()
d.Testing = "this is a test."
Dim client As New ServiceReference1.Service1Client()
Dim res As Object = client.Process(d)
Dim TRIP_ID As Int64 = res.TRIP_ID
Dim TRIP_NAM As String = res.TRIP_NAM
Dim TRIP_USR_CRE_DTE As Date = res.TRIP_USR_CRE_DTE
Dim TPVL_TRIP_ID As Int64 = res.TripValue.TPVL_TRIP_ID
Dim TPVL_VAL As String = res.TripValue.TPVL_VAL
End Sub
End Module