locked
Silverlight 4 TargetInvocationException when implementing Bird's Eye and/or Streetside RRS feed

  • Question

  • I've having trouble running Bing Maps Extended Modes when targeting Silverlight 4.  What I'm trying to do is enable Bird's Eye and Streetide view modes.  If you want to know the near exact code that I'm using (I modified mine to a slightly different lat/long and created a Loaded event, but exactly the same otherwise), you can view the video "Add Enhanced Bird's Eye and Streetside" at http://www.microsoft.com/maps/developers/videos.aspx

    Otherwise, here are the XAML and CS blocks:

    ...
    
    xmlns:m="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl"
    
    ...
    
    <m:Map Name="myMap" CredentialsProvider="[my key]" 
    
        Center="25.858531, -80.2097" ZoomLevel="19" Mode="AerialWithLabels"
    
        Grid.Row="1" />
    
    ...
    
    
    ...
    
    public MainPage()
    
    {
    
     InitializeComponent();
    
    
    
     Loaded += new RoutedEventHandler(MainPage_Loaded);    
    
    }
    
    
    
    void MainPage_Loaded(object sender, RoutedEventArgs e)
    
    {
    
     BirdseyeMode.AddModeToNavigationBar(myMap);
    
     StreetsideMode.AddModeToNavigationBar(myMap);
    
    }
    
    ...
    
    

    Run the app and it throws an error.

    Here is the error when the JIT Debugger pops up:

    An unhandled exception ('Unhandled Error in Silverlight Application
    Code: 4004
    Category: ManagedRuntimeError
    Message: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeLoadException

    Clicking yes to debug that does nothing because it then says that it can't actually find the source code.

    Click no on the JIT Debugger box and then double-click the error at the bottom of IE and the box then says:

    Webpage error details

    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET4.0C; .NET4.0E; .NET CLR 3.5.30729; .NET CLR 3.0.30729; InfoPath.3; MS-RTC LM 8)
    Timestamp: Fri, 3 Sep 2010 18:35:35 UTC


    Message: Unhandled Error in Silverlight Application
    Code: 4004   
    Category: ManagedRuntimeError      
    Message: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeLoadException: Could not load type 'Microsoft.Maps.Plugins.ConfigurationService' from assembly 'Microsoft.Maps.Plugins, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c70bd40282823787'.
       at Microsoft.Maps.PluginContainer.ConcretePluginStateManager..ctor()
       at Microsoft.Maps.PluginContainer.PluginContainerControl..ctor()
       --- End of inner exception stack trace ---
       at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
       at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
       at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
       at System.Activator.CreateInstance(Type type, Boolean nonPublic)
       at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
       at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
       at System.Reflection.Assembly.CreateInstance(String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
       at System.Reflection.Assembly.CreateInstance(String typeName)
       at Microsoft.Maps.MapControl.ExtendedModes.ModeFactory.ComposeCatalog(Assembly pcAssembly, String catalog)
       at Microsoft.Maps.MapControl.ExtendedModes.ModeFactory.FrameworkReadCompleted(Object sender, OpenReadCompletedEventArgs e)
       at System.Net.WebClient.OnOpenReadCompleted(OpenReadCompletedEventArgs e)
       at System.Net.WebClient.OpenReadOperationCompleted(Object arg)    

    Line: 56
    Char: 13
    Code: 0
    URI: http://localhost:16834/Bing%20MapsTestPage.aspx

    Answers to questions that you might think to ask:

    Yes, I have all the latest SDKs -
        Microsoft Silverlight 4 SDK v4.0.50826.0
        Bing Maps Silverlight Control SDK v1.01.0
        Bing Maps Silverlight Control Extended Modes Beta v0.5.0.0

    The app works just fine before adding the two extended views, or by commenting them out, but crashes everytime when trying to implement Bird's Eye and Streetside.

    • Moved by Ricky_Brundritt Friday, March 9, 2012 5:10 PM (From:Bing Maps: Map Control and Web services Development)
    Friday, September 3, 2010 6:51 PM

Answers

  • It seems like I've found how to solve it! It was not working even in SL3 project... Still not working in SL4, but works stable in SL3  

    So - just remove Microsoft.Maps.Core / Microsoft.Maps.Plugins references and then "Build / Clear solution" to remove old XAP files. So - I have just 3 DLLs related with Bing Silverlight contrl - Microsoft.Maps.MapControl, Microsoft.Maps.MapControl.Common and Microsoft.Maps.MapControl.ExtendedModes and it's works!

    Also  - I've digged into .csproj (I'm not sure that it can helps but... who knows? :)) and I've found this:

     

        <Reference Include="Microsoft.Maps.MapControl, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c70bd40282823787, processorArchitecture=MSIL">

          <HintPath>..\..\..\Program Files (x86)\Bing Maps Silverlight Control\V1\Libraries\Microsoft.Maps.MapControl.dll</HintPath>

        </Reference>

    also there was references to Microsoft.Maps.MapControl.Common and Microsoft.Maps.MapControl.ExtendedModes. I removed (in notepad) info about public key token, assembly, culture and all other info except name of ... assembly? So - if my first workaround doesn't work - try to left just short info about assembly. So - after it should looks like this (plus other references without additional info):

     

        <Reference Include="Microsoft.Maps.MapControl">

          <HintPath>..\..\..\Program Files (x86)\Bing Maps Silverlight Control\V1\Libraries\Microsoft.Maps.MapControl.dll</HintPath>

        </Reference>

     

     

    Hope it helps :)

     

    Best regards, Maxim Grigoryev

    www.Exonya.com - software development company, offshore programming

    Thursday, November 18, 2010 12:45 PM

