What's new
  • Visit Rebornbuddy
  • Visit Resources
  • Visit API Documentation
  • Visit Downloads
  • Visit Portal
  • Visit Panda Profiles
  • Visit LLamamMagic

System.Runtime.Remoting.RemotingException

Amarthalion Raigar

New Member
Joined
Nov 7, 2015
Messages
8
Reaction score
0
Hi there,

As I wasn't satisfied with the current CollectItemsAtFarm() method, I tried to implement my own one :
- CollectItemsAtFarm() don't "pick" items (like thunderstruck trees)
- when items are on higher ground, the bot just keep on bumping on the cliff, like a retard

I managed to handle the "pick" problem by using the UseDoodadSkill() method on each item instead of CollectItemsAtFarm()
And I kinda managed to handle the cliff problem by implementing my own ComeTo method, using the glider (when the bot is struck) to climb the cliff

Now the only remaining problem is that I randomly get this kind of exception :
System.Runtime.Remoting.RemotingException : Object '/2fa53226_da41_42ba_b185_ec7d9c454712/ygiw+xfegmkhdinj7g2kpkhc_7.rem' has been disconnected or does not exist at the server. at ArcheBuddy.Bot.Classes.SpawnObject.get_X()

Technical explanation on this error => This is because the Lifetime management on the server side disconnects the object when its lease expires, to allow GC to collect it. If you try to use it from the client side, you will get an Exception, even if it has not been GC'd on the server yet (e.g. because there still is another reference to it) but the lease has expired. This is to avoid unpredictable behaviour.

So, the longer the delay beetween the getDoodads() method call and the UseDoodadSkill() method call, and the higher the chances to get this exception
I want to avoid to be forced to scan all the doodads everytime I want to collect just one (I don't know if this request is local only or sent to the server) : it would be the same as asking for a ban :s
ATM, I even get this Exception when I try to collect 25 doodads on a gazebo which take less than 1 minute...
It seems weird that the lifetime of the AB proxies are this short

Has someone already experienced this kind of Exception and found a way to gracefully deal with it ?
Or at least some way to understand why or when this kind of Exception is raised, to be able to implement a workaround by myself
 
Last edited:
Hi, this means that the object you fetched with getDoodads() no longer exists, and thus when you try UseDoodadSkill(), it's basically calling an object that was removed from memory throwing that exception.

Example:

var doodads = GetDoodads() -> 10 flowers. (In the meantime, 1 flower was removed)

UseDoodadSkill(...doodads[0]...) <-- Removed flower, throws.
 
Hey,

I edited my initial question to add the technical explanation I found here : http://stackoverflow.com/questions/...ted-or-does-not-exist-at-the-server-exception

My main problem is that the doodad fetched still exists (in game)
If I take your example :

var doodads = GetDoodads() -> 10 flowers.
UseDoodadSkill(...doodads[0]...) <- ok
UseDoodadSkill(...doodads[1]...) <- ok
....
UseDoodadSkill(...doodads[6]...) <- throws although the flower is still here
var doodads = GetDoodads() -> 4 flowers. (the 6 first flowers were successfully harvested)
UseDoodadSkill(...doodads[0]...) <- ok although it throwed 1 sec ago
 
Hey,

I edited my initial question to add the technical explanation I found here : http://stackoverflow.com/questions/...ted-or-does-not-exist-at-the-server-exception

My main problem is that the doodad fetched still exists (in game)
If I take your example :

var doodads = GetDoodads() -> 10 flowers.
UseDoodadSkill(...doodads[0]...) <- ok
UseDoodadSkill(...doodads[1]...) <- ok
....
UseDoodadSkill(...doodads[6]...) <- throws although the flower is still here
var doodads = GetDoodads() -> 4 flowers. (the 6 first flowers were successfully harvested)
UseDoodadSkill(...doodads[0]...) <- ok although it throwed 1 sec ago

When you cast DoodadSkill, are you matching that doodad then against something?

Like:

var doodad;

UseDoodadSkill(doodad);

if(doodad == something) ?? That would cause such throw.
 
Last edited:
Nope

Here is the method I use to get the harvestable doodads on a given farm :
Code:
private IEnumerable<DoodadObject> GetHarvestablePlants(Db.FarmRow farm)
{
    return getDoodads().Where(doodad => doodad.plantZoneId == farm.PlantZoneId && doodad.type != BotTypes.Housing && doodad.dbAlmighty != null && doodad.dbAlmighty.growthTime != 0 && doodad.growthTime == 0);
}

the method I use to Harvest :
Code:
private bool Harvest(IEnumerable<DoodadObject> plants)
{
    foreach (var plant in plants)
    {
        if (me.laborPoints < 20) return LogError("Out of labor");
        var skill = plant.getUseSkills().FirstOrDefault();
        if (skill != null)
        {
            if (!UseDoodadSkill(skill.id, plant, true, plant.modelRadius))
            {
                Thread.Sleep(500);
                if (!UseDoodadSkill(skill.id, plant, true, plant.modelRadius)) LogError("Could not {0} the {1}", skill.name, plant.name);
            }
        }
    }
    return true;
}

and in my main method :

Code:
var plants = GetPlants(farm);
if (plants.Count() > 0)
{
    if (!Harvest(plants) return false;
}


As you can see, I only get the eligible doodads, then try to collect them once (twice if the first try fail) right after I fetched them
 
Can't say for sure, everything seems alright, although if (!UseDoodadSkill(skill.id, plant, true, plant.modelRadius)) LogError("Could not {0} the {1}", skill.name, plant.name); as a second cast, could be casting on a disconnected object. To figure out exactly where that's happening I suggest you try catching every line.
 
Sorry for being a little late, but I ran into the exact same problem & the 'solution' I found is just using catch methods as mentioned above.

Code:
foreach (Creature obj in getCreatures())
{
	try
	{
		// Do your stuff
		Log(obj.name);
	}
	catch (RemotingException)
	{ Log("Object didn't exist, skipping to the next in queue!"); continue; }
}

More information is here that does actually help understand it:

MSDN - Remoting Exception
MSDN - Runtime.Remoting
 
Back
Top