DotNetfromJava
.Net from java, Access any .NET Object and invoke any of its members via reflection
The intended purpose of this software API is to provide access to the .NET APIs, widening in this way the available java APIs. (For the moment is available only for windows systems)
To start development using dotnetfromjava you need the gr.dotnetfromjava.cpp.dll and dotnetfromjava.jar binaries.
Then after these files are addded to your project you have to initialize the dotnetfromjava native bridge. This can be done with the following method call:
NETManager.initialize();
When the bridge is initialized it pins the .NET Objects to the memory so that they will NOT get garbage collected. Because of the above restriction you have to initalize the bridge before you invoke any method and destroy it after you have finished with your .NET Invocations.
After you finish with all the native calls you can release any native resources that are beign held with the following method call
int res = NETManager.destroy();
// if (res==0) success
// else failure
By releasing a java object , it will also release its peer resources its from the dotnetfromjava registry and will eventually garbage collected from the .NET GC.
After we create the bridge we can create any .Net Object by passing the appropriate arguments to the NetObject constructor.
Examples:
NetObject dotnetObject = new NetObject("mscorlib.dll","System.Object");
NetObject customObject =
new NetObject("C:\\","my.dll","my.full.namespace.object",
new NetObject[]{dotnetObject});
After we create an .NEtObject we can invoke any method in that object via one of the following method calls:
# invokeSetMethod
# invokeGetMethod
# invokeSetProperty
# invokeGetProperty
# invokeSetField
# invokeGetField
All of the above methods are overloaded. You can invoke a member with just its name and its parameters (if any).
ie. (Windows Form creation and method invocation)
NetObject form = new NetObject("System.Windows.Forms.dll",
"System.Windows.Forms.Form");
form.invokeSetMethod("set_Text", new NetObject[]{new NetString("Form bar Text")});
The aforementioned method invocations exist similarly for static methods.
A static method can be invoked via the following way.
NetObject.invokeStaticSetMethod("mscorlib.dll", "System.Console", "WriteLine",new
NetBase[]{new NetString("Tsa...")});
For further documentation and examples you may view the javadocs and/or the examples subpackage as well as the official dotnetfromjava website
.NetfromJava provides also a sample .Net2java code geberator for extracting classs out of the assemblies





1 comments:
I am getting the same error that many people are getting
gr.DotNetFromJava.cpp.dll: This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem
can someone help with this?
the issue is not finding the libraries since it does, but using the library.
Post a Comment