Search code examples
javascriptc#.netwindows-8win-universal-app

Access Class Library from Universal Shared App


I have an Universal Shared Application which contains some Javascript/Html Code. See project structure here:

Now I want to access some native functionality which should be shared among the both projects. I tried to create a "Class Library (Universal Windows)" and "Class Library Portal for Universal Windows 8.1" but I can't neither of them reference to the Shared App.

"One or more selected items is not a valid reference for this type of project"

What am I missing? What are the restrictions for my intend?


Solution

  • Got it.

    There were two problems with my approach.

    1. You need a JavaScript Blank App (Universal Windows) - i had Windows 8.1
    2. You need to use a Windows Runtime Component (Universal Windows) for native code

    Then you can reference the RTC and use it in JavaScript.

    var cls = new rtcuw.Class1();
    var result = cls.doSomething();
    

    Keep in mind, that the function names in JavaScript are starting lowercase, even if your C# function is called DoSomeThing().