It is currently April 20th, 2024, 3:57 pm

Plugin development in C#: success

Share and get help with Plugins and Addons
User avatar
psouza4
Developer
Posts: 30
Joined: December 2nd, 2010, 1:56 pm
Location: Meridian, ID, USA

Plugin development in C#: success

Post by psouza4 »

I've been successful in writing a Rainmeter plugin completely in C#.

There are two caveats:
(1) the code must be compiled 'unsafe' (dealing with pointers at the moment)
(2) it must be disassembled using ildasm.exe (.NET SDK utility), modified to export the public class members for stdcall and corflags update, and then reassembled using ilasm.exe (.NET base runtime utility).

I wrote a utility that does (2) and is completely automated, so I just include that as a build step. It works with both Rainmeter x86 and Rainmeter x64 (but you need a separate plugin compiled for each). I've tested with Update() and GetString() members and they're both passing data back and forth just fine.

I'm going to be cleaning up some code and preparing a template and a utility class -- anyone interested in this?
MattKing
Developer
Posts: 98
Joined: August 6th, 2009, 3:03 pm

Re: Plugin development in C#: success

Post by MattKing »

Yeah, that sounds pretty nice. Definitely would be useful, much easier to write .NET plugins.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Plugin development in C#: success

Post by jsmorley »

MattKing wrote:Yeah, that sounds pretty nice. Definitely would be useful, much easier to write .NET plugins.
He's got it working nice. He is putting some coats of polish on a "tempate" and might have something soon.

I installed VC# Express 2010 and compiled a new plugin in C# that worked fine with Rainmeter. I wet myself a little.
User avatar
psouza4
Developer
Posts: 30
Joined: December 2nd, 2010, 1:56 pm
Location: Meridian, ID, USA

Re: Plugin development in C#: success

Post by psouza4 »

jsmorley wrote:I wet myself a little.
... my work here is done. :D
poiru
Developer
Posts: 2872
Joined: April 17th, 2009, 12:18 pm

Re: Plugin development in C#: success

Post by poiru »

jsmorley wrote:I wet myself a little.
Likewise.
Tuscany
Posts: 1
Joined: January 17th, 2011, 4:59 pm

Re: Plugin development in C#: success

Post by Tuscany »

C# developing tool will be just great. So, thumbs up and i'm looking forward to it (:
User avatar
psouza4
Developer
Posts: 30
Joined: December 2nd, 2010, 1:56 pm
Location: Meridian, ID, USA

Re: Plugin development in C#: success

Post by psouza4 »

It's live -- been in the beta builds and SVN for a bit over a month now. :) Download and enjoy.
User avatar
Tamschi
Posts: 4
Joined: December 16th, 2010, 10:45 pm

Re: Plugin development in C#: success

Post by Tamschi »

Will this work for .NET 4.0 plugins in the future?

Building InputText against .NET 4.0 seems to work fine after fixing the references and enabling mscorlib.dll, but Rainmeter crashes with an unspecified error when I switch the libs in the Plugins folder (x64 version, in case that matters).
User avatar
psouza4
Developer
Posts: 30
Joined: December 2nd, 2010, 1:56 pm
Location: Meridian, ID, USA

Re: Plugin development in C#: success

Post by psouza4 »

It works for 4.0, but you shouldn't enable mscorlib.dll automatic referencing. It was specifically excluded due to target platform incompatibilities (which is why you're crashing). Force the compiler to late bind and remove that reference. Then the plugin source should compile against .NET 2.0 and above (including 4.0).
User avatar
Tamschi
Posts: 4
Joined: December 16th, 2010, 10:45 pm

Re: Plugin development in C#: success

Post by Tamschi »

If I want late-binding, do I have to replace all mscorlib types with dynamic? What I want to do is getting access to the new libraries added in later versions of the runtime...

Sorry if this is a noob question, I'm not very experienced when it comes to mixing runtimes :???: