Author Topic: Slick-C Interface to C# Assemblies?  (Read 1824 times)

jlynker

  • Junior Community Member
  • Posts: 5
  • Hero Points: 0
Slick-C Interface to C# Assemblies?
« on: June 10, 2016, 05:49:36 pm »
I work in C# a lot and am looking for a solution to be able to expand Slickedit using C# Assemblies, by way of interfacing through Slick-C macros.

Anyone have suggestions? Solutions? Templates?

Thanks,
John

Graeme

  • Senior Community Member
  • Posts: 2210
  • Hero Points: 272
Re: Slick-C Interface to C# Assemblies?
« Reply #1 on: June 11, 2016, 06:01:05 am »
I don't understand your question.  Can you give some more details about what you're trying to do?


jlynker

  • Junior Community Member
  • Posts: 5
  • Hero Points: 0
Re: Slick-C Interface to C# Assemblies?
« Reply #2 on: June 12, 2016, 05:32:40 pm »
I write a lot of command pattern constructs in C# and pretty much work solely on Windows PCs (thus, C# & .NET are always available). Also, I've had a lot of experience with (Win32) LoadLibrary/GetProcAddress and (.NET) Assembly.Load/GetMethod.

What I'd like to do is write/use a generic Slick-C dload method to load a .NET Assembly DLL and have a generic method (or, a wrapper/shim per method or class) to then call into the .NET Assembly DLL methods where the .NET Assembly methods then could have access to Slick-C and other SlickEdit DLL Exports.

Slick-C is a good language, but I find myself having to consider re-writing code in Slick-C (or using Visual Studio DevEnv plugins and not using SlickEdit) to access functionality that's already well written in C# and .NET. This is especially true for XML/DOM code with MVC projects.

Example: I could develop a .NET Assembly which uses the Newtonsoft JSON and develop both product code and test code using similar libraries. Instead, I use DevEnv for development (with command line build) and use SlickEdit for searches and some basic macro execution.

I could get a lot more out of SlickEdit if I could interface .NET Assemblies into Slick-C programming modules.

Thanks,
John

Graeme

  • Senior Community Member
  • Posts: 2210
  • Hero Points: 272
Re: Slick-C Interface to C# Assemblies?
« Reply #3 on: June 13, 2016, 11:57:18 am »
I suspect you know more about this than I do.

Could you do something like this
http://www.codeproject.com/Tips/695387/Calling-Csharp-NET-methods-from-unmanaged-C-Cplusp
Call back the other way like this
https://dzone.com/articles/calling-unmanaged-c-function-c

Did you look at dload in the slickedit help file.  It says to look at simple.c for a dll example.  simple.c is in the slickedit installation samples/simple folder.

Have you seen the api documentation for slick functions you can call from a dll.  See api documentation in the help contents, then select C functions by category.  In the C Miscellaneous functions topic you'll see vsExecute which is the C API version of the slickedit macro "execute".  It can be passed a string containing the name of a command to be called and arguments for that command.  If you're using 64 bit slickedit, your dll functions have to be 64 bit too.

Another way to call a macro in slickedit from external code is to use the -r or -# invocation options  - e.g. vs.exe -r edit junk
Slickedit also supports DDE dynamic data exchange.  It used to work, I don't know if it still does.

Graeme

jlynker

  • Junior Community Member
  • Posts: 5
  • Hero Points: 0
Re: Slick-C Interface to C# Assemblies?
« Reply #4 on: June 15, 2016, 08:34:38 pm »
Thank you very much for your reply and detailed info...

Yes, found simple.c and the module support APIs... and, also, yes, looks like hosting Managed from Unmanaged will be as far as I can get .. This means that while in managed, I'll have to stay in managed (pretty much), still holding out hope that I can wrap many of the SlickEdit APIs so C# can call into it...

Thanks,
John