Reputation: 13
I'm developing an AutoCAD .Net plugin which contains a command that opens a modal window. The window should display a web page.
But it has a strange bug, here is a simple code to reproduce it:
[CommandMethod("TEST_BROWSER")]
public void TestBrowserCommand()
{
var window = new Window();
var browser = new WebBrowser();
window.Content = browser;
browser.Source = new Uri("http://google.com");
window.ShowDialog();
}
Or even simpler:
[CommandMethod("TEST_BROWSER")]
public void TestBrowserCommand()
{
Application.ShowModalWindow(new Uri("http://google.com"));
}
Here is the sequence of steps after which AutoCAD crashes:
It works fine if to open non-modal (modeless) windows, or not to use web browser, or to call the code without using the command.
But I need a modal window with a browser called from the command line.
Did anyone else encounter the same issue?
Upvotes: 1
Views: 1489
Reputation: 86640
The CommandMethod
attribute can have some flags.
Use the session
flag to make the method be independent of an open document and be managed by the autocad application main window.
Upvotes: 3
Reputation: 809
I can't test at the moment but I think you need to change your CommandMethod
statement to: [CommandMethod("TEST_METHOD", CommandFlags.Modal)]
Upvotes: 0
Reputation: 468
You can create WPF browser application and launch with the given url when required. or try passing the shell command using AutoCAD
you can open a website in a browser of your choice from CMD like this chrome.exe "zcodia.com.au"
Upvotes: 0