extension using c#

extension using c#

Postby icehuli » Tue Dec 31, 2013 4:45 pm

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
3
User avatar
icehuli 
 

Re: extension using c#

Postby tt_su » Mon Jan 06, 2014 3:37 pm

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.
0
User avatar
tt_su 
SketchUp Team
SketchUp Team
 

Re: extension using c#

Postby icehuli » Fri Mar 14, 2014 4:03 am

The C# stuff works on SketchUp 2014 with Ruby 2.0.0
0
User avatar
icehuli 
 

Re: extension using c#

Postby Dan Rathbun » Fri Mar 14, 2014 5:19 am

icehuli wrote: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 or AuthorNamespace or CompanyNamespace, 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.)

:idea:
0
    I'm not here much anymore. But a PM will fire email notifications.
    User avatar
    Dan Rathbun 
    PluginStore Author
    PluginStore Author
     

    Re: extension using c#

    Postby icehuli » Fri Mar 14, 2014 9:24 pm

    Dan Rathbun wrote:
    icehuli wrote: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 or AuthorNamespace or CompanyNamespace, 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.)

    :idea:



    Thanks for the reminding.
    0
    User avatar
    icehuli 
     

    Re: extension using c#

    Postby icehuli » Mon May 14, 2018 12:12 am

    in case somebody using it, added a new project "IHL_CsR22ExtApp0" for Sketchup 2018/2017 x64 with ruby 22
    0
    User avatar
    icehuli 
     

    Re: extension using c#

    Postby jolran » Tue Jun 12, 2018 9:45 am

    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/137 ... ime-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 ?
    0
    User avatar
    jolran 
    PluginStore Author
    PluginStore Author
     

    Re: extension using c#

    Postby Shubham777 » Tue Sep 26, 2023 1:10 pm

    icehuli wrote: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 :
    Code: Select all
    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 Loaded

    Currently 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 folder

    Can you please help me out for this issue. Thank you In Advance!
    0

    Shubham777 
     

    Re: extension using c#

    Postby gullfo » Tue Sep 26, 2023 2:05 pm

    may be the recursion?
    rb_define_module_function(module, name, func, 2)

    Shubham777 wrote:
    Code: Select all
    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.
    0
    User avatar
    gullfo 
    Premium Member
    Premium Member
     

    SketchUcation One-Liner Adverts

    by Ad Machine » 5 minutes ago



    Ad Machine 
    Robot
     



     

    Return to Developers' Forum

    Who is online

    Users browsing this forum: kartoon98 and 12 guests