Note that there are some explanatory texts on larger screens.

plurals
  1. POAutoHotkey.dll: "new CoCOMServer()" causes Exception
    text
    copied!<p>I successfully downloaded the Autohotkey_H 1.1 package from</p> <p><a href="http://www.autohotkey.net/~HotKeyIt/AutoHotkey/files/AutoHotkey-txt.html" rel="nofollow">http://www.autohotkey.net/~HotKeyIt/AutoHotkey/files/AutoHotkey-txt.html</a></p> <p>I then successfully registered the Win32w version (in the "Win32w" folder) of the AutoHotkey.dll with regsvr32.</p> <p>Then I started Visual Studio 2012, started a new Project and referenced the DLL in the project successfully.</p> <p>The project has only the following code:</p> <pre><code>class Program { static void Main(string[] args) { CoCOMServer ahkThread = new CoCOMServer(); } } </code></pre> <p>upon running the code, the following error occurs:</p> <p><a href="http://imageshack.us/f/822/pn3y.png" rel="nofollow">http://imageshack.us/f/822/pn3y.png</a> (StackOverflowException in mscorlib.dll)</p> <p>I am using Windows 7 64 bit. The error occurs on 2 different machines with the SAME setup.</p> <p>Has anyone successfully used the DLL with Visual Studio and give me some hints on what you did differently?</p> <p>EDIT:</p> <p>Also, this does NOT work in VB:</p> <pre><code>Sub atest() Dim AhkCom As Object Set AhkCom = CreateObject("AutoHotkey.Script") AhkCom.ahktextdll("MsgBox Hello World!" &amp; Chr(13) &amp; "ExitApp") End Sub </code></pre> <p>And neiter does this:</p> <pre><code>dynamic ahk = Activator.CreateInstance(Type.GetTypeFromProgID("AutoHotkey.Script.UNICODE")); ahk.ahktextdll("msgbox hello world"); </code></pre> <p>And this <strong>DOES</strong> work in Autohotkey itsself:</p> <pre><code>AhkCom := ComObjCreate("AutoHotkey.Script") AhkCom.ahktextdll("MsgBox Hello World!`nExitApp") While AhkCom.ahkReady() Sleep, 100 MsgBox Exiting now </code></pre> <p>Last one proves that the DLL is, in fact, working.</p> <p>In fact it shows very clearly that the problem is Visual Studio specific. Tried 2010 aswell by now.</p> <p>If someone can tell me what I am doing wrong I would be eternally grateful. Do I need to specify more than those 2-4 lines of code? Do something with Interop? I have no clue.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload