Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If the addin cannot be properly loaded, just skip the file. #11

Merged
merged 2 commits into from
May 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion DesignAutomationHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,17 @@ public Result Execute(ExternalCommandData commandData, ref string message, Eleme
string[] files = Directory.GetFiles(app.AllUsersAddinsLocation, "*.addin");
foreach (string file in files)
{
XElement addin = XElement.Load(file);
XElement addin;
try
{
addin = XElement.Load(file);
}
catch
{
MessageBox.Show($"Malformed XML in addin: {file}", "DesignAutomationHandler");
// if the XML is malformed or not parse-able, just continue
continue;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it ever happen that *.addin is malformed?
Instead of ignoring the error in silence, we'd better at least pop out an error message by "MessageBox.Show"(for example).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like it does, see issue filed last year here: #8
We also see some issues on stackoverflow: https://stackoverflow.com/questions/76132803/forge-design-automation-debug-revit-plugin-locally-tutorial-not-working

(however, we can certainly throw an message)

}
IEnumerable<XElement> childList = from el in addin.Elements() select el;
foreach (XElement e in childList)
{
Expand Down