frankito Posted December 12, 2009 Share Posted December 12, 2009 Hi everyone, i want to create a C# (or VB.net) DLL and use it in autoit. I just want my DLL return a large string to my autoit EXE. I didn't find any tuto about it, is that possible ? Thanks Link to comment Share on other sites More sharing options...
Richard Robertson Posted December 12, 2009 Share Posted December 12, 2009 It's not. AutoIt cannot access the .Net framework directly. It can only call native resources. You can instead create a COM object from your .Net class and use that. Link to comment Share on other sites More sharing options...
frankito Posted December 12, 2009 Author Share Posted December 12, 2009 like this ? http://www.autoitscript.com/forum/index.php?showtopic=39262 my purpose is quite simple i just want to encrypt a large string in a DLL and deserve it to my autoit exe. Like this : My DLL : GetMyString() { return string } My EXE : Call ("mydll","getMyString") I know it's not as simple as i could write, but i'm litlle bit lost... thanks Link to comment Share on other sites More sharing options...
Richard Robertson Posted December 12, 2009 Share Posted December 12, 2009 No, you're looking in the right place but the wrong direction.You said you wanted to use C#, so I assume you know enough about Visual Studio to follow this.[COMVisible(true)] public class MyCOMClass { public string GetMyString(string someparameter) { return someparameter; } }Compile this to "mydll.dll".Then call "regasm.exe /codebase mydll.dll".In AutoIt,$obj = ObjCreate("mydll.MyCOMClass") $mystring = $obj.GetString("Hello!")One or more of these steps may need tweaking, but I hope I've at least given you a step in the right direction. zpanderson 1 Link to comment Share on other sites More sharing options...
zpanderson Posted July 1, 2012 Share Posted July 1, 2012 (edited) Compile this to "mydll.dll".Then call "regasm.exe /codebase mydll.dll".Am I correct in thinking that this will only allow this solution to work on the computer that it's built on?Edit:Well I tested this method out and I have it working on 1 pc and not another. I tried using regasm to generate a registry file for use on the second pc but that didn't seem to help. Any advice on how to get this to work on pcs that it wasn't built on? Thanks! Edited July 1, 2012 by zpanderson Link to comment Share on other sites More sharing options...
Richard Robertson Posted July 2, 2012 Share Posted July 2, 2012 You need to make sure that the second computer has the appropriate version of the .Net framework and all dependencies installed. Link to comment Share on other sites More sharing options...
zpanderson Posted July 3, 2012 Share Posted July 3, 2012 (edited) Thanks a lot for your help on getting this to work. I do have one more question that you might be able to help with. My c# function takes "public static int put(String[] args)" as an input parameter but I can't figure out how to send this through autoit. I tried making an array of strings, but that doesn't work. Dim $args[4] = ['OTS.TROUBLECALL.IN', 'OMSDW001', 'SEEBYOND.SVRCONN/TCP/172.19.96.64(1414)', ''] $obj = ObjCreate("nmqput.mqput") $obj.put($args) I get a COM Error err.windescription = Type mismatch. err.number is: 80020005 err.lastdllerror is: 0 err.scriptline is: -1 err.source is: err.helpfile is: err.helpcontext is: 4980844 If I change my c# function to "public static int put(String args)". I can send a singular string with no problems. Regards, Edited July 3, 2012 by zpanderson Link to comment Share on other sites More sharing options...
Richard Robertson Posted July 3, 2012 Share Posted July 3, 2012 (edited) You don't want static functions. You want member functions because you are instantiating an object through COM. The problem appears to be handling of arrays via COM though. I don't have enough experience in that to say what the problem or solution is. Edited July 3, 2012 by Richard Robertson Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now