aspose file tools*
The moose likes Other Languages and the fly likes How do I run methods in .Net objects (C#, VB, etc) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Other Languages
Bookmark "How do I run methods in .Net objects (C#, VB, etc)" Watch "How do I run methods in .Net objects (C#, VB, etc)" New topic
Author

How do I run methods in .Net objects (C#, VB, etc)

Alejandro Barrero
Ranch Hand

Joined: Aug 01, 2005
Posts: 319
I haven't found a clear answer in the Internet.


Your help will be greatly appreciated,
Alejandro Barrero
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

Alejandro Barrero wrote:I haven't found a clear answer in the Internet.


.NET languages can call methods of .NET objects, regardless of what language the .NET objects are developed in.

In the case of Java, and I am assuming you are trying to do it from java, one possibly is to use JNI. JNI will enable java to call C/C++ wrappers, which can then be used to get to .NET. From C++, the easiest path to .NET is probably to managed C++, as managed C++ is a .NET language, and the Microsoft compiler can compile code with both managed (for .NET) and unmanaged (for JNI) components.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Alejandro Barrero
Ranch Hand

Joined: Aug 01, 2005
Posts: 319
Thank you very much for your prompt reply. I have learned that I can execute functions in another language using JNDI and I have also been reading about JNA. I understand that I can execute functions from a DLL or a lib and I could probably code to that; but I am faced with a situation where I have to execute a method from an instance of an object and I am at a loss.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

Alejandro Barrero wrote:Thank you very much for your prompt reply. I have learned that I can execute functions in another language using JNDI and I have also been reading about JNA. I understand that I can execute functions from a DLL or a lib and I could probably code to that; but I am faced with a situation where I have to execute a method from an instance of an object and I am at a loss.


First, I don't think that JNDI is an option here. JNDI is used to get object stubs for application server objects, or services (such as CORBA) objects. I don't think that there is an implementation of JNDI that will return object stubs for .NET components. I may be wrong here, so feel free to examine some more -- but I don't know of such an implementation.

As for JNI (and maybe JNA), these are low level libraries that get you from Java to another language. With this, you can get to what you want, however, you need to implement wrapper stuff. In other words, you need to implement your own object stubs.

Henry
 
wood burning stoves
 
subject: How do I run methods in .Net objects (C#, VB, etc)