Jump to content
Sign in to follow this  
LiorTal

AutoIT dll + C# (Interop) and portability

Recommended Posts

LiorTal

Hello!

I'm developing a library of automation related tasks, one of which is AutoIT functionality using the COM dll (Interop).

This library will eventually be used on various systems so it needs to be portable.

On my dev machine (where AutoIT is also installed) i've found no issues - running & testing my DLL works without any flaws.

When attempting to run the DLL on another machine (with Windows 2000):

Unhandled Exception: System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {1A671297-FA74-4422-80FA-6C5D8CE4DE04} failed due to the following error: 80040154.

at Automation.AutoIt.AutoItExecuteWorker..ctor(String xmlPath) in C:\Projects\Automation\AutomationDev\trunk\CustomActions\AutomationLib\AutoIt\AutoItExecuteWorker.cs:line 39

at TestApp.Program.Main(String[] args) in C:\Projects\Automation\AutomationDev\trunk\CustomActions\TestApp\Program.cs:line 32

Registering the DLL manually (regsvr32 AutoItX3.dll) gets rid of this exception, however my program doesn't really press any buttons or work as expected afterwards.

On a different machine, the same program works correctly.

What am i doing wrong? i'd like this library to be portable, without the need to register DLLs or do any steps before using it.

If someone can help i'd appreciate it !

Thanks

Lior

Share this post


Link to post
Share on other sites
FuryCell

AFAIK it is require that the dll is registered. Write some C# code to call regsvr32 before and after execution so it can be registered and unregistered on the fly.

Edit:Typo

Edited by FuryCell

HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

Share this post


Link to post
Share on other sites
LiorTal

AFAIK it is require that the dll is registered. Write some C# code to call regsvr32 before and after execution so it can be registered and unregistered on the fly.

Edit:Typo

Hi, thanks for the reply.

As i've written above, i've tried registering the dll myself before running.

On the Win2000 machine i do not see the exception anymore, however the application doesn't behave as expected.

It doesn't seem to be pressing the controls correctly...

My app as a test needs to focus on the Calculator window, and perform some key presses there.

It focuses on the window , however nothing is being pressed...

What could be wrong here.. ?

I've marked my app's Main method with the STAThread attribute (after reading somewhere on the net that it is mandatory), perhaps this is wrong?

Edited by LiorTal

Share this post


Link to post
Share on other sites
LiorTal

Hi, thanks for the reply.

As i've written above, i've tried registering the dll myself before running.

On the Win2000 machine i do not see the exception anymore, however the application doesn't behave as expected.

It doesn't seem to be pressing the controls correctly...

My app as a test needs to focus on the Calculator window, and perform some key presses there.

It focuses on the window , however nothing is being pressed...

What could be wrong here.. ?

I've marked my app's Main method with the STAThread attribute (after reading somewhere on the net that it is mandatory), perhaps this is wrong?

OK i've tested again, my TestApp.exe should focus on the caclulator window, hit 5 + 5 = and exit.

Observations:

1. On win2000 machine - running TestApp.exe BEFORE registering dll - crashes with exception.

2. On win2000 machine - running TestApp.exe AFTER registering dll - Calculator window focuses, but not key clicks are sent. TetsApp exits without any errors.

3. On Win2003 machine - running TestApp.exe AFTER registering dll - works fine.

The only problematic scenario then is the Win2000 box... once i add the code to register the DLL it should work on all other machines, but what about the Win2000 ?

Any help will be appreciated!

Lior.

Share this post


Link to post
Share on other sites
FuryCell

The only thing I can think of is using the ControlClick() and ControlSend() functions as they are often more reliable.


HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

Share this post


Link to post
Share on other sites
LiorTal

The only thing I can think of is using the ControlClick() and ControlSend() functions as they are often more reliable.

I've done some more testing - added debug code to print out the result from the button press code.

All the key presses are returning 0 (error), i have no idea why... on a different machine the same code works FINE!

Any idea anybody?

Thanks.

Share this post


Link to post
Share on other sites
edddy

Hello LioTal,

I am trying to do something similar too .. Could you please help me out My link

Thank you very much in advance..

Share this post


Link to post
Share on other sites
Richard Robertson

I believe that Windows 2000 support was dropped.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×