"Type 'System.Threading.Tasks.Task`1[BrightstarDB.Client.JobInfo]' cannot be serialized" thrown when running NerdDinner sample app

1,468 views
Skip to first unread message

Alex Maines

unread,
Oct 10, 2013, 6:31:39 PM10/10/13
to brightsta...@googlegroups.com
Hello everyone

I am new to BrightStar DB.  I have begun by trying out the NerdDinner sample.  I installed BS from the Windows Installer.  I configured the NerdDinner sample to run under IIS 7, and when I start the application, I get this exception, thrown by the constructor of my data context.

Type 'System.Threading.Tasks.Task`1[BrightstarDB.Client.JobInfo]' cannot be serialized


I saw a similar exception when running my own web application.

Has anyone on the Group come across this (I could find nothing on Google itself).  I can't see anything wrong with the configuration.

Thanks

Alex

Below is the full Gold Screen of Death stack trace

Exception Details: System.Runtime.Serialization.InvalidDataContractException: Type 'System.Threading.Tasks.Task`1[BrightstarDB.Client.JobInfo]' 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.

Source Error:

Line 59:     	/// connection string retrieved from the configuration.
Line 60:     	/// </summary>
Line 61:     	public NerdDinnerContext() : base(TypeMappings)
Line 62:     	{
Line 63:     		InitializeContext();

Source File: C:\Program Files (x86)\BrightstarDB\Samples\Server\NerdDinner\BrightstarDB.Samples.NerdDinner\Models\NerdDinnerContext.cs    Line: 61

Stack Trace:

[InvalidDataContractException: Type 'System.Threading.Tasks.Task`1[BrightstarDB.Client.JobInfo]' 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.]
   System.Runtime.Serialization.DataContractCriticalHelper.ThrowInvalidDataContractException(String message, Type type) +1184850
   System.Runtime.Serialization.DataContractCriticalHelper.CreateDataContract(Int32 id, RuntimeTypeHandle typeHandle, Type type) +787
   System.Runtime.Serialization.DataContractCriticalHelper.GetDataContractSkipValidation(Int32 id, RuntimeTypeHandle typeHandle, Type type) +117
   System.Runtime.Serialization.XsdDataContractExporter.GetSchemaTypeName(Type type) +85
   System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.CreatePartInfo(MessagePartDescription part, OperationFormatStyle style, DataContractSerializerOperationBehavior serializerFactory) +48
   System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.CreateMessageInfo(DataContractFormatAttribute dataContractFormatAttribute, MessageDescription messageDescription, DataContractSerializerOperationBehavior serializerFactory) +708
   System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter..ctor(OperationDescription description, DataContractFormatAttribute dataContractFormatAttribute, DataContractSerializerOperationBehavior serializerFactory) +570
   System.ServiceModel.Description.DataContractSerializerOperationBehavior.GetFormatter(OperationDescription operation, Boolean& formatRequest, Boolean& formatReply, Boolean isProxy) +308
   System.ServiceModel.Description.DataContractSerializerOperationBehavior.System.ServiceModel.Description.IOperationBehavior.ApplyClientBehavior(OperationDescription description, ClientOperation proxy) +65
   System.ServiceModel.Description.DispatcherBuilder.BindOperations(ContractDescription contract, ClientRuntime proxy, DispatchRuntime dispatch) +199
   System.ServiceModel.Description.DispatcherBuilder.BuildProxyBehavior(ServiceEndpoint serviceEndpoint, BindingParameterCollection& parameters) +430
   System.ServiceModel.Channels.ServiceChannelFactory.BuildChannelFactory(ServiceEndpoint serviceEndpoint, Boolean useActiveAutoClose) +102
   System.ServiceModel.ChannelFactory.CreateFactory() +46
   System.ServiceModel.ChannelFactory.OnOpening() +31
   System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +612
   System.ServiceModel.ChannelFactory.EnsureOpened() +97
   System.ServiceModel.ChannelFactory`1.CreateChannel(EndpointAddress address, Uri via) +477
   System.ServiceModel.ClientBase`1.CreateChannel() +57
   System.ServiceModel.ClientBase`1.CreateChannelInternal() +40
   System.ServiceModel.ClientBase`1.get_Channel() +411
   BrightstarDB.Client.BrightstarWcfServiceClient.DoesStoreExist(String storeName) +51
   BrightstarDB.Client.BrightstarServiceClient.DoesStoreExist(String storeName) +117
   BrightstarDB.EntityFramework.BrightstarEntityContext.AssertStoreFromConnectionString(ConnectionString connectionString) +183
   BrightstarDB.EntityFramework.BrightstarEntityContext..ctor(EntityMappingStore mappings, String updateGraphUri, IEnumerable`1 datasetGraphUris, String versionGraphUri) +159
   BrightstarDB.Samples.NerdDinner.Models.NerdDinnerContext..ctor() in C:\Program Files (x86)\BrightstarDB\Samples\Server\NerdDinner\BrightstarDB.Samples.NerdDinner\Models\NerdDinnerContext.cs:61
   BrightstarDB.Samples.NerdDinner.Controllers.HomeController..ctor() in C:\Program Files (x86)\BrightstarDB\Samples\Server\NerdDinner\BrightstarDB.Samples.NerdDinner\Controllers\HomeController.cs:13

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache) +117
   System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) +247
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +106
   System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +176

[InvalidOperationException: An error occurred when trying to create a controller of type 'BrightstarDB.Samples.NerdDinner.Controllers.HomeController'. Make sure that the controller has a parameterless public constructor.]
   System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +383
   System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +690
   System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +347
   System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +546
   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +268
   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +141
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +80
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +405
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375


Khalil Ahmed

unread,
Oct 11, 2013, 8:25:02 AM10/11/13
to brightsta...@googlegroups.com
Hi Alex,


I guess that the last time that I generated the WCF client code, it was with .NET 4.5 tooling - I hadn't realised it would cause backwards compatibility issues. 

Interestingly the app works OK for me if I run the NerdDinner sample from Visual Studio using the VS Development Server and also if I host the app in IIS (but I have IIS 8 on a Windows 8 machine). The app pool I am using has the .NET Framework configured as "v4.0", but I guess on Windows 8 that may be actually mapped to .NET 4.5.

I'll see if I can put together a hotfix for the 1.4 release that only generates the synchronous APIs because we don't actually use those task-based async APIs anyway and it would be better to remain compatible with IIS 7.

Of course, all this pain will go away when the new RESTful service is ready. Yay!

Cheers

Kal





--
You received this message because you are subscribed to the Google Groups "BrightstarDB Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brightstardb-us...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Kal Ahmed
Director, Networked Planet Limited
e: kal....@networkedplanet.com
w: www.networkedplanet.com

Khalil Ahmed

unread,
Oct 11, 2013, 8:53:05 AM10/11/13
to brightsta...@googlegroups.com
OK, I have rebuild the 1.4 release with the WCF client re-generated without the async methods. Hopefully this will fix your issue but I have no machine with IIS 7 on it to try it out. So can you please grab the updated installer from here: https://brightstardb.codeplex.com/releases/view/113310 (the version number for this release is 1.4.41011) and try it out for me. If it works OK for you I'll make this the recommended 1.4 release for BrightstarDB.

Cheers

Kal

Alex Maines

unread,
Oct 11, 2013, 2:10:44 PM10/11/13
to brightsta...@googlegroups.com
Kal

You're a gent and a scholar - works perfectly, first time.

Thanks for turning this around so quickly.  I'm looking forward to becoming better acquainted with your product.

Best

Alex


You received this message because you are subscribed to a topic in the Google Groups "BrightstarDB Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/brightstardb-users/YM9UmL5H2Eg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to brightstardb-us...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--
Alex Maines, software engineer, Brighton
Specialist in n-tier enterprise web application architecture and development
C#, ASP.Net MVC, jQuery, DI, TDD, relational database design
m: 07912 665531
e: alexmaines.so...@gmail.com
b: abstract-toast.blogspot.co.uk

Khalil Ahmed

unread,
Oct 12, 2013, 5:17:55 AM10/12/13
to brightsta...@googlegroups.com
Hi Alex,

Glad it worked! I'll update the NuGet packages and codeplex project page to make this the "official" 1.4 release.

Cheers

Kal
Reply all
Reply to author
Forward
0 new messages