All replies

  • Are you trying to use the extend modes dll's with the Bing Map App Plugin API? If so, make sure your using the dll's that come from with the Map App API and not the separate extended modes dll's that you get from Microsoft connect.
    Windows Live Developer MVP - http://rbrundritt.spaces.live.com
    Sunday, September 5, 2010 10:33 PM
  • No, I am not mixing it with using the Bing Map App API.  I am simply using the following DLLs:

    Microsoft.Maps.MapControl
    Microsoft.Maps.MapControl.Common
    Microsoft.Maps.MapControl.ExtendedModes

    As mentioned above, in the really short video that I linked to, I did it exactly the way that he did.

    As a sort of update, I've been able to run it on two other computers and a VM hosting Server 2008 R2 and Windows 7.  I can't find at all what the differences are between the computers that this project won't run on and the ones that it will.  The DLLs are embedded in the project, so what is going on behind the scenes that keeps it from working on some computers?  I've tried matching SDK versions and such things.  Something is obviously blocking on three computers.  The three that I work on, so I need to figure this out.  The other computers belong to other developers, so I can't just use theirs to work on, of course.  They are all baffled, too.

    Tuesday, September 7, 2010 8:51 PM
  • I have the exact same problem.

    It does not work with VS 2010 (with either SL3 or SL4), but it does work with VS2008 SL3.

    Tom

     

    Saturday, September 11, 2010 11:32 PM
  • I wish that I had an answer by now.  Let me know if you come up with any leads.  I'm running VS2010 and when I create the exact same project and target SL3 instead of 4, it works just fine.  Taking the SL4 project and then trying to target SL3 in the project properties had some kinks, so I scrapped that idea.  The tutorial project is simple enough to recreate and I've been using it as a test point for the larger project that I'm on.  As of now, I can't develop this project directly on my own machine.  I had to import a VM that the project actually works on and I have to remote into and work on it there.  Yippee! ):|  I still can't find the difference between the machines that it works on and the ones that it doesn't.
    Monday, September 13, 2010 5:26 PM
  • Having the same problem. 

    Visual Studio 2010, Bing Maps Extended, targeting SL4 - throws the exception. 

    When changing to SL3 everything is ok.

     

    Thursday, October 14, 2010 10:27 AM
  • It seems like I've found how to solve it! It was not working even in SL3 project... Still not working in SL4, but works stable in SL3  

    So - just remove Microsoft.Maps.Core / Microsoft.Maps.Plugins references and then "Build / Clear solution" to remove old XAP files. So - I have just 3 DLLs related with Bing Silverlight contrl - Microsoft.Maps.MapControl, Microsoft.Maps.MapControl.Common and Microsoft.Maps.MapControl.ExtendedModes and it's works!

    Also  - I've digged into .csproj (I'm not sure that it can helps but... who knows? :)) and I've found this:

     

        <Reference Include="Microsoft.Maps.MapControl, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c70bd40282823787, processorArchitecture=MSIL">

          <HintPath>..\..\..\Program Files (x86)\Bing Maps Silverlight Control\V1\Libraries\Microsoft.Maps.MapControl.dll</HintPath>

        </Reference>

    also there was references to Microsoft.Maps.MapControl.Common and Microsoft.Maps.MapControl.ExtendedModes. I removed (in notepad) info about public key token, assembly, culture and all other info except name of ... assembly? So - if my first workaround doesn't work - try to left just short info about assembly. So - after it should looks like this (plus other references without additional info):

     

        <Reference Include="Microsoft.Maps.MapControl">

          <HintPath>..\..\..\Program Files (x86)\Bing Maps Silverlight Control\V1\Libraries\Microsoft.Maps.MapControl.dll</HintPath>

        </Reference>

     

     

    Hope it helps :)

     

    Best regards, Maxim Grigoryev

    www.Exonya.com - software development company, offshore programming

    Thursday, November 18, 2010 12:45 PM
  • Hello everyone,

    I am experiencing the same issue with Visual Studio 2010 SL4. With SL3 it works fine.

    Honga


    honga.super6.cz
    • Edited by hongabonga Wednesday, April 13, 2011 11:29 AM
    Monday, February 14, 2011 10:22 PM
  • Hello,

    I have the same problem,only with SL4

    Cosmin

    Friday, February 18, 2011 1:44 PM
  • A few more clues that might help people out.

    The Microsoft.Maps.Plugins.ConfigurationService is located in an assembly that is automatically downloaded inside a XAP. The three assemblies are: Microsoft.Maps.Plugins.dll, Microsoft.Maps.PluginContainer.dll and Microsoft.Maps.Plugins.Internal.dll. If the application doesn't have these you'll get that TargetInvocationException

    If you're using an XML configuration file that is passed to MapConfiguration.Load check addresses being used, mainly FrameworkUrl. There could also be problems with http vs. https. If any map functionality seems broken after all types load, addresses in the configuration file can also be checked.

    Fiddler's a great tool to trace requests and make sure everything is getting downloaded as expected.

    Hope this helps

    • Edited by Jeff S Wednesday, April 6, 2011 7:08 PM formatting
    Wednesday, April 6, 2011 7:07 PM
  • Jeff S - thanks for the good idea!

    I found the solution of the issue - you have to add additional DLLs - you canfind details here

    Hope it helps!




    • Edited by MagicMax Thursday, January 23, 2014 3:41 PM
    Friday, April 22, 2011 10:29 AM