Print Page | Close Window

More client projects connecting to one server

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2124
Printed Date: 29-Jul-2026 at 8:30pm


Topic: More client projects connecting to one server
Posted By: jkattestaart
Subject: More client projects connecting to one server
Date Posted: 03-Sep-2010 at 11:59am
I'n new to DevForce Silverlight and trying to test some scenario's.
 
The one i am testing now is a Claiburn Micro MVVM application using MEF.
this works ok, but now i added an extra siliverlight application to my solution with its own XAP, which is loaded when i click a button trough a MEF catalog functionality. This works ok until i want to reachs the server Devforce model.
It returns the following error. I already tried to add a suggested ServiceReferences.ClientConfig with no luck.
I think it has someting to do with accessing the webserver objects.
 
---
 
Query failed: IdeaBlade.EntityModel.EntityServerException: There was an error while trying to serialize parameter http://ideablade.com/EntityModel:entityQuerySurrogate - http://ideablade.com/EntityModel:entityQuerySurrogate . The InnerException message was 'Type 'IdeaBlade.EntityModel.EntityQueryProxy`1[[SKComCenter.Customer, SKComCenter.CustomerModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' with data contract name 'EntityQueryProxyOfCustomermuN0sGwD:http://ideablade.com/EntityModel' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.'.  Please see InnerException for more details. ---> System.ServiceModel.CommunicationException: There was an error while trying to serialize parameter http://ideablade.com/EntityModel:entityQuerySurrogate - http://ideablade.com/EntityModel:entityQuerySurrogate . The InnerException message was 'Type 'IdeaBlade.EntityModel.EntityQueryProxy`1[[SKComCenter.Customer, SKComCenter.CustomerModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' with data contract name 'EntityQueryProxyOfCustomermuN0sGwD:http://ideablade.com/EntityModel' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.'.  Please see InnerException for more details. ---> System.Runtime.Serialization.SerializationException: Type 'IdeaBlade.EntityModel.EntityQueryProxy`1



Replies:
Posted By: kimj
Date Posted: 08-Sep-2010 at 5:46pm
In order to send complex queries and their results between a client application and the BOS services, DevForce needs to discover the "known types" involved.  These types are the entity types in your domain model, plus any other types which you send between client and server.  Currently, DevForce will only find this information from the main application XAP, so if your domain model assembly is in a dynamically loaded XAP DevForce won't find it. 
 
There is currently not a workaround for this, other than to place your domain model in the main XAP, which may defeat what you're trying to do with MVVM and MEF.  We do have an open feature request to support this, but it's not currently on the schedule.


Posted By: jkattestaart
Date Posted: 22-Mar-2011 at 2:35pm

Is there any chance this feature will be available soon, now it is possible to load XAPs on demand.... in v6.0.8



Posted By: kimj
Date Posted: 22-Mar-2011 at 9:50pm
This should work with the dynamic module support introduced in 6.0.8.  Are you still seeing a problem?
 
We also have a DevForce-Caliburn application framework using MEF available on CodePlex if you're interested - http://devforcecaliburn.codeplex.com/ - http://devforcecaliburn.codeplex.com/


Posted By: skingaby
Date Posted: 04-May-2011 at 12:06pm
Yes.  I just finished upgrading to 6.0.9 and I am still getting this error.  Is there something I need to do in the config files to activate this feature?


Posted By: skingaby
Date Posted: 04-May-2011 at 12:16pm
I have a main app that is loading a separate module using MEF.  The separate module has its own EntityModel diagram and its own client.SL and server DLL's.  The web.config for the host web app has the EDMKEYs set up for both the main app and the separate module.  The client DLL is getting loaded from it's XAP correctly and the call is being made as shown below.  ExecuteBaseQuery is inside the SL client of the separate module.  It is called from the main app.  It, in turn, uses the seperate module's EntityManager to get a query and calls ExecuteAsync on it.  The BaseQueryCallback method is reached and the code fails on the line "var queryResults = args.Results" because args.Results contains the error shown below.
public void ExecuteBaseQuery(Action<QueryExecutionResult> userCallback, object userState = null)
        {
            this.BuildBaseQuery().ExecuteAsync(this.BaseQueryCallback, new QueryExecutionPayload(userCallback, userState));
        }
 	public IEntityQuery BuildBaseQuery()
        {
            return ((EdiTransactionReportModelContainer)this.EntityManager).EdiTransactionViews;
        }
 
        public void BaseQueryCallback(EntityQueryOperation args)
        {
            var payload = (QueryExecutionPayload) args.UserState;
            var queryResults = args.Results;
            var result = new QueryExecutionResult(queryResults, payload.UserState);
            payload.UserCallback.Invoke(result);
        }
My error messages are:

There was an error while trying to serialize parameter http://ideablade.com/EntityModel:entityQuerySurrogate. The InnerException message was 'Type 'IdeaBlade.EntityModel.EntityQueryProxy`1[[EdiTransactionReport.EdiTransactionView, EdiTransactionReport, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' with data contract name 'EntityQueryProxyOfEdiTransactionViewaJAXY_PMZ:http://ideablade.com/EntityModel' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.'.  Please see InnerException for more details.

and

{System.ServiceModel.CommunicationException: There was an error while trying to serialize parameter http://ideablade.com/EntityModel:entityQuerySurrogate. The InnerException message was 'Type 'IdeaBlade.EntityModel.EntityQueryProxy`1[[EdiTransactionReport.EdiTransactionView, EdiTransactionReport, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' with data contract name 'EntityQueryProxyOfEdiTransactionViewaJAXY_PMZ:http://ideablade.com/EntityModel' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.'.  Please see InnerException for more details. ---> System.Runtime.Serialization.SerializationException: Type 'IdeaBlade.EntityModel.EntityQueryProxy`1[[EdiTransactionReport.EdiTransactionView, EdiTransactionReport, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' with data contract name 'EntityQueryProxyOfEdiTransactionViewaJAXY_PMZ:http://ideablade.com/EntityModel' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeAndVerifyType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, Boolean verifyKnownType, RuntimeTypeHandle declaredTypeHandle)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithXsiType(XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle objectTypeHandle, Type objectType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle, Type declaredType)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerialize(XmlWriterDelegator xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle)
   at WriteConstantExpressionBlockToXml(XmlWriterDelegator , Object , XmlObjectSerializerWriteContext , ClassDataContract )
   at System.Runtime.Serialization.ClassDataContract.WriteXmlValue(XmlWriterDelegator xmlWriter, Object obj, XmlObjectSerializerWriteContext context)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.WriteDataContractValue(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeAndVerifyType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, Boolean verifyKnownType, RuntimeTypeHandle declaredTypeHandle)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithXsiType(XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle objectTypeHandle, Type objectType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle, Type declaredType)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerialize(XmlWriterDelegator xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle)
   at WriteSerializedExpressionToXml(XmlWriterDelegator , Object , XmlObjectSerializerWriteContext , ClassDataContract )
   at System.Runtime.Serialization.ClassDataContract.WriteXmlValue(XmlWriterDelegator xmlWriter, Object obj, XmlObjectSerializerWriteContext context)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.WriteDataContractValue(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithoutXsiType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerialize(XmlWriterDelegator xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle)
   at WriteEntityQuerySurrogateToXml(XmlWriterDelegator , Object , XmlObjectSerializerWriteContext , ClassDataContract )
   at System.Runtime.Serialization.ClassDataContract.WriteXmlValue(XmlWriterDelegator xmlWriter, Object obj, XmlObjectSerializerWriteContext context)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.WriteDataContractValue(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeAndVerifyType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, Boolean verifyKnownType, RuntimeTypeHandle declaredTypeHandle)
   at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithXsiTypeAtTopLevel(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle originalDeclaredTypeHandle)
   at System.Runtime.Serialization.DataContractSerializer.InternalWriteObjectContent(XmlWriterDelegator writer, Object graph)
   at System.Runtime.Serialization.DataContractSerializer.InternalWriteObject(XmlWriterDelegator writer, Object graph)
   at System.Runtime.Serialization.XmlObjectSerializer.WriteObjectHandleExceptions(XmlWriterDelegator writer, Object graph)
   at System.Runtime.Serialization.XmlObjectSerializer.WriteObject(XmlDictionaryWriter writer, Object graph)
   at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.SerializeParameterPart(XmlDictionaryWriter writer, PartInfo part, Object graph)
   --- End of inner exception stack trace ---
   at IdeaBlade.EntityModel.EntityServerProxy.ExecFunc[T](Func`1 func, Boolean funcWillHandleException)
   at IdeaBlade.EntityModel.EntityServerProxy.ExecuteOnServer[T](Func`1 func, Boolean funcWillHandleException)
   at IdeaBlade.EntityModel.EntityServerProxy.Fetch(SessionBundle bundle, IEntityQuerySurrogate query)
   at IdeaBlade.EntityModel.EntityManager.AsyncFetchWorker(AsyncEventArgs asyncArgs)}


Posted By: kimj
Date Posted: 04-May-2011 at 7:51pm
You have to tell DevForce about the new content too, by calling CompositionHost.Add.  Are you doing this and still seeing the error?
 
Here's more info - http://drc.ideablade.com/xwiki/bin/view/Documentation/on-demand-discovery - http://drc.ideablade.com/xwiki/bin/view/Documentation/on-demand-discovery
 


Posted By: skingaby
Date Posted: 05-May-2011 at 7:46am
Woohoo!  I have data now!  Thanks for the tip kimj.  Once again you have pointed me in the right direction.
In my implementation, I added one line that registers the downloaded component with Ideablade and now the unknown type issue is resolved. 
In the end, I have data in a grid in the host app, from an EF Model that was dynamically downloaded and dynamically queried, where the host app has no reference to the query builder and knows nothing about the EF model or resultant type that is displayed in the grid.  Cool.
Here's the code.  The one line is highlighted pink.

	[Import]
        public IQueryBuilder QueryBuilder { getset; }
 
        private void GetQueryBuilderAsync()
        {
            if (this.IsInDesignMode)
                return;
            
            //use MEF to get a catalog of the specific report query builder
            var catalog = new DeploymentCatalog(this.SelectedReportType.ReportSpecificXap);
            catalog.DownloadCompleted += this.CatalogDownloadCompleted;
            catalog.DownloadAsync();
        }
 
        void CatalogDownloadCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            var catalog = (DeploymentCatalog)sender;
            IdeaBlade.Core.Composition.CompositionHost.Add(catalog);
            var container = new CompositionContainer(catalog);
            container.ComposeParts(this);
            this.RaisePropertyChanged("ShowFiltersRow");
        }



Print Page | Close Window