- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey all,
How does one execute a command located inside of a .NET assembly from a recursive function in another .NET assembly?
I'm working on a program that will load a .NET Assembly, then calls one of the commands inside of it to make changes to the current document.
Anyways, I was able to succesfully load the assembly using this code:
try
{
Assembly.LoadFrom(@"C:\acad\networkdll\MyDotNetAssembly.dll");
ASSEMBLY_LOADED = true;
}
catch
{ //Load failed.
ASSEMBLY_LOADED = false;
}
Now when I go to execute my command I use a function similar to this, and this works almost fine:
public void DoSomething(string currentDrawing)
{
... \\open acadDoc
acadDoc.SendStringToExecute("MYCOMMAND\n", true, false, true);
... \\Get next drawing file name or return if there is none.
DoSomething(nextDrawing);
}
The function that calls this "MYCOMMAND" is recursive, and it should attempt to call this command during each recursive call (and the original call).
Unfortunately, the command is called once, and it happens on the LAST recursive call only.
Here is the command that is called (withing the referenced .NET assembly.
[CommandMethod("MYCOMMAND", CommandFlags.Session|CommandFlags.Transparent)]
public void MYCOMMAND() { main(); }
private void main(bool showErrors = true)
{
System.Windows.MessageBox.Show("MYCOMMAND, ShowErrors=" + showErrors);
... //Change drawing
}I've also testing with only the CommandFlags.Session flag only, this did not work too.
The way my original program is ran is through a command. (Session flag only on that one as well).
For reference, here is the documentation for the CommandFlags enumeration.
If anyone could help me out here, it'd be greatly appreciated.
PS: In case it wasn't clear, I can call this command manually. It is just my program that cannot call it.
Thanks,
-Nicholas
Solved! Go to Solution.