Jonas
Jonas

Reputation: 4584

Referencing a custom WinRT component breaks javascript class?

I have a javascript Windows Store application that I'm working on, and I needed to create a WinRT component for some processing. As soon as I add the reference to that component, I get a javascript error:

0x800a01bd - Javascript runtime error: Object doesn't support this action.

This occurs on a line w/ the following:

engine = new MyApp.Engine();

Which is defined:

WinJS.Namespace.define("MyApp", {
  Engine: WinJS.Class.define(function() {
    //constructor stuff
    //other stuff snipped for brevity
  }
});

I'm not even accessing any code in my custom component, simply adding the reference causes it to break. Anyone run into this? Googling/Binging has been no help.

Upvotes: 2

Views: 743

Answers (1)

Jonas
Jonas

Reputation: 4584

I found the answer.

So in my Javascript code, I had the declaration for a namespace.

In my WinRT C# component, I was using the same namespace. That namespace apparently stomps out my JS namespace declartion. I changed my WinRT component from this:

namespace MyApp
{
  public sealed class SomeClass
  {
  }
}

to:

namespace MyAppUtils
{
  public sealed class SomeClass
  {
  }
}

And now everything is good..so, Lesson: If you're using JS and a custom WinRT component, you (apparently) can't use the same namespace in both.

Upvotes: 2

Related Questions