Check if a project exists before collecting referenced/referencing projects

Fix #1001752
Merge pull request #49 from dotta/issue/prevent-resource-exception-on-closed-referenced-projects

Check if a project exists before collecting referenced/referencing projects