WCF DataPortal and SqlGuid BO fieldsWCF DataPortal and SqlGuid BO fields
Old forum URL: forums.lhotka.net/forums/t/11197.aspx
Elio posted on Sunday, February 26, 2012
Hi, firts of all sorry for my not so good english, i'm using Csla 3.0.5, my Dataportal is WcfProxy, when i reatreave an object with SqlGuid field and that field is Null from the database i get this exception:
The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://ws.lhotka.net/WcfDataPortal:FetchResult. The InnerException message was 'ValueType 'System.Data.SqlTypes.SqlGuid' cannot be null.'. Please see InnerException for more details.
I googled for a coupled of hours and for my surprise i didnt find nothing about this particular issue, can anybody help me on this?
Thanks
Elio
JonnyBee replied on Sunday, February 26, 2012
SqlGuid is not a data type that your BO should use.
Convert it to a System.Guid or a string instead.
Elio replied on Sunday, February 26, 2012
Hi Jonny, Thans for your quick response; i'm afraid that is something that i cannot change because this is a big legacy application and the code of the those BOs librarys is not on my control. But the instersting thing is when the database column is not null everything works fine. Any idea?
regards
Elio
JonnyBee replied on Sunday, February 26, 2012
Probably because this code (I use LinqPad to run code):
var x = new System.Data.SqlTypes.SqlGuid((string)null);
x.Dump();
will throw exception
Value cannot be null.Parameter name: g |
Message |
Value cannot be null. Parameter name: g |
ParamName |
g
|
Data |
|
InnerException |
null |
TargetSite |
Guid..ctor (String g) |
Name |
.ctor
|
MemberType |
Constructor
|
DeclaringType |
typeof (Guid) |
ReflectedType |
typeof (Guid) |
MetadataToken |
100666501
|
Module |
CommonLanguageRuntimeLibrary |
MDStreamVersion |
131072
|
FullyQualifiedName |
C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll
|
ModuleVersionId |
ef393d65-870f-4a49-bd31-c168e9aa90c0
|
MetadataToken |
1
|
ScopeName |
CommonLanguageRuntimeLibrary
|
Name |
mscorlib.dll
|
Assembly |
mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089 |
CodeBase |
file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
|
FullName |
mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
|
EntryPoint |
null |
Evidence |
PublicKey |
Name |
Version |
Value |
SecurityZone |
SHA1 |
SHA256 |
MD5 |
Certificate |
|
|
|
|
|
|
|
|
|
00000000000000000400000000000000 |
|
mscorlib
|
|
|
|
|
|
|
|
|
|
|
file:///C:/Windows/Microsoft.Net/assembly/GAC_32/mscorlib/v4.0_4.0.0.0__b77a5c561934e089/mscorlib.dll
|
|
|
|
|
|
|
|
|
|
MyComputer
|
|
|
|
|
|
|
|
|
|
95 4B F3 4C 55 9B DA AE C4 57 4B 6A E8 AB C2 CF C2
99 26 89 |
byte[] |
D8 18 2D 9D 2E 39 1E 5A 95 29 DA 7E DB B0 58 15
|
|
|
|
|
|
|
|
|
|
System.Security.Cryptography.X509Certificates.X509Certificate |
|
|
PermissionSet |
|
SecurityRuleSet |
Level2
|
ManifestModule |
CommonLanguageRuntimeLibrary |
|
ReflectionOnly |
False
|
Location |
C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll
|
ImageRuntimeVersion |
v4.0.30319
|
GlobalAssemblyCache |
True
|
HostContext |
0
|
IsDynamic |
False
|
EscapedCodeBase |
file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
|
IsFullyTrusted |
True
|
|
ModuleHandle |
System.ModuleHandle |
MDStreamVersion |
131072
|
|
|
MethodHandle |
System.RuntimeMethodHandle |
Value |
|
|
Attributes |
PrivateScope, Public, HideBySig, SpecialName, RTSpecialName
|
CallingConvention |
Standard, HasThis
|
IsSecurityCritical |
False
|
IsSecuritySafeCritical |
False
|
IsSecurityTransparent |
True
|
ContainsGenericParameters |
False
|
IsGenericMethodDefinition |
False
|
IsGenericMethod |
False
|
IsPublic |
True
|
IsPrivate |
False
|
IsFamily |
False
|
IsAssembly |
False
|
IsFamilyAndAssembly |
False
|
IsFamilyOrAssembly |
False
|
IsStatic |
False
|
IsFinal |
False
|
IsVirtual |
False
|
IsHideBySig |
True
|
IsAbstract |
False
|
IsSpecialName |
True
|
IsConstructor |
True
|
|
StackTrace |
at System.Guid..ctor(String g) |
HelpLink |
null |
Source |
mscorlib
|
Elio replied on Sunday, February 26, 2012
Thanks very much Jonny, i switched to WebService DataPortal which accept SqlGui nulls value from db.
I tested WCF with System.Guid and works fine, but we cannot move our code to use guid, so the service will do the work in the meadel time
Elio
Copyright (c) Marimer LLC