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 8.1 - System.TypeLoadException when adding SDKs

Discussion in 'Windows' started by skaarjslayer, Dec 2, 2014.

  1. skaarjslayer

    skaarjslayer

    Joined:
    Oct 10, 2013
    Posts:
    108
    Hey,

    Here's a fun problem. When creating a blank Unity project with an empty scene, building it to Windows 8.1, and adding certain SDKs in the Visual Studio solution, the project crashes on deployment. It builds fine, but when it starts to run it gets a System.TypeLoadException in the App.xaml.cs constructor App(), at appCallbacks = new AppCallbacks(false);

    The error is as follows:

    "An exception of type 'System.TypeLoadException' occurred in Template.exe but was not handled in user code

    Additional information: Requested Windows Runtime type 'UnityPlayer.AppCallbacks' is not registered."

    The certain SDK in question is the Microsoft Advertising SDK for Windows 8.1. When I remove the reference, the project runs fine again. Add it again, the app crashes. I do not access any of the API of the SDK in any way, simply adding the reference to the project causes the problem.

    I am running Unity 4.5.5p5 and the issue occurs whether you build to Windows 8.1 alone or build a Universal 8.1 project. No issues occur if you add the SDK to a blank Windows Store App in Visual Studio (with no relation to Unity). This problem also occurs when adding the AdDuplex Windows 8.1 SDK (installable through NuGet).

    What do?
     
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,627
    What are your export settings when building from Unity (SDK, C# projects, etc.) ?
     
  3. skaarjslayer

    skaarjslayer

    Joined:
    Oct 10, 2013
    Posts:
    108
    XAML C# Solution
    SDK 8.1 (also does it if you choose Universal 8.1)
    Unity C# Projects and Development Build are unchecked
     
  4. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,627
    We have a reported bug that this failure happens using VS2013 Update 4.
    Is that the case for you?
     
  5. skaarjslayer

    skaarjslayer

    Joined:
    Oct 10, 2013
    Posts:
    108
    Well I do have VS2013 Update 4 installed because it's essential to have that update in order to even use Universal 8.1. Where can I see this bug report?
     
  6. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,658
    Unity libraries for Universal apps are built with VS 2013 Update 3, there may be an incompatibility here
     
  7. skaarjslayer

    skaarjslayer

    Joined:
    Oct 10, 2013
    Posts:
    108
    Okay that makes sense. When I didn't have the required SDKs to build in Universal 8.1 the Microsoft site told me to just upgrade to the latest version (which is Update 4) so I did that. I'll downgrade to Update 3 and see if that resolves the issue.
     
  8. skaarjslayer

    skaarjslayer

    Joined:
    Oct 10, 2013
    Posts:
    108
    I had to completely uninstall Visual Studio 2013 and install Update 3, because apparently you can't downgrade. In the end, it worked and the project runs fine now even with those references. It seems like it'd be a major pain for anyone stuck in this kind of situation because Microsoft wants you to upgrade to Update 4, which a lot of people would do only to find out (in no obvious way) that they can't develop properly for Windows 8.1 on Unity.
     
    Last edited: Dec 3, 2014
    sotteson likes this.
  9. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,491
    I suppose we'll have to update then!
     
  10. zezba9000

    zezba9000

    Joined:
    Sep 28, 2010
    Posts:
    983
    What Unity3D versions do you think will get a patch or update for this?
    Unity4.5.x or Unity4.6.x? As long as Unity4.6.x gets an update I think people should be fine.
     
  11. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,491
    We'll first need to investigate the issue in the first place - it might be that the VS version might not be actually the issue here. It was a shot in the dark, but it doesn't mean it's a correct one :).
     
  12. sotteson

    sotteson

    Joined:
    Nov 29, 2014
    Posts:
    5
    I just ran into this too. I thought it was because I updated to Unity 4.6, but now I realize it was because I upgraded VS to Update 4. I guess I'll have to go back to Update 3. Ugh.
     
  13. sotteson

    sotteson

    Joined:
    Nov 29, 2014
    Posts:
    5
    Uninstalled VS with Update 4, and reinstalled with Update 3. It's still broken, though. I'm not sure what to try at this point. I can no longer build and launch a Unity app on Win 8.1 if the app uses the advertising SDK.
     
  14. zezba9000

    zezba9000

    Joined:
    Sep 28, 2010
    Posts:
    983
    @sotteson Wondering if you have tried Unity4.6 Patch 1? Looks like it had some stuff fixed for Win8 but have not tried it yet.
     
  15. sotteson

    sotteson

    Joined:
    Nov 29, 2014
    Posts:
    5
    I just tried 4.6.0p1 and it's still broken.
     
  16. Jenzo83

    Jenzo83

    Joined:
    Oct 22, 2013
    Posts:
    34
    We are facing this issue as well. Will try to downgrade visual studio. Currently I'm downgrading unity, because I thought that was the reason.

    Does not seem to work with Visual Studio 2013 - Express - Update 3. (win 8.1)

    Working solution: Use Visual Studio 2012 - with Win 8.0 as SDK.
     
    Last edited: Dec 6, 2014
  17. MasoInar

    MasoInar

    Joined:
    Feb 20, 2014
    Posts:
    125
    Hi,

    I got same error. I Have Visual Studio Premium 2013 Update 4 (Version 12.0.31101.00) and Unity 4.6.1p1

    Any update on this problem, because downgrading visual studio isn't an option for me?

    Edit. I removed Microsoft Ad SDK reference and got it working. I've already filed one bug report on MS ads not working on Windows Phone
     
  18. Ignas83

    Ignas83

    Unity Technologies

    Joined:
    Mar 26, 2013
    Posts:
    28
    Microsoft acknowledged there's a bug in Visual Studio 2013 Update 4 and it will get fixed in the near future. In the meantime you can either downgrade to Update 3 or manually edit AppxManifest.xml after build (the problem is that UnityPlayer.dll extension is removed and it needs to be readded). If none of this works for you please leave me a private message and I'll try to help you.
     
  19. MasoInar

    MasoInar

    Joined:
    Feb 20, 2014
    Posts:
    125
    Can you provide some information on how to edit AppxManifest.xml after build?
     
  20. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,658
    Here's how correct AppxManifest.xml file looks like:

    Code (CSharp):
    1.  
    2. <?xml version="1.0" encoding="utf-8"?>
    3. <Package xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest" xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:build="http://schemas.microsoft.com/developer/appx/2012/build" IgnorableNamespaces="build">
    4.   <!--
    5.     THIS PACKAGE MANIFEST FILE IS GENERATED BY THE BUILD PROCESS.
    6.  
    7.     Changes to this file will be lost when it is regenerated. To correct errors in this file, edit the source .appxmanifest file.
    8.  
    9.     For more information on package manifest files, see http://go.microsoft.com/fwlink/?LinkID=241727
    10.   -->
    11.   <Identity Name="testtt" Publisher="CN=DefaultCompany" Version="1.0.0.0" ProcessorArchitecture="x86" />
    12.   <Properties>
    13.     <DisplayName>testtt</DisplayName>
    14.     <PublisherDisplayName>DefaultCompany</PublisherDisplayName>
    15.     <Logo>Assets\StoreLogo.png</Logo>
    16.   </Properties>
    17.   <Prerequisites>
    18.     <OSMinVersion>6.3.0</OSMinVersion>
    19.     <OSMaxVersionTested>6.3.0</OSMaxVersionTested>
    20.   </Prerequisites>
    21.   <Resources>
    22.     <Resource Language="EN-US" />
    23.   </Resources>
    24.   <Applications>
    25.     <Application Id="App" Executable="Template.exe" EntryPoint="testtt.App">
    26.       <m2:VisualElements DisplayName="testtt" Square150x150Logo="Assets\MediumTile.png" Square30x30Logo="Assets\SmallLogo.png" Description="testtt" ForegroundText="light" BackgroundColor="#000000">
    27.         <m2:DefaultTile Wide310x150Logo="Assets\WideTile.png" DefaultSize="square150x150Logo" />
    28.         <m2:SplashScreen Image="Assets\SplashScreen.png" />
    29.       </m2:VisualElements>
    30.     </Application>
    31.   </Applications>
    32.   <Capabilities />
    33.   <Dependencies>
    34.     <PackageDependency Name="Microsoft.VCLibs.120.00.Debug" MinVersion="12.0.21005.1" />
    35.   </Dependencies>
    36.   <Extensions>
    37.     <Extension Category="windows.activatableClass.inProcessServer">
    38.       <InProcessServer>
    39.         <Path>UnityEngineDelegates.dll</Path>
    40.         <ActivatableClass ActivatableClassId="UnityEngineDelegates.FunctionDefsDictionary" ThreadingModel="both" />
    41.         <ActivatableClass ActivatableClassId="UnityEngineDelegates.PlatformInvoke" ThreadingModel="both" />
    42.       </InProcessServer>
    43.     </Extension>
    44.     <Extension Category="windows.activatableClass.inProcessServer">
    45.       <InProcessServer>
    46.         <Path>UnityPlayer.dll</Path>
    47.         <ActivatableClass ActivatableClassId="UnityPlayer.AppCallbacks" ThreadingModel="both" />
    48.         <ActivatableClass ActivatableClassId="UnityPlayer.StreamListenerContext" ThreadingModel="both" />
    49.         <ActivatableClass ActivatableClassId="UnityPlayer.MulticastSocketContext" ThreadingModel="both" />
    50.         <ActivatableClass ActivatableClassId="UnityPlayer.XamlPageAutomationPeer" ThreadingModel="both" />
    51.       </InProcessServer>
    52.     </Extension>
    53.     <Extension Category="windows.activatableClass.inProcessServer">
    54.       <InProcessServer>
    55.         <Path>CLRHost.dll</Path>
    56.         <ActivatableClass ActivatableClassId="WinRTBridge.Marshalling" ThreadingModel="both" />
    57.         <ActivatableClass ActivatableClassId="WinRTBridge.MethodTools" ThreadingModel="both" />
    58.         <ActivatableClass ActivatableClassId="WinRTBridge.SerializationReader" ThreadingModel="both" />
    59.         <ActivatableClass ActivatableClassId="WinRTBridge.SerializationWriter" ThreadingModel="both" />
    60.         <ActivatableClass ActivatableClassId="WinRTBridge.ObjectInstantiation" ThreadingModel="both" />
    61.         <ActivatableClass ActivatableClassId="WinRTBridge.TypeInformation" ThreadingModel="both" />
    62.         <ActivatableClass ActivatableClassId="WinRTBridge.ArrayTools" ThreadingModel="both" />
    63.         <ActivatableClass ActivatableClassId="WinRTBridge.ScriptingPinnedArray" ThreadingModel="both" />
    64.         <ActivatableClass ActivatableClassId="WinRTBridge.GCHandles" ThreadingModel="both" />
    65.         <ActivatableClass ActivatableClassId="WinRTBridge.GCHandledObjects" ThreadingModel="both" />
    66.         <ActivatableClass ActivatableClassId="WinRTBridge.Utils" ThreadingModel="both" />
    67.         <ActivatableClass ActivatableClassId="WinRTBridge.WinRTBridge" ThreadingModel="both" />
    68.         <ActivatableClass ActivatableClassId="WinRTBridge.UnityEngineObjectTools" ThreadingModel="both" />
    69.         <ActivatableClass ActivatableClassId="WinRTBridge.ExceptionHandling" ThreadingModel="both" />
    70.         <ActivatableClass ActivatableClassId="WinRTBridge.MonoBehaviourSerialization" ThreadingModel="both" />
    71.       </InProcessServer>
    72.     </Extension>
    73.   </Extensions>
    74.   <build:Metadata>
    75.     <build:Item Name="TargetFrameworkMoniker" Value=".NETCore,Version=v4.5.1" />
    76.     <build:Item Name="VisualStudio" Version="12.0" />
    77.     <build:Item Name="VisualStudioEdition" Value="Microsoft Visual Studio Ultimate 2013" />
    78.     <build:Item Name="OperatingSystem" Version="6.3.9600.16384 (winblue_rtm.130821-1623)" />
    79.     <build:Item Name="Microsoft.Build.AppxPackage.dll" Version="12.0.30501.0" />
    80.     <build:Item Name="Microsoft.Windows.UI.Xaml.Build.Tasks.dll" Version="12.0.30501.0" />
    81.     <build:Item Name="MakePri.exe" Version="6.3.9600.17029 (winblue_gdr.140219-1702)" />
    82.   </build:Metadata>
    83. </Package>
    84.  
    85.  
    It's located in bin\<x86|ARM>\<Debug|Release|Master>

    Check that this part is not missing:
    Code (CSharp):
    1.  
    2.     <InProcessServer>
    3.         <Path>UnityPlayer.dll</Path>
    4.         <ActivatableClass ActivatableClassId="UnityPlayer.AppCallbacks" ThreadingModel="both" />
    5.         <ActivatableClass ActivatableClassId="UnityPlayer.StreamListenerContext" ThreadingModel="both" />
    6.         <ActivatableClass ActivatableClassId="UnityPlayer.MulticastSocketContext" ThreadingModel="both" />
    7.         <ActivatableClass ActivatableClassId="UnityPlayer.XamlPageAutomationPeer" ThreadingModel="both" />
    8.       </InProcessServer>
    9.  
    10.  
     
    timthecoder and MasoInar like this.
  21. MasoInar

    MasoInar

    Joined:
    Feb 20, 2014
    Posts:
    125
    Thanks for help Tomas1856.

    That part is missing indeed. Can I just open .appxupload zip-package and insert those lines in AppxManifest.xml file and then re-zip the package?

    I tried to edit AppxManifest.xml in bin\Arm\Master folder, but creating app packages overrides those changes..

    Btw. Does anyone know is this bug fixed in Visual Studio 2013 Update 5 CTP 1?
     
  22. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,491
    I don't think you can just re-zip it with regular zipping program, but you should be able to do it with a command line tool that's in Windows SDK folder. Here's the path on my machine:

    "C:\Program Files (x86)\Windows Kits\8.1\bin\x86\makeappx.exe"
     
    MasoInar likes this.
  23. grofie

    grofie

    Joined:
    Dec 9, 2013
    Posts:
    30
    I just tried it with Visual Studio 2013 Update 5 CTP 1, the problem is still unfixed -_-
     
  24. LinderBoss

    LinderBoss

    Joined:
    May 1, 2014
    Posts:
    8
    I have the same problem. As a workaround I did the following

    1. Right click on Package.appxmanifest inside VS 2013.4
    2. Select the View Code Option.
    3. Add the code below (based on Tomas1856's comment above) after the Capabilities section :

    Code (CSharp):
    1. <Extensions>
    2. <ExtensionCategory="windows.activatableClass.inProcessServer">
    3. <InProcessServer>
    4. <Path>UnityPlayer.dll</Path>
    5. <ActivatableClassActivatableClassId="UnityPlayer.AppCallbacks"ThreadingModel="both" />
    6. <ActivatableClassActivatableClassId="UnityPlayer.StreamListenerContext"ThreadingModel="both" />
    7. <ActivatableClassActivatableClassId="UnityPlayer.MulticastSocketContext"ThreadingModel="both" />
    8. <ActivatableClassActivatableClassId="UnityPlayer.XamlPageAutomationPeer"ThreadingModel="both" />
    9. </InProcessServer>
    10. </Extension>
    11. </Extensions>
     
  25. zezba9000

    zezba9000

    Joined:
    Sep 28, 2010
    Posts:
    983
    FYI, I also get TypeLoadExceptions when targeting Windows Phone 8.1 in random places.

    I can't wait till you guys start using the .NET Core or IL2CPP for all platforms so you don't have to do all this hacky stuff just because you're on Mono now.
     
  26. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,491
    Could we get a bug report?
     
  27. zezba9000

    zezba9000

    Joined:
    Sep 28, 2010
    Posts:
    983
    Yes I can look into getting you one of those.
     
  28. sathya

    sathya

    Joined:
    Jul 30, 2012
    Posts:
    279
    Hi, Does Win8 WP8 Unified API support windows 8.0 ? Read the doc and it says plugin supports only 8.1.
    If no is there a way to support 8.0 . My team wants to support windows 8 as well but i have purchased this plugin already. I need to implement IAP for windows 8.
     
  29. zezba9000

    zezba9000

    Joined:
    Sep 28, 2010
    Posts:
    983
    It currently does not as there has been no request for Win8.0 support anymore.
    Keep in mind Win8.0 IAP did not support consumables.
    I can add Win8.0 support if you need it but could you email: "features@reign-studios.com" with an invoice number about the request so I can keep track of this.
     
  30. zezba9000

    zezba9000

    Joined:
    Sep 28, 2010
    Posts:
    983
    I no longer get that issue anymore Tautvydas, just FYI.
    But the MS-Ads issues is still a problem.
     
  31. MasoInar

    MasoInar

    Joined:
    Feb 20, 2014
    Posts:
    125
    Hi,

    Visual studio 2013 Update 5 CTP 2 (http://www.visualstudio.com/news/vs2013-update5-vs) seems to fix the issue with incorrect AppxManifest.xml (Didn't test with actual device, because I have little problems with my Lumia right now. I just looked the file and confirmed that those UnityPlayer.xxx files exist).

    Also I'm not sure if the problem with clicking ads are fixed.. Probably not
     
  32. Grygus

    Grygus

    Joined:
    Aug 7, 2013
    Posts:
    18
    Yes this update fixed TypeLoad exception issue, but I have another issue with Advertising SDK but only for Windows Store 8.1 in the same place right after typeLoad occured, "System.IO.FileNotFoundException" occures maybe someone had that issue before?
     
  33. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,658
    Probably some file is still missing, enable exceptions via Debug->Exceptions, and when you'll hit FileNotFoundException, enter $exception in the watch window, it may contain information what file is missing.
     
  34. debuglog

    debuglog

    Joined:
    Jan 27, 2013
    Posts:
    5
    Same here. I built an empty windows store project with universal 8.1 sdk.
    At this point it runs without any errors.
    In VS 2013 update 5 CTP 3 I added the latest MS ads SDK. Now it throws FileNotFoundExcetion at start.

    Have you solved it Grygus?
     
  35. DanglingNeuron

    DanglingNeuron

    Joined:
    Dec 4, 2012
    Posts:
    37
    This issue is resolved in VS 2013 Update 5 RC ...

    Unity 4.6.4f1 - Windows Store - 8.1 - C# XAML

    Tested with Microsoft Advertisement XAML SDK.
     
    Last edited: May 9, 2015
  36. Waqas-Anwar

    Waqas-Anwar

    Joined:
    Feb 2, 2015
    Posts:
    26