Amit Goyal

Hi all,
I created a jscript dll using jsc compiler. Now I want to use its functions from vc++. What is the best way to do it I tried various ways but did not succeed. Here are the details :

1. I added the reference to dll as : right click on project name -> add reference -> browse to myjs.dll. But when I define and call the class (foo) constructor, I get an error saying

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module.

Additional information: File or assembly name myjs.dll, or one of its dependencies, was not found.


2. When I use LoadLibrary and GetProcAddress functions, it always returns the function pointer as null. Here is the code :

using namespace myjs;
HINSTANCE hinst = LoadLibrary("C:\\Documents and Settings\\amit\\My Documents\\Visual Studio Projects\\MyFirst\\myjs.dll");
EntryPointfuncPtr LibMainEntryPoint, LibMainEntryPoint1;
if(hinst!=0) {
LibMainEntryPoint = (EntryPointfuncPtr)GetProcAddress(hinst,"foo");
LibMainEntryPoint1 = (EntryPointfuncPtr)GetProcAddress(hinst,"bar");
}
The flow enters the if condition but both LibMainEntryPoint and LibMainEntryPoint are NULL.

Here is the jscript file :

package myjs {
public class foo {
function foo() {
}
function bar() {
}
}


Any ideas

Thanks,
Amit


Re: Visual C++ Language calling jscript dll function from c++

Alexander Stoyan

Your approach is wrong.

U should use ActiveScript techology to work with scripts. Start from http://msdn.microsoft.com/library/default.asp url=/library/en-us/script56/html/d8acee11-7f0d-4999-b97a-66774af16f71.asp.






Re: Visual C++ Language calling jscript dll function from c++

Amit Goyal

Alexander Stoyan wrote:

Your approach is wrong.

U should use ActiveScript techology to work with scripts. Start from http://msdn.microsoft.com/library/default.asp url=/library/en-us/script56/html/d8acee11-7f0d-4999-b97a-66774af16f71.asp.



I have tried that. Infact, we have successfully run some jscript from C++. But when we call OpenFileDialog (to pick a file from filesystem), it throws error saying OpenFileDialog undefined. Since it is defined in System.Windows.Forms namespace, we need to import the namespace.
And when we import namespace (like import System;), it again says "System" undefined. Any ideas what is wrong with that

Anyways, I am still wondering why DLL should not work as the .NET framework converts the script code into MSIL.

Thanks,
Amit Goyal