Having a hard time updating a relation

I have an object in my program that doesnt seem to want to update one of its relations. I have an object (‘ModelYearSpec’) that has a 1->N relation to ‘Car’ objects. In my .NET code the ModelYearSpec object uses a List<Car> to handle this relation. At one point I make a new Car object, save it so it has an objectId, then add it to the list in the ModelYearSpec, then when I try to save the ModelYearSpec I get a few different types of errors, apparently randomly.

One says: “Version is disabled or provided wrong application info (application id or secret key)” which seems really odd because everything else, including updating relations and making new objects and stuff seems to work.

Another one was talking about not being able to cast a hashmap to something else in the weborb.dll or something (I cant replicate this suddenly…)

Another one is a “java.lang.ClassCastException” that doesnt really give me anymore info other than that it involve ‘Server.Processing’

These varying errors have all occurred while Im trying to reproduce the same issue, so im not sure whats up. Im not changing the code on the client side between attempts…

Simply put I want to make new ‘Car’ object, which has relations within it that appear to created just fine, and add it to a ‘ModelYearSpec’ which doesnt appear to be working.

Heres that other error:

java.lang.ClassCastException: java.util.HashMap cannot be cast to weborb.v3types.V3Message

Hi Matthew,

We just updated the build of the SDK for .NET on our site. Could you please grab a copy and try it again? The new build should be much easier to work with. There is only one assembly (Backendless.dll) and no additional config files are needed.

Please let me know if you still run into a problem with the latest build.

Regards,
Mark

Im definitely already using a version that only requires one .dll though im not sure if its the newest one. Ill make sure it is as soon as im back.

As always thanks for the amazingly fast response time!

Yeah it looks like I’ve got the most recent version.

Got it here: https://github.com/Backendless/.NET-SDK/tree/master/Backendless/Bin/NET_40/Debug

Ok, thanks for confirming. I asked because you mentioned weborb.dll which is not used anymore. Is the problem with update intermittent or happens every time now?

Its happening every time.

Also my AppID is: E97D1C37-02A6-7BE0-FFD0-EED613EC7B00

Not sure if thats a thing you need though

No, I do not need the app id (yet). I’d like to try the same thing though with your object model. Could you please attach your Car and ModelYearSpec classes?

This has all of the types used. I removed my private key data and whatnot as well.

BackendValues.zip (712B)

Matthew,

We were able to reproduce all the errors you mentioned and are working on a fix.

Regards,
Mark

Hi Matthew,

The fixes are in. You can download the latest SDK from our website or grab it from github:

Here’s the code which tests the use case you described:

static void Main( string args )

{

  Backendless.InitApp( APPID, SECRET, "v1" );
  // create and save one spec with a car.
  // this is needed so there is one saved car in the backend

  ModelYearSpec spec = createMakeModelSpec();

  ModelYearSpec updatedSpec = Backendless.Data.Of&lt;ModelYearSpec&gt;().Save( spec );

  System.Console.WriteLine( "spec saved " + updatedSpec.objectId );




  // retrieve an existing car

  Car existingCar = retrieveFirstCar();




  // create a new spec object

  ModelYearSpec anotherSpec = createMakeModelSpec();




  // add existing car to a new spec. Now there is an existing car
  // in it and a new one.

  anotherSpec.Cars.Add( existingCar );




  // save the new spec with a reference to the existing car

  updatedSpec = Backendless.Data.Of&lt;ModelYearSpec&gt;().Save( anotherSpec );

  System.Console.WriteLine( "spec saved " + updatedSpec.objectId );

}




private static Car retrieveFirstCar()

{

  return Backendless.Data.Of&lt;Car&gt;().FindFirst();

}




private static ModelYearSpec createMakeModelSpec()

{

  ModelYearSpec spec = new ModelYearSpec();

  spec.Make = new Make();

  spec.Make.Name = "Honda";




  spec.Model = new Model();

  spec.Model.Name = "Accord";




  spec.Year = 2010;

  spec.AvailableFeatures = new List&lt;AvailableFeature&gt;();

  AvailableFeature feature = new AvailableFeature();

  feature.Feature = new Feature();

  feature.Feature.Name = "Cruise Control";

  spec.AvailableFeatures.Add( feature );




  spec.Cars = new List&lt;Car&gt;();

  Car car = new Car();

  car.EdmundsStyleID = "1111111";

  car.ExtantFeatures = new List&lt;ExtantFeature&gt;();

  ExtantFeature extantFeature = new ExtantFeature();

  extantFeature.Feature = new Feature();

  extantFeature.Feature.Name = "Radio";

  car.ExtantFeatures.Add( extantFeature );

  car.Trim = "Sports Trim";

  car.VIN = "1111111111111111111111";

  spec.Cars.Add( car );




  return spec;

}

Awesome its working perfectly now thanks guys!