How to access the JSIL base library (from C #) on a web page?

I am trying to start with JSIL . As far as I understand, I followed the directions. I have a very simple C # project with code:

namespace TestLib
{
    public class MagicType
    {
        public int Multiply(int x, int y)
        { // test instance method
            return x * y;
        }
        public static int Add(int x, int y)
        {// test static int method
            return x + y;
        }
    }
}

I compiled this with help jsilcand created a website that hosts this along with jsil scripts. My html initializes this:

<script type="text/javascript">
    var jsilConfig = {
        libraryRoot: '/js/jsil/',
        scriptRoot: '/js/testlib/',
        manifestRoot: '/js/testlib/',
        manifests: ['TestLib.dll'] // gets as far as Loading '/js/testlib/TestLib.dll.manifest.js'...
                                   // which is 200 / OK
    };
    var asm = null;
    var runMain = function () { // doesn't get invoked
        console.log('> main');
        asm = JSIL.GetAssembly("TestLib", true); // (executed outside method) returns a stub with no content
        console.log('< main');
    };
</script>
<script src="/js/jsil/jsil.js"></script>

but ... I cannot access the library. The console output indicates that it is loading:

Loading '/js/testlib/TestLib.dll.manifest.js'...

which is 200 OK. However, I cannot access it. If I run:

var asm = JSIL.GetAssembly("TestLib", true);

then I return the stub to the library, but there is nothing in it. There is a asm.$typesByName, but it is an empty object. What I want to do (to see it work) is to call methods Multiplyand Add.

: ? , js, , , . . : https://github.com/mgravell/jsilfun

+4
1

, JSIL : , , , - , DOM . , , .

onLoad (, ), . <body onload="onLoad()"> - , .

+4

Source: https://habr.com/ru/post/1678013/


All Articles