Windows Store App with Plugin using RuntimeComponent in C++

Hi,

We created an example project to test a plugin, but we have some errors.

The library is a test, it only returns a double value. It contains three projects:

  • Stub for Unity
  • RuntimeComponent in C++
  • Windows Store Library that uses the RuntimeComponent

First of all, if we create the build in Unity, appears the following error:

Error building Player: Exception: Failed to run Reference Rewriter with cmdline --target=“Temp/StagingArea\CS_Library.dll” --framework=“C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETCore\v4.5” --platform=“C:\Program Files (x86)\Windows Kits\8.0\References\CommonConfiguration\Neutral\Windows.winmd” --support=“Temp/StagingArea\WinRTLegacy.dll” --system=System --dbg=pdb --alt=System.Xml.Serialization --ignore=System.IConvertible,mscorlib.[Temp/StagingArea\CS_Library.dll]
Catastrophic failure while running rrw: Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: ‘WinRT_CPP, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null’

So, we put the dll in the unprocessed plugins list in PlayerSettings. Also, using [DllImport(“CS_Library”)] apparently solves this issue.

But the big problem occurs when we execute the project in Visual Studio:

The RuntimeComponent can’t be loaded.

Had someone the same error? Please, share with us how you solved this.

Thanks.

Could you create a bug with small repro attached, this scenario should work as far as I know.

You could also check if plugin is added to References section in generated solution.

Thanks to answer!

If we try to add the WinRT_CPP.dll appears this:

There is the RuntimeComponent: Dropbox - Error - Simplify your life
It has the output folders with the dll’s.

And there is the Unity project: Dropbox - Error - Simplify your life

if it’s a c++ winrt component, you need to add winmd file, not dll file.

There’s also seems to be a problem with this code:

public double Function()
{
this.rc = new RuntimeComponent();
IList<double> result = this.rc.ComputeResult(6.0);
return result.GetEnumerator().Current;
}

I am getting
A first chance exception of type ‘System.InvalidOperationException’ occurred in mscorlib.dll

I tried to call this function from App.xaml.cs, but I get same issue there, something is wrong with this implementation, but I am not sure what, try changing
return result.GetEnumerator().Current;

to

return result[0];

P.S in the future please use this section for Windows Store Apps - Unity Engine - Unity Discussions

Cheers

The C# code needs:
result.GetEnumerator().MoveNext();
That’s the error.

There is a problem with the winmd, it isn’t resolved:

Could you upload your project? We think there are some things that need to be active or similar, and we don’t know which are.

Oh by the way, are you using Visual Studio 2013 Update 4, because there’s a known bug, that it incorrectly adds WinRT C++ components to AppXManifest file

Here’s the exported project without Players folder - https://oc.unity3d.com/public.php?service=files&t=86e867e1008360a6054bfbc5af64710d.

Here’s what I did:

  • Opened project with Unity 4.6.1f1
  • Fixed error in plugin “return result.GetEnumerator().Current;”
  • Built to Windows Store Apps SDK 8.0
  • Opened exported Visual Studio solution
  • Build & Run

Oh, we don’t know this bug… We have the version 12.0.21005.1 REL. How we know if we have the update?

Which version of visual studio we need?

Thanks a lot for your help.

That version should be fine - it’s not affected.

Did you try building the application? I wouldn’t mind the exclamation marks in the references window - chance are they will go away once you run the application.