Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Class not registered exception when calling a WinRT compontent after migrating to VS2013.4

I have a HTML5 application, that contains a .winmd component used for file system operations (sqlite, zip archives and so on).

After I upgraded to 2013.4 this component suddenly stopped working. Javascript still sees all the classes and function, but when I attempt to call any of them I get "WinRT: Class not registered" exception.

Full VS reinstall didn't help. Neither did upgrading to community version. This behavior is reproduced on both desktop (8.1pro) and laptop (win8.1 single language)

I spent 2 days trying to figure out what's wrong and I found that it fails as soon as component includes any asyncronous activity (like await/async or just Task.Delay(100))

So my concern is... What's going on? Where I was wrong and what can I do?

Right now installing 2015 preview. If I roll back to 2013.3 using system restore, project works fine, but VS gets in semi-broken state, and there is no link on a MS website to download previous version.

If what I say doesn't make any sense, i may upload a file with a simpliest possible VS solution to reproduce a problem. But in brief it's as simple as:

namespace NSUtil {
  public sealed class Test{
    public static IAsyncOperation<string> DoSomething () {
      return Task<string>.Run(async () => {
        await Task.Delay(100);
        return "";
      }).AsAsyncOperation();
    }
  }
}

and as soon as I call NSUtil.Test.doSomething() from javascript, i get WinRTError: Class not registered exception.

So the question is.... What's wrong with me/my pc/my vs installation/microsoft developers?

like image 588
mjr27 Avatar asked Nov 19 '14 17:11

mjr27


1 Answers

And the answer is: one should put in package.appxmanifest following lines:

<Extensions>
  <Extension Category="windows.activatableClass.inProcessServer">
    <InProcessServer>
      <ActivatableClass ActivatableClassId="MyNS.MyClass1" ThreadingModel="both" />
      <ActivatableClass ActivatableClassId="MyNS.MyClass2" ThreadingModel="both" />
      ...
      <ActivatableClass ActivatableClassId="MyNS.MyClassN" ThreadingModel="both" />
    </InProcessServer>
  </Extension>
</Extensions>

where MyNS.MyClass{N} are all classes, exposed to WinRT. For some weird reason VS2013.4 doesn't do it on its own, so I had to do it on my own

like image 169
mjr27 Avatar answered Sep 21 '22 15:09

mjr27