Rpg.NET Export ToolAuthors: ForeverZer0Version: 1.0Type: .NET Post-Built Tool
IntroductionThis application is designed to allow you to create Microsoft .NET assemblies that can interop with RGSS using Ruby's Win32API. Assemblies built that target the .NET Framework are managed code, and are unable to be invoked using Ruby. This application performs a post-build process on your existing .NET projects that allows them to be invoked with Win32API, just like that of an unmanaged C/C++ library. Since many on this forum are C# (and other .NET Framework languages) programmers, this should hopefully open up many new possibilities for us that have since moved on from RGSS due to it's simplicity, but still have an active interest in it.
Features
- Extremely simple to create managed .NET assemblies that can interop with Ruby
- Easily modify and use existing projects
- Only need to add a single method attribute to functions that you want to export
Download.NET Framework v.4.0Rpg.NET Export.zip (116 KB)
Requires
Microsoft .NET Framework 4.0.NET Framework v.2.0 Rpg.NET Export.zip (116 KB)
This version of the framework is already pre-installed on Windows XP SP3 and above.
Contains everything needed to built projects with exported functions.
- RpgExport.exe
Main tool that performs the compilation
- RpgExport.exe.config
Configuration file for the RpgExport tool. Can be modified manually, but not required
- RpgExportAttribute.dll
Library that needs to be referenced by your project, and contains the method attribute. The dependency will be removed during the post-build process, so this file will NOT need to be deployed with your project
Source CodeSource Forge
InstructionsStep 1Download the above file, and unzip to anywhere on your computer.
Step 2Create a new project, targeting whichever framework you prefer. Remember that pretty much every Window's computer out there will have .NET Framework installed already on it, but higher versions such as 3.5 and 4.0 may not be, and could possibly require the end-user to install before your assembly will work on it.
After creating your project, make a reference to
RpgExportAttribute.dll.
Step 3Now create your code as you please. The only important factor to implement is that the methods must be marked as "static", and they need decorated with the "RpgExport" attribute that is imported from the RpgExportAttribute.dll. The only required argument with the attribute is the name that it will be as exported as, which can be different than the actual method name. Following is a rather simple example:
The name assigned within the "RpgExport" attribute is the name that will be invoked with Ruby's Win32API class.
Step 4Now build your project, and open up the
RpgExport.exe tool.
Either drag-drop the created assembly onto the form, type in the full path to the file, or use the dialog to set the assembly as the input assembly.
Here is a quick explanation of the parameters that can be set in the application:
- IL Assembler Location
This is the location of "ilasm.exe", selected from list of versions found on the system. I personally have not found any difference in which version is used, and have always just used the highest version available.
- IL Disassembler Location
This is the location of "ildasm.exe", selected from list of versions found on the system. Again, I have not found any difference in which is used.
- Input Assembly
The input assembly that will be recompiled
- Output Assembly
This is the output path of the assembly. If blank, the input assembly will simply be overwritten.
- Architecture
This is the target CPU architecture the assembly will target. Typically "Any CPU" will work just fine.
- Optimize
This is the same as checking "Optimize" in the within the Build Properties of the project, and is the default of any "Release" build. There really isn't any reason this should not be used.
Step 5After making any changes you need, click "Export" and the project will be rebuilt. Copy this output assembly to your RPG Maker project's game folder, and you are ready for a test.
Step 6Within RPG Maker, create the necessary Win32API object, and invoke your new method!
Tips and TricksI will add more to this section later, and explain more on the few things that follow just to get you started.
Invoke Ruby Code From .NET AssemblyInclude "System.Runtime.InteropServices" in a class, and use P/Invoke to exectute Ruby code. The only little hiccup I have run in to so far is that ensure any class that implements importing unmanaged DLLs is marked as "internal", and not the within a class you are exporting functions from. To see what I mean, look at the following two pictures.
Win32API.new('RpgNet.dll', 'SayHello', 'p', '').call('ForeverZer0')
Encrypting/Compressing ScriptsYup, this is actually quite simple, a very good encryption, but does require the use of one other post-built tool. I will explain more tomorrow within the next day or so.
NotesFeel free to report any bugs, issues, or comments, I will try to answer anything that I can.
Please give credit if using in your project!