From: Mr. Arnold on
Charles wrote:
> I am trying to modify a MSDN WCF sample, and am getting this error in my
> client app.
>
> "There was an error while trying to serialize parameter
> http://Microsoft.ServiceModel.Samples:obj. The InnerException message
> was 'Type 'Client.Form1' with data contract name
> 'Form1:http://schemas.datacontract.org/2004/07/Client' 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."


You're trying to send a form (class/object) that's a (form) to a WCF
service from a WCF client?

A form in not a serializable WCF data contract decorated with the proper
attributes that makes it such that WCF will accept it as a WCF data
contract and KnownType.

The best you could do was to XML serialize the object to create the
properties of the object in XML and send it as string and cast it back
to a know type on either the client or service side. All behavior of the
object is dropped (methods) and only properties are sent when an object
is sent between the WCF Client/Service.

What are you trying to do here?
From: Mr. Arnold on
Charles wrote:
> It doesn't have to be a form I pass. In fact, it wasn't originally, it
> was just a simple class object that implemented INotify.
>
> Suppose I had
>
> Class MyClass
>
> Implements INotify
>
> ...
>
> End Class
>
> and then in the form had
>
> Dim c as New MyClass
>
> Client.Register(c)
>
> How would I decorate MyClass in order for the client service to accept it?
>
> What I am trying to do is get the mechanism working for passing an
> object of type INotify to a WCF service. I could then call methods of
> INotify, or later raise events that MyClass would consume.
>
> Charles
>
>
>
> "Mr. Arnold" <Arnold(a)Arnold.com> wrote in message
> news:Ol4sylntKHA.5608(a)TK2MSFTNGP05.phx.gbl...
>> Charles wrote:
>>> I am trying to modify a MSDN WCF sample, and am getting this error in
>>> my client app.
>>>
>>> "There was an error while trying to serialize parameter
>>> http://Microsoft.ServiceModel.Samples:obj. The InnerException message
>>> was 'Type 'Client.Form1' with data contract name
>>> 'Form1:http://schemas.datacontract.org/2004/07/Client' 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."
>>
>>
>> You're trying to send a form (class/object) that's a (form) to a WCF
>> service from a WCF client?
>>
>> A form in not a serializable WCF data contract decorated with the
>> proper attributes that makes it such that WCF will accept it as a WCF
>> data contract and KnownType.
>>
>> The best you could do was to XML serialize the object to create the
>> properties of the object in XML and send it as string and cast it back
>> to a know type on either the client or service side. All behavior of
>> the object is dropped (methods) and only properties are sent when an
>> object is sent between the WCF Client/Service.
>>
>> What are you trying to do here?
>

You should understand Data Contract basics.

http://msdn.microsoft.com/en-us/library/ms733127.aspx

You should look at the classes/objects in VB and C# in the link that are
valid WCF serialized data contracts decorated properly objects that can
be sent between the WCF client and service.

You can have a class/object that has all kind of methods, events etc,
etc, which is called "behavior" -- behavior of the object. When the WCF
XML serialized data contract object is transmitted between the WCF
client and service, "behavior" is not transmitted, and it is dropped.
Only primitive types in the form of public properties of the object are
sent -- no behavior and only data in public properties are sent.

Or the object can have a collection objects in it that are proper WCF
data contract objects -- decorated correctly with the attributes --
prmitive.

So your object can have the methods, but only primitive data type
properties are going to be transmitted, and object behavior is dropped.

Therefore you must set some kind of primitive public property int, bool,
string, etc that indicates that a notification has been raised. You cast
the WCF data contract object back to its known object type object to
pick-up the behavior and act upon the behavior of the and public
properties of the object.

The known object say it Book.cs is a known object in IServcie as and
object type and to the SVC method something like this.

IService

Book GetBook();

void SaveBook(Book);

SVC Methods

public Book Getbook();
{
var book = dosomethingtogetbook(); // dosomething is returning Book
return book;
}

public void SaveBook(Book as thebook)
{
SaveBook(thebook) // a method
}


Client

var client = new client.

var book = client.GetBook();

You act upon the public properties and behavior of book.

cleint.SaveBook(book);


Of course Book.cs originates on the WCF service side.

HTH



From: Mr. Arnold on
sloan wrote:
> Well explained (<< comment geared to Mr. Arnold).
>
> I would point out this 3.5 SP1 specific detail .... since (in your
> searching) you'll probably find some older samples.
>
> http://www.pluralsight.com/community/blogs/aaron/archive/2008/05/13/50934.aspx
>

Now, I am working on WCF Web services and keeping session variables and
cache on the back-end Web servers used by the clients.

Keeping state for an application in the company I work for is like
pulling hen's teeth. I am almost ham-strung with session variables on
the front-end Web servers and not being able to use them.

But may be there is hope yet on the back-end servers through WCF Web
service. -:)