The reason for the error is that the code loads objects into two different sessions, and then the objects loaded in one session adds to the collection of objects loaded in another session. This is forbidden, because the session should monitor the state of the objects and be able at any time to answer the question, for example, which objects have been changed. Therefore, alien objects (loaded in another session) are rejected when trying to add them to the collection.
The exception points to the place in the code where it occurs, and the error message indicates its cause. In order to correct the error, you need to find the code that loads the objects involved in the operation, and modify it so that all the objects involved in the operation are loaded in one session.
If for any significant reason you cannot control the loading of objects and ensure that they are loaded in one session, then in order to add an object loaded in another session to the collection, you need to get the object loaded in the desired session using the Session.GetObjectByKey method. With this approach, changes that have not yet been saved will not be applied to the object loaded in another session. Therefore, this approach is not always applicable, and it is good practice to use only one session to load the objects required in the current operation.
BVVGlobalwhatBVVGlobal,oXpoandGet_Session(). Give a minimal reproducible example - Pavel Mayorov