Hi Team.I am using Aspose.Tasks Python via .net for exporting to MPP.
I am trying to add task link and I am receiving this error.
link=prj.task_links.add(predecessor, successor)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Proxy error(ArgumentException): An item with the same key has already been added. Key: 21
The error message “An item with the same key has already been added. Key: 21” typically indicates that you are trying to add a task link that already exists in the collection. This can happen if you attempt to create a link between the same predecessor and successor tasks multiple times without removing the existing link first.
To resolve this issue, you can check if the task link already exists before adding it. Here’s a general approach you can follow:
Check Existing Links: Before adding a new link, iterate through the existing task links to see if a link between the specified predecessor and successor already exists.
Add Link Only if Not Exists: If the link does not exist, proceed to add it.
Here’s a sample code snippet that demonstrates this approach:
# Assuming 'project' is your Project object
# and 'predecessor' and 'successor' are your Task objects
# Check if the link already exists
link_exists = any(link.PredTask == predecessor and link.SuccTask == successor for link in project.TaskLinks)
if not link_exists:
# Add the task link if it does not exist
project.TaskLinks.Add(predecessor, successor)
else:
print("The task link already exists.")
This code checks for existing links before attempting to add a new one, which should help you avoid the error you are encountering.
If you continue to face issues, please ensure that the task IDs you are using are correct and that you are not inadvertently trying to create duplicate links.
Feel free to reach out if you need further assistance!
@vasiliy.sinitsyn
Task link is sometimes working and sometimes failing I am not understanding why its failing.Can I show u.Can we connect.There are no duplicate links as well.
@vasiliy.sinitsyn
Can u please speed up the process.Its already been 3 days.I need to make a decision whether to take this license or not.My temporary license is expiring.
looks like there is a problem in internal recalculations after task link is added.
We will investigate it further.
As a workaround you can turn off recalculations (it will also speed up creation of the project)
by setting calculation_mode to MANUAL before adding task links:
prj.calculation_mode = asp_tasks.CalculationMode.MANUAL
for dep_data in dependency_data:
# Print the predecessor and successor task data
[ ...]
and restoring it to AUTOMATIC after adding task links:
@sitha
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): TASKSNET-11408
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.