I had created a very small DLL in C# using Visual Studio Express 2013, Update 3, and if I run Revit 2013 with code that that had built, it worked fine.
I have since upgraded to Visual Studio 2013 Community Edition, Update 4 to get the benefit of debugging as suggested by the Building Coder blog. Debugging certainly works - but my code now does not. It now throws an exception when trying to use TaskDialog saying it should be in the main thread (it worked before), it will no longer load custom families (it did before), and although it still creates ribbon content they are now disabled (they were enabled before). The DLL *has* been fully recompiled with the new Studio.
Taking LoadFamily() as an example, this is my code:
private void loadFamilies(Document doc) { string filespec = Directory.GetParent(Assembly.GetExecutingAssembly().Location) + @"\TFRectangular.rfa" ; Family family = null ; try { if (!doc.LoadFamily(filespec, out family) ) throw new Exception("Unable to load " + filespec); } catch (Exception e) { TaskDialog.Show("MyCompany", "Family load failed: " + e.Message, TaskDialogCommonButtons.Ok); return ; } } void onNewDocument(Document doc) { Transaction t = new Transaction(doc, "Performing Document Loading Procedure" ); t.Start(); loadFamilies(doc); t.Commit(); } void onDocumentCreated(object sender, Autodesk.Revit.DB.Events.DocumentCreatedEventArgs e) { onNewDocument(e.Document); }
The family still loads into Revit manually. I don't get an exception from LoadFamily(); it simply returns false and I don't know how to get error information back (assuming that is even possible, since it suggests that it uses the exception mechanism to indicate errors).
Any suggestions as to why updating Visual Studio should break everything? It's the same version of Revit and the references in the project are therefore still correct as they came from Revit's directory.
(The family might have been already loaded in one case, but I specifically tried a new [Architectural template] drawing and I can confirm that the family was *not* loaded when it had finished.)
Solved! Go to Solution.
OK, I happened to see a related article and read it, and lo and behold, it had the answer.
You have to force Visual Studio to use the 'legacy debugger'. See the thread here:
That fixes the problems I listed.
Can't find what you're looking for? Ask the community or share your knowledge.