title: A first chance exception of type 'System.UnauthorizedAccessException' occurred in System.Windows.ni.dll
body: <p>I am trying to develop a windows phone plugin for unity3d to show admob ads. I am new to Windows Phone. I followed the steps from <a href="https://docs.unity3d.com/Documentation/Manual/wp8-plugins-guide-csharp.html" rel="nofollow noreferrer">here</a>. My code for windows phone class library class is:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Diagnostics;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using GoogleAds;
  
  namespace UnityPluginForWindowsPhone
  {
       /**
       * this class belongs to windows phone class library.
       **/
      public class TAdmob
      {
          private static string interstitialAdUnitId;
          private static InterstitialAd interstitialAd;
  
          public static void InitInterstitialAd(string adUnitId)
          {
              interstitialAdUnitId = adUnitId;
              interstitialAd = new InterstitialAd(adUnitId);           
          }
  
          public static void ShowInterstitialAd()
          {
              AdRequest adRequest = new AdRequest();
              interstitialAd.ReceivedAd += OnInterstitialAdRecieved;
              interstitialAd.LoadAd(adRequest);            
          }
  
          private static void OnInterstitialAdRecieved(object sender, AdEventArgs e)
          {
              interstitialAd.ShowAd();
          }
  
          public static string GetString()
          {
              return "Hello, Not a device";
          }
      }
  }
  </code></pre>
  
  <p>and my windows class library class is:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  
  namespace UnityPluginForWindowsPhone
  {
      /**
       * this class belongs to windows class library which is used for the unity editor.
       **/
      public class TAdmob
      {
  
          public static void InitInterstitialAd(string adUnitId)
          {
  
          }
  
          public static void ShowInterstitialAd()
          {
  
          }
      }
  }
  </code></pre>
  
  <p>and I am getting following message in the log:</p>
  
  <pre><code>'TaskHost.exe' (CoreCLR: DefaultDomain): Loaded 'C:\windows\system32\mscorlib.ni.dll'. Cannot find or open the PDB file.
  'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Windows.RuntimeHost.ni.dll'. Cannot find or open the PDB file.
  'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Windows.ni.dll'. Cannot find or open the PDB file.
  'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Net.ni.dll'. Cannot find or open the PDB file.
  'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\System.ni.dll'. Cannot find or open the PDB file.
  'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Xml.ni.dll'. Cannot find or open the PDB file.
  'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\Data\Programs\{857FF137-25B1-462A-BC86-829A1236A776}\Install\UnityPluginTestForWindowsPhone.DLL'. Symbols loaded.
  'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\Microsoft.Phone.ni.dll'. Cannot find or open the PDB file.
  'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\Microsoft.Phone.Interop.ni.dll'. Cannot find or open the PDB file.
  'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\Data\Programs\{857FF137-25B1-462A-BC86-829A1236A776}\Install\WinRTBridge.DLL'. Cannot find or open the PDB file.
  'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\Data\Programs\{857FF137-25B1-462A-BC86-829A1236A776}\Install\BridgeInterface.winmd'. Module was built without symbols.
  'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\Data\Programs\{857FF137-25B1-462A-BC86-829A1236A776}\Install\UnityPlayer.winmd'. Module was built without symbols.
  'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\WinMetadata\Windows.winmd'. Cannot find or open the PDB file.
  'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Runtime.ni.dll'. Cannot find or open the PDB file.
  'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Core.ni.dll'. Cannot find or open the PDB file.
  Build from '' branch, version is '4.3.4f1 (e444f76e01cd)' (Release build).
  
  Physical memory: 907 MB, commited memory limit: 380 MB.
  
  PlayerConnection initialized from C:/Data/Programs/{857FF137-25B1-462A-BC86-829A1236A776}/Install/Data (debug = 0)
  
  PlayerConnection initialized network socket : 0.0.0.0 55344
  
  Multi-casting "[IP] 192.168.0.114 [Port] 55344 [Flags] 2 [Guid] 352403036 [EditorId] 599262348 [Version] 1048832 [Id] WP8Player(192.168.0.114) [Debug] 0" to [225.0.0.222:54997]...
  
  Direct3D:
  
      Version:  Direct3D 11.0 [level 9.3]
  
      Renderer: Qualcomm Adreno 305 (WDDM v1.2) (ID=0x30303330)
  
      Vendor:   Qualcomm
  
      VRAM:     98 MB
  
  Initialize engine version: 4.3.4f1 (e444f76e01cd)
  
  'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\Data\Programs\{857FF137-25B1-462A-BC86-829A1236A776}\Install\UnityEngine.DLL'. Cannot find or open the PDB file.
  'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\Data\Programs\{857FF137-25B1-462A-BC86-829A1236A776}\Install\UnityEngineProxy.DLL'. Cannot find or open the PDB file.
  'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\Data\Programs\{857FF137-25B1-462A-BC86-829A1236A776}\Install\Assembly-CSharp.DLL'. Symbols loaded.
  'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\Data\Programs\{857FF137-25B1-462A-BC86-829A1236A776}\Install\GoogleAds.DLL'. Symbols loaded.
  'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\Data\Programs\{857FF137-25B1-462A-BC86-829A1236A776}\Install\UnityPluginForWindowsPhone.DLL'. Symbols loaded.
  'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'Anonymously Hosted DynamicMethods Assembly'. 
  'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\Data\Programs\{857FF137-25B1-462A-BC86-829A1236A776}\Install\UnityEngineDelegates.winmd'. Module was built without symbols.
  'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Runtime.InteropServices.WindowsRuntime.ni.dll'. Cannot find or open the PDB file.
  'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\en-US\mscorlib.debug.resources.dll'. Module was built without symbols.
  A first chance exception of type 'System.UnauthorizedAccessException' occurred in Microsoft.Phone.ni.dll
  'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Runtime.Serialization.ni.dll'. Cannot find or open the PDB file.
  A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.ni.dll
  A first chance exception of type 'System.UnauthorizedAccessException' occurred in System.Windows.ni.dll
  
  Exception: Invalid cross-thread access.
  Type: System.UnauthorizedAccessException
  Module: System.Windows
  InnerException: &lt;No Data&gt;
  AdditionalInfo:Invoking AdButton::OnMouseUpAsButton method with argument count: 0
     at MS.Internal.XcpImports.CheckThread()
     at MS.Internal.XcpImports.MessageBox_ShowCore(String messageBoxText, String caption, UInt32 type)
     at System.Windows.MessageBox.ShowCore(String messageBoxText, String caption, MessageBoxButton button)
     at System.Windows.MessageBox.Show(String messageBoxText)
     at UnityPluginForWindowsPhone.TAdmob.ShowInterstitialAd()
     at AdButton.OnMouseUpAsButton()
     at lambda_method(Closure , Object , Object[] , Int32 )
     at WinRTBridge.MethodTools.InvokeMethod(Object instance, Int32 methodIndex, Object[] args)
  
  (Filename: C:/BuildAgent/work/d3d49558e4d408f4/Runtime/Scripting/WinRTUtility.cpp Line: 65)
  </code></pre>
  
  <p>I tried to find the file that can't be access using Process Monitor, and find this. Though Can't find what it means. the out put screenshot is given below:
  <img src="https://i.stack.imgur.com/wzyVC.png" alt="output from process monitor"></p>
  
  <p>I can't figure out what to do. Can anybody know how to solve this?</p>