If you are putting TaskService inside a using clause like the following, you cannot use the variable outside the brackets.
using (TaskService ts = new TaskService())
{
// All references to "ts" must be here. Outside of the brackets for the using clause, any reference to "ts" will cause errors.
}
If you hold onto an instance of TaskService, then you must instantiate it and dispose of it manually.class MyClass : IDisposable
{
private TaskService ts;
public MyClass()
{
ts = new TaskService();
}
void Dispose()
{
ts.Dispose();
ts = null;
}
public void DoSomething()
{
ts.RootFolder.CreateFolder("NewFolder");
}
}