.NET Framework Interop (CLR, C#, VB)

Post your working scripts, libraries and tools
User avatar
evilC
Posts: 3593
Joined: 27 Feb 2014, 12:30

Re: .NET Framework Interop (CLR, C#, VB)

06 Mar 2017, 09:35

OK, I have it all working now.
Many thanks to Lexikos for releasing CLR and your help on this thread.

I now have my own thread here: https://autohotkey.com/boards/viewtopic ... 19&t=28889
lexikos
Posts: 5455
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: .NET Framework Interop (CLR, C#, VB)

10 Mar 2017, 18:04

Why ask the question when it's so simple to just change the code and see what happens?

Yes, it's possible.
User avatar
evilC
Posts: 3593
Joined: 27 Feb 2014, 12:30

Re: .NET Framework Interop (CLR, C#, VB)

10 Mar 2017, 19:08

I tried, but I could not get it to work. I guess I did something wrong - it said something like "interface does not support that". I suppose I will have to try again then.
lexikos
Posts: 5455
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: .NET Framework Interop (CLR, C#, VB)

10 Mar 2017, 21:58

I can't imagine what would cause that.

Modifying my example to use a BoundFunc is very simple:
  • Obviously, if handler (on the C# side) is a BoundFunc, handler.Handle() won't work. Change it to handler() or handler.call().
  • Change util.Test(Handler) to util.Test(Handler.Handle.Bind(Handler)).
raskun
Posts: 12
Joined: 01 Mar 2017, 20:30

Re: .NET Framework Interop (CLR, C#, VB)

12 Mar 2017, 07:58

How to use this when my main ahk script was referencing to calling to another ahk script?
b0bi
Posts: 6
Joined: 07 Apr 2016, 13:11

Re: .NET Framework Interop (CLR, C#, VB)

20 Mar 2017, 10:14

This seems very interesting, but the download link is dead :/
burque505
Posts: 138
Joined: 22 Jan 2017, 19:37

Re: .NET Framework Interop (CLR, C#, VB)

20 Mar 2017, 11:31

Confirming dead link 03/20/17 at 10:31 MST
User avatar
evilC
Posts: 3593
Joined: 27 Feb 2014, 12:30

Re: .NET Framework Interop (CLR, C#, VB)

20 Mar 2017, 17:04

Whee! C# is fun!

I am currently mucking around with Managed Extensibility Framework (MEF). MEF is basically a framework to make it easy to write plugins which can advertise their capabilities etc.

I have a post here if anyone is interested in how to rig up a DLL which can load other DLLs as plugins - it's pretty easy:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

lexikos
Posts: 5455
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: .NET Framework Interop (CLR, C#, VB)

21 Mar 2017, 05:18

The download link was to my Dropbox public folder. Dropbox killed all public folders.

I've replaced the link. (It just links to the download function of the code box at the bottom of my post now.)
burque505
Posts: 138
Joined: 22 Jan 2017, 19:37

Re: .NET Framework Interop (CLR, C#, VB)

21 Mar 2017, 10:05

Thanks, lexikos.
iseahound
Posts: 114
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

Re: .NET Framework Interop (CLR, C#, VB)

26 Apr 2017, 13:36

How would I load a DLL that loads either a 64 bit or 32 bit DLL?

I'm getting a cannot load file or assembly error, and loading the 64-bit DLL directly returns error "'00.dll' could not be opened -- ‘An attempt was made to load a program with an incorrect format."
iseahound
Posts: 114
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

Re: .NET Framework Interop (CLR, C#, VB)

01 May 2017, 01:39

Alright. After some extensive testing, code that works fine in PowerShell gives me an error in AHK. Upon loading an external Dll, The object is successfully created using CLR_CreateObject, but any calls to the created object fail. (Ex. obj.Version does not return the version number. Works fine in Powershell).

I tried debugging the object, and the DispatchType and IID fields are blank.

If anyone can help, I'm trying to convert this code. https://github.com/jourdant/powershell-paperless (DLLS are downloaded via powershell script.)

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

sancarn
Posts: 203
Joined: 01 Mar 2016, 14:52

Re: .NET Framework Interop (CLR, C#, VB)

03 Jun 2017, 19:57

I am wondering which versions of Windows OS CLR applies to? From general knowledge I know that CLR 4.5 is installed on all Windows 10 operating systems, however I was wondering how far back this goes? CLR 1.0 appears to go back to Windows 98 OS, but I have no idea whether CLR.AHK will work with the functions provided by CLR 1.0. (P.S. I don't expect Windows 98 to be supported... :p)
User avatar
evilC
Posts: 3593
Joined: 27 Feb 2014, 12:30

Re: .NET Framework Interop (CLR, C#, VB)

06 Jun 2017, 16:52

I manged to figure out how to get a message pump going in a C# DLL with no visible GUI.
In this post, I demo using it to allow my code to process RawInput (WM_INPUT) messages, and fire a callback to AHK, though I would imagine this technique would be handy for other things too.
My code uses SharpDX, so that seems to preclude the need for implementing a message processing loop, but the code has links to an article which shows how that is done.
User avatar
evilC
Posts: 3593
Joined: 27 Feb 2014, 12:30

Re: .NET Framework Interop (CLR, C#, VB)

06 Jun 2017, 17:03

@iseahound - have you tried running the AHK script in Scite4AutoHotkey?
I get what looks like exception messages in the output pane when using CLR, so that may yield some useful info.
sancarn
Posts: 203
Joined: 01 Mar 2016, 14:52

Re: .NET Framework Interop (CLR, C#, VB)

23 Jun 2017, 05:33

How do you parse a List object from CLR to AHK?

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Last edited by sancarn on 23 Jun 2017, 05:39, edited 1 time in total.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: burque505 and 19 guests