This project is read-only.

DependencyWalker can crash killing app. Added a switch to skip the dependency walking code


I didn't spend anytime determining the cause of the crash, other than it being a bug inside of the DependencyWalker. I suspect it is caused by the use of linked servers inside of some sprocs I have.
As a fix, I added a switch to skip the dependency tree code. I've attached the changes as a unified diff file.
Great app, thanks for making it.

file attachments


michaelplevy wrote Nov 14, 2012 at 6:47 PM

This fix seemed to mess up the order object were created in the export script and so the script could not be run to recreate the objects without error. However, while rebuilding the app to apply this fix, I updated the app to .NET 4 to be compatible with the SQLDMO on my machine (I couldn't get it to compile otherwise) and the app now seems to no longer throw the dependency walker errors on my machine, even without using the /SkipDeps option.

michaelplevy wrote Nov 14, 2012 at 7:42 PM

Woops. Can I delete that last comment?

michaelplevy wrote Nov 14, 2012 at 11:37 PM

Your fix in the attached diffs.txt did not work for me because objects weren't scripted in the correct dependency order.

I took a different approach which is to handle the exception if an dependent object cannot be retrieved by GetSmoObject.

As explained in, I was having a problem becuase the Sql system stored proc dbo.sp_upgraddiagrams depends on the table dtproperties which is a SQL 2005 table and does not exist in SQL 2008. Since stored procedures can be compiled with their dependencies in place, another approach to fixing this would be to now follow the dependency tree for stored procedure objects. I didn't go down that path, though it may be a better choice.

Here is my fix as a unified diff:

Index: Program.cs

--- Program.cs (revision 31329)
+++ Program.cs (working copy)
@@ -247,9 +247,20 @@
                     DtnSmo sortUnit = new DtnSmo();
                     sortUnit.dependencyTreeNode = dependencyTreeNodeChild;
  • sortUnit.namedSmoObject = (NamedSmoObject)server.GetSmoObject(dependencyTreeNodeChild.Urn);
  • Children.Add(sortUnit);
  • dependencyTreeNodeChild = dependencyTreeNodeChild.NextSibling;
  • try
  • {
  • sortUnit.namedSmoObject = (NamedSmoObject)server.GetSmoObject(dependencyTreeNodeChild.Urn);
  • Children.Add(sortUnit);
  • }
  • catch (FailedOperationException failedOpEx)
  • {
  • // if you can't get the child, don't add it to the children list
  • }
  • finally
  • {
  • dependencyTreeNodeChild = dependencyTreeNodeChild.NextSibling;
  • }
             //Sort dependencies

wrote Feb 14, 2013 at 2:49 AM