Hello,
I'm trying to use CSLA 4.5 (actual version compiled from sources) on PC with .NET 4. I get CSLA assemblies compiled for .NET 4 from "bin/NET4" directory. I use client WCF channel for communication between client and server.
Whenever I call DataPortal methods from client (Create/Fetch or CreateAsync/FetchAsync), I get this exception:
System.Runtime.Serialization.InvalidDataContractException: Type 'System.Threading.Tasks.Task`1[Csla.Server.Hosts.WcfChannel.WcfResponse]' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. If the type is a collection, consider marking it with the CollectionDataContractAttribute. See the Microsoft .NET Framework documentation for other supported types.
When I run client application on PC with .NET 4.5, everything works fine.
It doesn't matter if I use async
return await DataPortal.FetchAsync<Person>(id);
or sync version from client
return DataPortal.Fetch<Person>(id);
Complete sample solution with this problem is available at http://sdrv.ms/UiZCH9 .
Is it known bug, or has anybody working CSLA 4.5 code on PCs with .NET 4 only and problem is in my code?
Thanks a lot.
So, what you are saying is that an application compiled for .NET 4 with VS2012 behaves differently beetween a client computer that has .NET 4.5 installed and one that only has .NET 4 installed on the client?
Do you run the serverside portal on a computer with .NET 4.5 or is the serverside also running on the client in IIS with .NET 4.5?
One moment that immediatly strike me here is that WCF in .NET 4.5 has been updated to handle async/await and generate client side code that has async/await methods. I haven´t ttried to use these methods with in a .NET 4 client (without .NET 4.5 installed).
Hve you tried to use the Mobile dataportal?
Same as for Silverligh with the MobileFormatter.
Yes, exactly - app compiled with VS 2012 for .NET 4 with CSLA 4.5 for .NET 4 behaves differently on computers with .NET 4 and .NET 4.5. On my development computer with VS 2012/.NET 4.5 it works correctly, the same compiled assemblies on testing computer with NET 4 only does'nt.
I have serverside portal on computers with both .NET versions and the problem is the same - so it looks like the problem is in client WCF proxy.
I haven't tried Mobile formatter yet, I'll try it tommorow and write result to this discussion.
Yes, I am able to reproduce the issue. Thank you for finding this problem - I hadn't thought to test the .NET 4 code on a machine where .NET 4.5 was never installed, and there's clearly some update to the core .NET 4 WCF behaviors that's causing an issue...
The MobileProxy doesn't exist in the CSLA build for .NET 4, so you can't try that. I may get that working as well, depending on the amount of effort, but in any case I'll try to figure out what's going on with your code.
What is a little worrisome, is that we don't actually use a pre-built WCF proxy anymore. The WCF channel and proxy are created at runtime. So you'd _think_ they'd work as expected... Time for some "fun" troubleshooting :)
That was fun :)
Blake and I figured out how to use the remote debugger from a Win8 VS12 machine to debug code on Win7 without VS12 installed. Pretty cool tool.
And more importantly, I did figure out what was happening with the data portal and the code in svn now includes the fix.
The issue is that installing .NET 4.5 does update WCF, so even a .NET 4 app running on a .NET 4.5 machine uses the new WCF. The new WCF knows about the Task<T> type, and the old WCF 4 does not. Because the new CSLA 4.5 data portal uses Task<T> this is an issue.
Now the .NET 4 and .NET 4.5 data portal (WcfProxy) implementations are different, and the .NET 4 implementation avoids using any of those (missing) WCF features.
The behaviors are still the same, though using async data portal calls in .NET 4.5 is probably more efficient than in .NET 4. The .NET 4 implementation basically works as it did in CSLA version 4.3. So the .NET 4 implementation isn't bad, it just isn't as direct as the newer model (behind the scenes).
YOUR code shouldn't be affected, regardless of whether you make sync or async calls to the data portal.
I get code from SVN and my code works well with new assemblies. The only difference is in configuration - I use custom WCF configuration and on the client side I had to change the contract attribute to get it working - from this
<endpoint ... contract="WcfPortal.IWcfPortal" name="WcfDataPortal" />
to this
<endpoint ... contract="Csla.Server.Hosts.IWcfPortal" name="WcfDataPortal" />
But with this confguration change, my code now works on computers with .NET 4 and .NET 4.5.
Copyright (c) Marimer LLC