B4J Programming Press on the image to return to the main documentation page.

jDotNetBridge

Written by Andrew Graham

This library is a demonstration of how to interface to a C# or VB.NET managed library.
You will need to modify and recompile it to match the managed library you want to use.
There is more information on this in the document UnmanagedExports.rtf in the library archive.

This particular library shows that it is possible for a B4J Java library to access a Windows COM or ActiveX object
using COM Interop via a .NET Framework library. In this case the COM object is the MS Script Control.

This library uses the JNA libraries to call native code methods in a .NET library that have been exported by UnmanagedExports
written by Robert Giesecke.

The JNA libraries are licensed under the LGPL, version 2.1 or later, and (from version 4.0 onward)
also the Apache Software License, version 2.0

This library is therefore also licensed under those licences.

UnmanagedExports is licensed by Robert Giesecke under the MIT License but as the managed dll modified by its' use
contains none of the UnmanagedExports code I believe this license applies only to the actual use of UnmanagedExports.
http://opensource.org/licenses/mit-license.php

List of types:

DotNetBridge

DotNetBridge

The DotNetBridge object allows access to the methods of a C# MSScript.dll library that has been processed by
the UnmanagedExports NuGGet written by Robert Giesecke to make it callable from a B4J Java library via JNA.
https://www.nuget.org/packages/UnmanagedExports

The C# library exposes the Microsoft ActiveX Script Control which can execute JavaScript and VBScript.
Here it is initialized for VBScript.

There is very little documentation for the MSScript Control, I obtained that in the xml comments from here.
http://msdn.microsoft.com/en-us/library/aa227633(v=vs.60).aspx.

Events:

None

Members:


  About

  AddCode (scriptcode As String)

  ClearError

  DotNetLibraryName As String

  DotNetLibraryVersion As Double

  ErrorColumn As Int

  ErrorDescription As String

  Errored As Boolean

  ErrorLine As Int

  ErrorNumber As Int

  ErrorSource As String

  ErrorText As String

  Eval (expression As String) As String

  ExceptionFlag As Boolean

  ExceptionMsg As String

  ExecuteStatement (statement As String)

  Initialize

  Reset

  ResultType As String

  Run (startsub As String, subparams() As String) As String

  SetAllowUI (value As Boolean)

  SetScriptTimeout (value As Int)

  SetUseSafeSubset (value As Boolean)

  TimedOut As Boolean

  Version As Double [read only]

Members description:

About
Cause the Script Control to display its' About box.
AddCode (scriptcode As String)
Add the provided code to the script of the Script Control.
ClearError
The ClearError method is used to reset the Error object.
Using the AddCode, Eval, ExecuteStatement, or Reset methods will also clear the Error object before these methods begin processing.
DotNetLibraryName As String
Returns the name of the .NET MSScript library.
DotNetLibraryVersion As Double
Returns the version number of the .NET MSScript library.
ErrorColumn As Int
Returns the source code column number where the error occurred.
ErrorDescription As String
Returns a description of the error.
Errored As Boolean
Returns True if an error occurred during script execution. The other ErrorXxxx methods give more information
ErrorLine As Int
Returns the source code line number where the error occurred
ErrorNumber As Int
Returns the error number.
ErrorSource As String
Returns a description of the general type of error.
ErrorText As String
Returns the line of source code where the error occurred.
Eval (expression As String) As String
Evaluate an expression and return the result.
ExceptionFlag As Boolean
Returns True if an Exception occurred running a script or evaluating an expression.
ExceptionMsg As String
Returns the message of whatever Exception occurred when running a script or evaluating an expression.
ExecuteStatement (statement As String)
Execute the single provided VBScript statement.
Initialize
Initialise an instance of our .NET library Interface so we can call its' methods.
Reset
Reinitializes the scripting engine.
ResultType As String
Returns the original type of the result as the actual result is converted to a string value by Eval and Run.
Run (startsub As String, subparams() As String) As String
Run a pre-loaded script by calling the named Sub or Function with the supplied parameters.
If a Function was called the return value of that Function is returned.
SetAllowUI (value As Boolean)
When set to True, means that the script program can display user interface (UI) elements such as a MsgBox or InputBox.
SetScriptTimeout (value As Int)
Sets the maximum amount of time in mS that a script can run before a warning message is displayed (if the AllowUI property is True).
-1 = no timeouts will occur.
0 = the ScriptControl will monitor the execution of the script and will trigger the Timeout event if it determines that the script is hung.
SetUseSafeSubset (value As Boolean)
When set True prevents access to selected objects and procedures that can compromise an applications' security.
TimedOut As Boolean
Returns True if the script timed out.
Version As Double [read only]
Returns the version number of the library.
Top