0

I create new project (Windows Store application in Javascript). Then, I add to project new Windows Runtime Component (Class1.cs class is generated). If I call the component from JavaScript I get error:

0x800a1391 - JavaScript runtime error: 'Component' is undefined

default.js

var eventMan = new Component.Class1();

Class1.cs

namespace Component
{
    public sealed class Class1
    {
    }
}

1 Answer 1

1

After adding the component project to your solution, right-click on the References in the JS project, select Add Reference, and in that dialog click "Solution" on the left and make sure your component is checked on the right. This is what wires up the component's namespace into JS. I suspect you're missing this step.

By the way, be mindful that using a C# component with JS incurs greater memory overhead to load the CLR (i.e. a second managed environment). We recommend writing components in C++ for use with JS. My blog post on this gives a few more details.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.