xaml - Getting System.Windows.Markup.XamlParseException while trying to run WP8 app -


i writing windows phone 8 application , using mvvm light. have written viewmodel , model class of wp8 app seperate pcl project.

while using expression blend populate design time data. when try run app in emulator following error. please me in figuring out fix error.

a first chance exception of type 'system.windows.markup.xamlparseexception'  occurred in system.windows.ni.dll 

here details of exception.

system.windows.markup.xamlparseexception occurred   hresult=-2146233087   message=cannot create instance of type 'mypkg.commons.viewmodel.viewmodellocator' [line: 12 position: 61]   source=system.windows   linenumber=12   lineposition=61   stacktrace:        @ system.windows.application.loadcomponent(object component, uri resourcelocator)        @ mypkg.windowsphone8.app.initializecomponent()        @ mypkg.windowsphone8.app..ctor()   innerexception: system.typeinitializationexception        hresult=-2146233036        message=the type initializer 'mypkg.commons.viewmodel.viewmodellocator' threw exception.        source=mscorlib        typename=mypkg.commons.viewmodel.viewmodellocator        stacktrace:             @ system.runtimemethodhandle.invokemethod(object target, object[] arguments, signature sig, boolean constructor)             @ system.reflection.runtimeconstructorinfo.invoke(bindingflags invokeattr, binder binder, object[] parameters, cultureinfo culture)             @ ms.internal.typeproxy.<>c__displayclass32.<getcreateobjectdelegate>b__2c()             @ ms.internal.typeproxy.createinstance(uint32 customtypeid)             @ ms.internal.xamlmanagedruntimerpinvokes.createinstance(xamltypetoken inxamltype, xamlqualifiedobject& newobject)        innerexception: system.io.fileloadexception             hresult=-2146234304             message=could not load file or assembly 'microsoft.practices.servicelocation, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35' or 1 of dependencies. located assembly's manifest definition not match assembly reference. (exception hresult: 0x80131040)             source=mypkg.commons             stacktrace:                  @ mypkg.commons.viewmodel.viewmodellocator..cctor()             innerexception:  

below app.xaml

<application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"              xmlns:phone="clr-namespace:microsoft.phone.controls;assembly=microsoft.phone"              xmlns:shell="clr-namespace:microsoft.phone.shell;assembly=microsoft.phone"              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"              xmlns:vm="clr-namespace:mypkg.commons.viewmodel;assembly=mypkg.commons"              mc:ignorable="d" x:class="mypkg.windowsphone8.app">   <!--application resources-->   <application.resources>     <local:localizedstrings xmlns:local="clr-namespace:mypkg.windowsphone8" x:key="localizedstrings" />         <vm:viewmodellocator x:key="locator" d:isdatasource="true"  />   </application.resources>   <application.applicationlifetimeobjects>     <!--required object handles lifetime events application-->     <shell:phoneapplicationservice launching="application_launching" closing="application_closing" activated="application_activated" deactivated="application_deactivated" />   </application.applicationlifetimeobjects> </application> 

below code constructor of viewmodellocator

   static viewmodellocator()     {         servicelocator.setlocatorprovider(() => simpleioc.default);          if (viewmodelbase.isindesignmodestatic)         {             // create design time view services , models             simpleioc.default.register<ialaramservice, mypkg.commons.design.alaramservice>();         }         else         {             // create run time view services , models             simpleioc.default.register<ialaramservice, mypkg.commons.design.alaramservice>();         }          simpleioc.default.register<mainviewmodel>();     } 

it appears there's problem reference microsoft.practices.servicelocation assembly. open references folder project, right click on microsoft.practices.servicelocation, , choose properties. ensure file referenced @ path exists , copy local set true, rebuild application. if error persists, remove , re-add mvvm light library project.


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -