.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Accessing/Calling a Command inside of a .NET Assembly.

2 REPLIES 2
Reply
Message 1 of 3
Millerni456
406 Views, 2 Replies

Accessing/Calling a Command inside of a .NET Assembly.

Hey all,

 

How does one execute a command located inside of a .NET assembly from 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:

acadDoc.SendStringToExecute("MYCOMMAND", true, false, true);

 

This should activate the document, and echo "MYCOMMAND" to the command line.  (Btw, the echo doesn't happen, and the document is already active before this call).

 

 

In the loaded .NET Assembly, my command is not called at all! The first line is to just put up a message box, which is not shown.

[CommandMethod("MYCOMMAND", CommandFlags.Session|CommandFlags.Transparent)]
public void MYCOMMAND() { main(); }

private void main(bool showErrors = true)
{
    System.Windows.MessageBox.Show("MYCOMMAND, ShowErrors=" + showErrors);
}

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

 

2 REPLIES 2
Message 2 of 3
Millerni456
in reply to: Millerni456

SOLVED:  I forgot to add a "\n" at the end my command.

 

Apparently, there is no need for the CommandFlags.Transparent flag.  So I was able to access the command, I just never called it properly. Go figure.

Message 3 of 3
Millerni456
in reply to: Millerni456

Could somebody delete this thread?  I need to repost the original problem.

 

Real problem is here:

http://forums.autodesk.com/t5/NET/Execute-Strings-Commands-Recursively/td-p/4404993

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost