What's new

"Could not load file or assembly" with Alibre 2011

joril

Member
Hi everyone!
We just upgraded to Alibre 2011, and our automation scripts don't work anymore :/

Calling a method of the AutomatioHook.Root results in an error message "Could not load file or assembly":

zgSBJ.png


I wrote a tiny Autohotkey script that triggers the problem:

Code:
COM_Init()
h := COM_CreateObject("AlibreX.AutomationHook")
r := COM_Invoke(h, "Root")
f := COM_Invoke(r, "OpenFile", "C:\whatever")

With Alibre 12 everything works as usual... Am I missing something?

Thanks for your attention :)
 

joril

Member
joachim said:
not automationhook , use iautomationhook instead

Hi, thanks for your answer :)
I tried casting the automation hook to IAutomationHook (after the CreateObject of course), but the error is still there :/ Do you know if the 2011 installations are running on XP?
 

sigseven

Senior Member
I've never used AutoHotKey, so I was hoping someone else might have been able to weigh in. I'm not sure why it would be having this problem. I haven't had issues making the same API calls in 2011 using C#, C++ or VB.

The exception is rather perplexing. The assembly it says it can't find is the source of the call at the bottom of the stack...

Could you clarify whether that AutoHotKey code is supposed to create a gui-less instance of Alibre or connect to a running one? Also, it would be helpful if you could confirm if you get this error in both of those situations. I'll see about getting AutoHotKey installed and trying it out.
 

joril

Member
sigseven said:
I've never used AutoHotKey, so I was hoping someone else might have been able to weigh in. I'm not sure why it would be having this problem. I haven't had issues making the same API calls in 2011 using C#, C++ or VB.

I see... Please note that my application is written in Python and I'm getting the error there too.. I wrote the Autohotkey script to see if it was somehow Python's fault, but it looks like the problem lies elsewhere :/

sigseven said:
The exception is rather perplexing. The assembly it says it can't find is the source of the call at the bottom of the stack...

Could you clarify whether that AutoHotKey code is supposed to create a gui-less instance of Alibre or connect to a running one? Also, it would be helpful if you could confirm if you get this error in both of those situations. I'll see about getting AutoHotKey installed and trying it out.

The code is for GUI-less mode, so to adapt it for GUI mode you should change the COM_CreateObject call to COM_GetActiveObject, and... It works :shock: No error with Alibre running... But I need to support GUI-less too :(

Many thanks for your assistance!
 

sigseven

Senior Member
I installed AutoHotKey, and when I attempt to load the sample script you posted I get the following error:


Is there something else I need to have in the script?
 

Attachments

  • AHKError.png
    AHKError.png
    21.8 KB · Views: 2,995

sigseven

Senior Member
Thanks, that lets me load the script. However, when I try to run it I now get this error message:


This isn't normal is it? If I continue I get another one of these, and after that nothing happens. I never get the error you posted. Is there something else I should do?
 

Attachments

  • AHKError2.png
    AHKError2.png
    25.7 KB · Views: 184

joril

Member
sigseven said:
Is there something else I should do?
I think you're using Autohotkey_L, while I'm using the "basic" version.. Sorry again :( Since the L version includes the COM library, the syntax is a bit different:

Code:
hook := COMObjCreate("AlibreX.AutomationHook")
hook.Root.OpenFile("C:\whatever")
Thanks for your patience!
 

joril

Member
NateLiqGrav said:
joril, Can you post the full AHK code to an example that works in v12? I'd love to play with it.
Well sure, I can try to port to AHK one of our Alibre-related Python functions...
I'm not familiar with Autohotkey_L COM syntax though, I hope you won't mind if I use the "basic" syntax :) (that requires the COM library plugin)

Here's a script that displays the Mass of a part file (Alibre must be closed):
Code:
COM_init()
hook := COM_CreateObject("AlibreX.AutomationHook")
COM_Invoke(hook, "Initialize", "", "", "", False, 0)
root := COM_Invoke(hook, "Root")
f := COM_Invoke(root, "OpenFile", "C:\path\to\partfile.ad_prt")
design := COM_QueryInterface(f, "{591B330B-4AF7-4DC5-B7CA-E68E6CBE12E8}")
pp := COM_Invoke(design, "PhysicalProperties", 2)
v := COM_Invoke(pp, "Mass")
msgbox, %v%
 

NateLiquidGravity

Alibre Super User
Thanks, I use the original AHK anyways. Worked like a charm on v12.1 :D I've not much experience in COM but this should give me a jumpstart. Will also give sigseven a base to test why its different in v2011 vs v12.
 

sigseven

Senior Member
I installed AHK Classic and tried running that sample code. It got the mass successfully and didn't report any errors.

Maybe there's a problem with your configuration? Possibly something gone wrong with the install? You might want to try doing an uninstall/reinstall of Alibre.
 

joril

Member
I didn't get the notification of your reply, sorry for the late answer :/

sigseven said:
Maybe there's a problem with your configuration? Possibly something gone wrong with the install? You might want to try doing an uninstall/reinstall of Alibre.

I already tried that, and on different machines too.. :/ On what OS did you run the test?
 

joril

Member
Just tried with the latest version (AlibreDesign_V2011.59_x32.exe) and I still get the error :/ Could it be an XP compatibility problem?
 

sigseven

Senior Member
The PhysicalProperties sample (available here: viewtopic.php?f=13&t=8186) will attempt to initialize Alibre in GUI-less mode if it is not already running. Could you please try using it to see if it gets the same problem? This will help us determine whether this is a general issue or something AHK specific.
 

sigseven

Senior Member
Alright, thanks for the info. It will be helpful in diagnosing the problem. I'll try to get a test computer to demonstrate the error, so that we can find the cause of the problem.
 
Top