ResultsetFields in WCF

Posts   
 
    
Jowen
User
Posts: 47
Joined: 06-Feb-2007
# Posted on: 19-Feb-2007 11:44:05   

Hi

First some info: - Version: LLBLGen Pro 2.0.0.0 - RTL: 2.0.7.209 - DB: SQL 2005 - Template: Adapter with .Net 2.0

I want to send a ResultsetFields object across a wire using WCF (using tcp-binding). I've already managed to successfully transfer Entity and EntityCollection objects. When I want to use the ResultsetFields object in a method, and generate the proxy, there's a conflict with the added code in the proxy (the partial class ResultsetFields) and the existing code in the helperclass.

To isolate the issue, I defined a really simple method:


namespace WcfInterfaces
{
    [ServiceContract]
    public interface IGenService
    {
        [OperationContract]
        void FetchTypedList( ResultsetFields fields );
    }
}

(this method is not actually being used. In the end, I want to call something like DataTable FetchTypedList( ResultsetFields fields, IGroupByCollection groupByClause, IRelationPredicateBucket relation ) )

The generated proxy looks like this:


namespace DataAccessLayer.HelperClasses
{
    using System;
    
    
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
    [System.SerializableAttribute()]
    public partial class ResultsetFields : object, System.Runtime.Serialization.ISerializable
    {
        
        private System.Runtime.Serialization.SerializationInfo info;
        
        public ResultsetFields(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
        {
            this.info = info;
        }
        
        public System.Runtime.Serialization.SerializationInfo SerializationInfo
        {
            get
            {
                return this.info;
            }
            set
            {
                this.info = value;
            }
        }
        
        public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
        {
            if ((this.SerializationInfo == null))
            {
                return;
            }
            System.Runtime.Serialization.SerializationInfoEnumerator enumerator = this.SerializationInfo.GetEnumerator();
            for (
            ; enumerator.MoveNext(); 
            )
            {
                System.Runtime.Serialization.SerializationEntry entry = enumerator.Current;
                info.AddValue(entry.Name, entry.Value);
            }
        }
    }
}


[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(ConfigurationName="IGenService")]
public interface IGenService
{   [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IGenService/FetchTypedList", ReplyAction="http://tempuri.org/IGenService/FetchTypedListResponse")]
    void FetchTypedList(DataAccessLayer.HelperClasses.ResultsetFields fields);
}

The exact error message is:


The type 'DataAccessLayer.HelperClasses.ResultsetFields' in 'c:\Develop\Source\Library\Database\proxy.cs' conflicts with the imported type 'DataAccessLayer.HelperClasses.ResultsetFields' in 'c:\Develop\Source\AppName\DatabaseGeneric\bin\Debug\DataAccessLayer.dll'. Using the one in 'c:\Develop\Source\Library\Database\proxy.cs'

I've searched on this forum with the keywords ResultsetFields and webservice or wcf but I didn't find any results. So I have the feeling it shouldnt be any problem to perform this action...On the other hand, There's not much I can do wrong really.

Can you help me out here?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39862
Joined: 17-Aug-2003
# Posted on: 19-Feb-2007 22:52:52   

You get the class re-generated by the proxy stubber in wcf. (hence the re-definition of the class in teh proxy.cs).

I think you can avoid this by adding [ServiceKnownType(typeof(ResultsetFields))] to the servicecontract interface

Frans Bouma | Lead developer LLBLGen Pro
Jowen
User
Posts: 47
Joined: 06-Feb-2007
# Posted on: 20-Feb-2007 20:31:43   

Otis wrote:

You get the class re-generated by the proxy stubber in wcf. (hence the re-definition of the class in teh proxy.cs).

I think you can avoid this by adding [ServiceKnownType(typeof(ResultsetFields))] to the servicecontract interface

Unfortunately, that doesnt work. On the contrary, that ensures the regeneration of the class. Even when I don't have the param, but do have that [ServiceKnownType] attribute, the class is regenerated.

But I fixed it already... First I tried to pass the actual object, but that didnt work out for me. Now I'm passing the IEntityFields2 interface, and that works fine simple_smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39862
Joined: 17-Aug-2003
# Posted on: 20-Feb-2007 21:21:00   

Hmm, as when I added that attribute I didn't get any stubs and it works fine. Oh well... simple_smile

Frans Bouma | Lead developer LLBLGen Pro
caffreys
User
Posts: 65
Joined: 25-Jan-2009
# Posted on: 05-Jun-2010 02:26:19   

I'm also trying to pass a ResultsetFields definition between services but can't quite figure out how to avoid the usual known types issue.

if I add [ServiceKnownType(typeof(ResultsetFields))] to my interface then the following exception is raised:


There was an error while trying to serialize parameter http://Exalt.Task.Server.Data:fields. The InnerException message was 'Type 'System.Collections.ArrayList' with data contract name 'ArrayOfanyType:http://schemas.microsoft.com/2003/10/Serialization/Arrays' is not expected. Consider using a DataContractResolver or 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.

I've tried also passing IEntityFields2 instead with similar results.

My intention is to have the client request some reporting criteria, i.e. date/time, range etc. and pass the request to the BL service. This service assembles the resultset fields, grouping, sorting, paging etc. and passes to the DL service who performs the projection onto DTOs which are returned to the BL and finally to the client.

Thanks.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 05-Jun-2010 05:12:49   

I think you should add ResulsetFields, EntityFields2 and ArrayOfanyType to KnownTypes in your Contract. At least that is what the error is saying.

Please open a new thread as this is very outdated/old one and we don't want to hijack threads. When you post new thread also specify LLBLGen version and runtime library version and your data contract (http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7717).

David Elizondo | LLBLGen Support Team