Extension using c#
-
Someone might be interested in using c# and .net stuff.
I created a very simple example to write a ruby extension in c#.
https://bitbucket.org/icehuli/sucsexttutorial -
Cool! That's very interesting.
Last week I was working on a Ruby C Extension in C++ and I started to write a thin wrapper over the Ruby C code so that I could manipulate them as C++ objects. It'd be nice with a set of wrappers like that the various languages.
-
The C# stuff works on SketchUp 2014 with Ruby 2.0.0
-
@icehuli said:
The C# stuff works on SketchUp 2014 with Ruby 2.0.0
ALL tutorials should show ALL objects being created INSIDE an Author's toplevel module.
We usually use the module name
Author
orAuthorNamespace
orCompanyNamespace
, etc., do denote that the end user should replace that name with their own toplevel module name.Only Ruby and the API (in rare cases,) should ever create classes at the toplevel (aka
TOPLEVEL_BINDING
.) -
@dan rathbun said:
@icehuli said:
The C# stuff works on SketchUp 2014 with Ruby 2.0.0
ALL tutorials should show ALL objects being created INSIDE an Author's toplevel module.
We usually use the module name
Author
orAuthorNamespace
orCompanyNamespace
, etc., do denote that the end user should replace that name with their own toplevel module name.Only Ruby and the API (in rare cases,) should ever create classes at the toplevel (aka
TOPLEVEL_BINDING
.)Thanks for the reminding.
-
in case somebody using it, added a new project "IHL_CsR22ExtApp0" for Sketchup 2018/2017 x64 with ruby 22
-
Interesting stuff indeed, and nice job Icehuli!
It looks like you are wrapping a lot of Ruby-communication-code into C#.
Does it work well ? How is the performance ?
Ive read the UnmanagedExports-package puts a bit of overhead.
Was rather old info, I'll be intreseted to know if it has been improved.I'm working on a similar project with a WPF application.
In my project I use a different pattern in using a C++/Cli "Bridge-layer" with a C++/cli ref-class that subclass the WPF app. Then I can use that class to communicate with C++ as normal through exporting the required functions.
This means off course writing the bussiness-layer and Ruby-Communication layer in C++,
and (for the most part) only using C# for the front-end.I had some problems running the application if I did not put the assembly in the same folder as Sketchup.exe. I don't want to hijack your post but it would be interesting to hear if you have any experience with this.
The solution I found is to handle the event when the Appdomain cant locate an assembly.
AppDomain ResolveEventHandler
This SO-topic has some code: https://stackoverflow.com/questions/1373100/how-to-add-folder-to-assembly-search-path-at-runtime-in-net (msarahan C++/Cli version a bit further down).
This requires a longliving Application though.I could also possibly explicitly load the assembly, and then use reflection to create an instance. But it becomes quite complicated when I want to use a C++/Cli ref class as subclass.
I wonder what the policy is regarding putting dll's in the Sketchup folder ?
-
@icehuli said:
in case somebody using it, added a new project "IHL_CsR22ExtApp0" for Sketchup 2018/2017 x64 with ruby 22
Interesting and nice job Icehuli!
I currently working on your C# project "IHL_CsExt0" .After successfully build your code I connected this with SketchUp 2023 but I got exception at following function :
public static void rb_define_module_function(VALUE module, string name, CallbackArg2 func) { MethodDelegates.Add(func);//keep a reference to "func" to prevent it being garbage collected rb_define_module_function(module, name, func, 2); }
exception occurs ::
1.Exception thrown at 0x00007FF99A750EB6 (x64-msvcrt-ruby270.dll) in SketchUp.exe: 0xC0000005: Access violation reading location 0x000000006F21B998.
2.System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'
3.kernelbase.pdp Not LoadedCurrently using ::
SketchUp 2023 with "x64-msvcrt-ruby270.dll" in visual studio 2019.
framework=.net 4.5 also add post build event to copy "IHL_CsExt0.so" file (SketchUp)Plugin folderCan you please help me out for this issue. Thank you In Advance!
-
may be the recursion?
rb_define_module_function(module, name, func, 2)@shubham777 said:
public static void rb_define_module_function(VALUE module, string name, CallbackArg2 func) > { > MethodDelegates.Add(func);//keep a reference to "func" to prevent it being garbage collected > rb_define_module_function(module, name, func, 2); > }
exception occurs ::
1.Exception thrown at 0x00007FF99A750EB6 (x64-msvcrt-ruby270.dll) in SketchUp.exe: 0xC0000005: Access violation reading location 0x000000006F21B998. -
@icehuli said:
Someone might be interested in using c# and .net stuff.
I created a very simple example to write a ruby extension in c#.
https://bitbucket.org/icehuli/sucsexttutorialcan you guide me to run the sample code
Advertisement