I guess it is the error message that seems having nothing to do with Win Form makes people hesitate to response to your question. The error message looks like somehow related to WPF UI. Also, when you say "... show this in debug", what does "debug" mean? where exactly do you see the error message? A pop-up window in AutoCAD, where you can click either "Detail" to see more error message, or "Continue", which would either let AutoCAD continue. if the error is not that fatal, or let AutoCAD die?
Anyway, if your Form1 is a true win form, regardless the strange error, your code in the CommandMethod is very wrong, in 2 ways:
1. You DO NOT show dialog form (modal view) with Form.ShowDialog() in AutoCAD .NET API add-in. You must use AutoCAD .NET API method
Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog[Window]()
2. You DO NOT sandwich all the code (showing the dialog box, and then user may do something to AutoCAD by interacting with the form) with a Transaction and only not commit it (which means whatever user does to AutoCAD would be aborted when you close the dialog form. That is why the line drawn by the button clicking action is not there: it is lost after you close the form. because the outer-most transaction is not commited (thus, aborted automatically).
While letting UI's event handler (button clicking, in your case) directly interact with AutoCAD isn't a very good code practice, I think you can live with that for now (as beginner?), thus, the simple fix to your code is to modify the CommandMethed as following:
[CommandMethod("ACADPipe")]
public static void pipe()
{
using (Form1 form1 = new Form1())
{
Application.ShowModalDialog(form1);
}
}
And, in your drawTestLine_Click() method, you might want to add
ed.UpdateScreen()
at the end of the Transaction, if you want the newly created line to be seen without dismissing the dialog box.