Search code examples
c#windows-phone-8.1lumia-imaging-sdk

How to workaround missing ActivatableAttribute for a class


We are using the Lumia.Imaging.SDK 2.0 in a Windows Phone 8.1 Runtime app. For some reason, Microsoft failed to set the ActivatableAttribute on the Lumia.Imaging.RandomAccessStreamImageSource class. Consequently, this class does not get marked as an ActivatableClass in the appxmanifest.xml. Of course, trying to instantiate this class leads to the following error.

A first chance exception of type 'System.TypeLoadException' occurred in MyApp.exe Requested Windows Runtime type 'Lumia.Imaging.RandomAccessStreamImageSource' is not registered.

Does anyone know how I can register this class as activatable from C# at run time? Or, is there a way to "hack" the Lumia.Imaging.winmd to include the ActivatableAttribute?

Thanks for your help.


Solution

  • I had the same problem. Here is working solution. Add these lines to the Package.appxmanifest manually (use any text editor):

      <Extensions>
        <Extension Category="windows.activatableClass.inProcessServer">
          <InProcessServer>
            <Path>Lumia.Imaging.dll</Path>
            <ActivatableClass ActivatableClassId="Lumia.Imaging.RandomAccessStreamImageSource" ThreadingModel="both" />
          </InProcessServer>
        </Extension>
      </Extensions>
    

    before

    </Package>
    

    Make sure that your main (executable) library has reference on Lumia.Imaging.dll