Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Windows Store App with Plugin using RuntimeComponent in C++

Discussion in 'Windows' started by plungeInt_sergi, Dec 18, 2014.

  1. plungeInt_sergi

    plungeInt_sergi

    Joined:
    Dec 18, 2014
    Posts:
    4
    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.
     
  2. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,658
    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.
     
  3. plungeInt_sergi

    plungeInt_sergi

    Joined:
    Dec 18, 2014
    Posts:
    4
  4. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,658
    if it's a c++ winrt component, you need to add winmd file, not dll file.
     
  5. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,658
    There's also seems to be a problem with this code:
    Code (csharp):
    1.  
    2. public double Function()
    3. {
    4. this.rc = new RuntimeComponent();
    5. IList<double> result = this.rc.ComputeResult(6.0);
    6. return result.GetEnumerator().Current;
    7. }
    8.  
    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 - http://forum.unity3d.com/forums/windows-development.50/

    Cheers
     
    Last edited: Jan 2, 2015
  6. plungeInt_sergi

    plungeInt_sergi

    Joined:
    Dec 18, 2014
    Posts:
    4
    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.
     
  7. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,658
    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
     
  8. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,658
  9. plungeInt_sergi

    plungeInt_sergi

    Joined:
    Dec 18, 2014
    Posts:
    4
    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.
     
    Last edited: Jan 8, 2015
  10. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,491
    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.