Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The closed type Component does not have a corresponding IsMultimedia settable property

I have generated a service reference in Visual Studio to CD OData webservice on SDL Tridion 2011 SP1 and everything seems to be working fine, but when I request specific component with code like this:

ContentDeliveryService cdService1 = new ContentDeliveryService(new Uri("http://xxx:81/odata.svc"));
var item =  cdService1.Components.Where(p => p.ItemId == 29 && p.PublicationId == 1).First();
Console.WriteLine(item.ItemId);

It is throwing exception:

 The closed type ConsoleApplication1.CdService.Component does not have a corresponding IsMultimedia settable property.

Does anybody know hot fix this?

like image 810
Andrey Marchuk Avatar asked May 08 '12 08:05

Andrey Marchuk


2 Answers

I assume the problem is that the server sends you a property which the client doesn't know about (the IsMultimedia property). You can confirm this by using for example Fiddler to see the response from the server. It might happen if the Component type on the server is marked as open (can have more properties than those declared). The client library doesn't support open types directly today.

If you don't need the IsMultimedia property on the client you can suppress this error by setting cdService1.IgnoreMissingProperties = true.

If you do need the IsMultimedia property on the client, the Component class generated for you should be a partial class, so you can add the property IsMultimedia to it manually. Then it should also work.

like image 94
Vitek Karas MSFT Avatar answered Oct 12 '22 12:10

Vitek Karas MSFT


This appears to be a defect that will be fixed in the next version. Setting IgnoreMissingProperties works, the other solution is to open Reference.cs file of this reference and change public global::System.Nullable<bool> Multimedia property to IsMultimedia

like image 40
Andrey Marchuk Avatar answered Oct 12 '22 11:10

Andrey Marchuk