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.
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.
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?
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?
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<ModelYearSpec>().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<ModelYearSpec>().Save( anotherSpec );
System.Console.WriteLine( "spec saved " + updatedSpec.objectId );
}
private static Car retrieveFirstCar()
{
return Backendless.Data.Of<Car>().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<AvailableFeature>();
AvailableFeature feature = new AvailableFeature();
feature.Feature = new Feature();
feature.Feature.Name = "Cruise Control";
spec.AvailableFeatures.Add( feature );
spec.Cars = new List<Car>();
Car car = new Car();
car.EdmundsStyleID = "1111111";
car.ExtantFeatures = new List<ExtantFeature>();
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;
}