I have an Asset object that has a property AssignedSoftware, which is a collection.
I want to make sure that the same piece of Software is not assigned to an Asset more than once. In Add method I check to see if the Software already exist, and if it does, I want to throw an exception.
Is there a standard .NET exception that I should be throwing? Or does best practices dictate I create my own custom exception?
From the Class Library design guidelines for errors (http://msdn.microsoft.com/en-us/library/8ey5ey87(VS.71).aspx):
This seems like an "Object state invalid" scenario to me, so I’d pick InvalidOperationException over ArgumentException: The parameters are valid, but not at this point in the objects life.