peass-ng/PEASS-ng · error · NotImplementedException
NotImplementedException
Error message
NotImplementedException
What it means
TaskFolderCollection.Add is part of the ICollection<TaskFolder> implementation but adding an existing folder object to the collection is impossible with the underlying Task Scheduler API, so it throws NotImplementedException. The library directs you to TaskFolder.CreateFolder instead, which actually creates a folder in the scheduler.
Source
Thrown at winPEAS/winPEASexe/winPEAS/TaskScheduler/TaskFolderCollection.cs:77
try
{
if (v2FolderList != null)
return parent.GetFolder(path);
if (v1FolderList != null && v1FolderList.Length > 0 && (path == string.Empty || path == "\\"))
return v1FolderList[0];
}
catch { }
throw new ArgumentException(@"Path not found", nameof(path));
}
}
/// <summary>Adds an item to the <see cref="ICollection{T}"/>.</summary>
/// <param name="item">The object to add to the <see cref="ICollection{T}"/>.</param>
/// <exception cref="System.NotImplementedException">
/// This action is technically unfeasible due to limitations of the underlying library. Use the <see
/// cref="TaskFolder.CreateFolder(string, string, bool)"/> instead.
/// </exception>
public void Add([NotNull] TaskFolder item) => throw new NotImplementedException();
/// <summary>Removes all items from the <see cref="ICollection{T}"/>.</summary>
public void Clear()
{
if (v2FolderList != null)
{
for (var i = v2FolderList.Count; i > 0; i--)
parent.DeleteFolder(v2FolderList[i].Name, false);
OnNotifyPropertyChanged(nameof(Count));
OnNotifyPropertyChanged(IndexerName);
CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
}
}
/// <summary>Determines whether the <see cref="ICollection{T}"/> contains a specific value.</summary>
/// <param name="item">The object to locate in the <see cref="ICollection{T}"/>.</param>
/// <returns>true if <paramref name="item"/> is found in the <see cref="ICollection{T}"/>; otherwise, false.</returns>
public bool Contains([NotNull] TaskFolder item)View on GitHub (pinned to 53fb989abc)
Solutions
- Use TaskFolder.CreateFolder(path) instead of Add
- Avoid APIs/initializers that call ICollection<T>.Add on SubFolders
- Implement custom code that checks collection capabilities before Add
Example fix
// before
ts.RootFolder.SubFolders.Add(newFolder);
// after
ts.RootFolder.CreateFolder("MyNewFolder"); Defensive patterns
Strategy: fallback
Try / catch
try { subFolders.Add(f); }
catch (NotImplementedException) { parent.CreateFolder(f.Name); } Prevention
- Never use Add/ICollection initializers on TaskFolderCollection
- Use TaskFolder.CreateFolder for folder creation
- Document that SubFolders is effectively read-only
When it happens
Trigger: Calling subFolders.Add(someTaskFolder) or passing the collection to code that calls Add (e.g. collection initializers, certain LINQ-to-collection helpers).
Common situations: Treating SubFolders like a List<TaskFolder>; using collection-initializer syntax on TaskService.RootFolder.SubFolders.
Related errors
- Index is not a valid index in the ActionCollection
- Specified argument was out of the range of valid values. (Pa
- Specified argument was out of the range of valid values. (Pa
- Path not found
- Specified argument was out of the range of valid values. (Pa
AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02).
Data as JSON: /api/errors/796e3adcb92e1745.
Report an issue: GitHub.