Trying to call interface method for a C# class

I am attempting to call an interface method for a .net class and am
having difficulty. I’m using IronRuby v1.1.2 and working with
ScintillaNet, a .net wrapper for the Scintilla control.

A portion of the ScintillaNet::Scintilla class is below:

namespace ScintillaNet
{

public partial class Scintilla : Control, INativeScintilla,
ISupportInitialize
{

}
}

And a portion of the ScintillaNet::INativeScintilla interface is below:

namespace ScintillaNet
{
public interface INativeScintilla
{

void BackTab();

}
}

I came across another forum discussion
http://rubyforge.org/pipermail/ironruby-core/2009-January/003520.html,
which seems to fall along the lines of what I’m trying to do, but I’m
not sure the features discussed there are implemented yet.

I’ve reduced the troublesome code to a relatively short length to play
with alternative approaches:

require “bin/ScintillaNet”
class ScintillaNet::Scintilla
include ScintillaNet::INativeScintilla

def self.ztest2()
  z = ScintillaNet::Scintilla.new()
  puts "z[#{z}]"
  #; z.BackTab() # undefined method `BackTab' for

ScintillaNet.Scintilla:ScintillaNet::Scintilla (NoMethodError)
#; ScintillaNet::INativeScintilla(z).BackTab() # undefined method
INativeScintilla' for ScintillaNet:Module (NoMethodError) #; ScintillaNet::INativeScintilla.BackTab() # undefined method BackTab’ for ScintillaNet::INativeScintilla:Module (NoMethodError)
puts “fence”
end
end

ScintillaNet::Scintilla.ztest2()
puts “done”

The three approaches above yield the errors to the right of each line.

Thanks in advance for any assistance you might be able to provide.
–John

On Fri, May 20, 2011 at 10:30 PM, John Cawley III [email protected]
wrote:

I am attempting to call an interface method for a .net class and am
having difficulty. I’m using IronRuby v1.1.2 and working with
ScintillaNet, a .net wrapper for the Scintilla control.

John, I’m a little unclear about the problem you’re trying to solve
… I’ve got some questions inline:

A portion of the ScintillaNet::Scintilla class is below:

namespace ScintillaNet
{

public partial class Scintilla : Control, INativeScintilla,
ISupportInitialize
{

Is BackTab implemented in any other partial C# class of Scintilla? If
not, than you should be getting a compiler error …

void BackTab();

}
}

I came across another forum discussion
http://rubyforge.org/pipermail/ironruby-core/2009-January/003520.html,
which seems to fall along the lines of what I’m trying to do, but I’m
not sure the features discussed there are implemented yet.

That thread is about calling explicit interface methods, which we do
now support, though the API needs some work:
http://ironruby.codeplex.com/workitem/1594.

I’ve reduced the troublesome code to a relatively short length to play
with alternative approaches:

require “bin/ScintillaNet”
class ScintillaNet::Scintilla
include ScintillaNet::INativeScintilla

How come your including this interface here? In C# this class already
implements INativeScintilla …

def self.ztest2()
z = ScintillaNet::Scintilla.new()
puts “z[#{z}]”
#; z.BackTab() # undefined method `BackTab’ for
ScintillaNet.Scintilla:ScintillaNet::Scintilla (NoMethodError)

This works if I implement BackTab in this class, but again not sure if
that’s what you’re trying to do…

#; ScintillaNet::INativeScintilla(z).BackTab() # undefined method
`INativeScintilla’ for ScintillaNet:Module (NoMethodError)

This is invalid IronRuby; .NET interfaces are exposed to IronRuby as
ruby modules, and here you’re using a module as a method.

#; ScintillaNet::INativeScintilla.BackTab() # undefined method
`BackTab’ for ScintillaNet::INativeScintilla:Module (NoMethodError)

Also invalid as INativeScintilla is basically a module without any
actual methods implemented on it, as a .NET interface doesn’t have
method implementations.

–John
Let me know if you can clear those things up …

~Jimmy

And that does it! Thank you, Jimmy!

Summarizing: I was trying to use the ScintillaNet control from IronRuby.
The main class in the ScintillaNet DLL is ScintillaNet::Scintilla, and
I’d been able to invoke its methods and work with its properties from
IronRuby just fine. That class also implements the INativeScintilla
interface, but I was having difficulty working with the methods and
properties of that interface from IronRuby. Accessing those was the
goal.

From .net, you should be able to access those with code like this:

((INativeScintilla)scintilla).BackTab()

The equivelent in IronRuby (thanks to your reference to Work Item 1594,
http://ironruby.codeplex.com/workitem/1594) is:

scintilla.clr_member( ScintillaNet::INativeScintilla, :BackTab ).call

That was the mechanism I was reaching around for.

Thanks again,
–John

I’m hoping to do some work to fix some of the bugs in IronRuby’s visual
studio integration, but I’m having a few issues getting a dev
environment
up and running.

  • I can build IronStudio.sln from the Solutions folder, and my modified
    version of the IronRuby tools loads in the visual studio experimental
    instance and is fine.
  • I can build the full IronRuby installer, and when I install it, my
    modified version of IronRuby tools loads in the normal visual studio
    instance.

But, I can’t figure out how I can build a modified version of IronRuby
tools and run it in a normal instance without doing the full MSI release
build.
Simply building the tools and then launching a normal visual studio
instance produces this error message when I open any solution:


Microsoft Visual Studio

The ‘Microsoft.IronRubyTools.IronRubyToolsPackage, IronRubyTools,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=7f709c5b713576e1’
package
did not load correctly.

The problem may have been caused by a configuration change or by the
installation of another extension. You can get more information by
running
the application together with the /log parameter on the command line,
and
then examining the file
‘C:\Users\orione\AppData\Roaming\Microsoft\VisualStudio\10.0\ActivityLog.xml’.

Continue to show this error message?

Yes No

If I click Yes, then the projects load, but this dialog reappears
whenever
I launch VS or load any solutions. If I click no, VS disables the
IronRuby
addin, and I have to run devenv /ResetSkipPkgs to put it back (and then
the error messages come back). The only way to “fix” the issue is to
uninstall/reinstall the IronRuby tools MSI itself.

Is there a way to get the non-experimental instance of visual studio to
load IronRuby tools without having to do a full build if the MSI in
release mode?

Thanks, Orion

###########################################################################
This e-mail is confidential and may contain information subject to legal
privilege. If you are not the intended recipient please advise us of
our
error by return e-mail then delete this e-mail and any attached files.
You may not copy, disclose or use the contents in any way.

The views expressed in this e-mail may not be those of Gallagher Group
Ltd or subsidiary companies thereof.
###########################################################################