Search code examples
xamarinxamarin.formsxamarin-studio

No embedded resource found


I have a xamarin forms application where the very first page has a image control which displays a embedded resource. Often, when i run the application, it fails during start-up with following error:

[libc] WARNING: generic atexit() called from legacy shared library
[monodroid-gc] GREF GC Threshold: 46800
[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] Xamarin.Forms.Xaml.XamlParseException: No embeddedresources found for SeeVee.StartPage
[MonoDroid]   at Xamarin.Forms.Xaml.XamlLoader.Load (Xamarin.Forms.BindableObject view, System.Type callingType) [0x00000] in <filename unknown>:0 
[MonoDroid]   at Xamarin.Forms.Xaml.Extensions.LoadFromXaml[StartPage] (SeeVee.StartPage view, System.Type callingType) [0x00000] in <filename unknown>:0 
[MonoDroid]   at SeeVee.StartPage.InitializeComponent () [0x00000] in <filename unknown>:0 
[MonoDroid]   at SeeVee.StartPage..ctor () [0x00000] in <filename unknown>:0 
[MonoDroid]   at SeeVee.App.GetMainPage () [0x00000] in <filename unknown>:0 
[MonoDroid]   at SeeVee.Android.MainActivity+<OnCreate>d__0.MoveNext () [0x00000] in <filename unknown>:0 
[mono] 
[mono] Unhandled Exception:
[mono] Xamarin.Forms.Xaml.XamlParseException: No embeddedresources found for SeeVee.StartPage
[mono]   at Xamarin.Forms.Xaml.XamlLoader.Load (Xamarin.Forms.BindableObject view, System.Type callingType) [0x00000] in <filename unknown>:0 
[mono]   at Xamarin.Forms.Xaml.Extensions.LoadFromXaml[StartPage] (SeeVee.StartPage view, System.Type callingType) [0x00000] in <filename unknown>:0 
[mono]   at SeeVee.StartPage.InitializeComponent () [0x00000] in <filename unknown>:0 
[mono]   at SeeVee.StartPage..ctor () [0x00000] in <filename unknown>:0 
[mono]   at SeeVee.App.GetMainPage () [0x00000] in <filename unknown>:0 
[mono]   at SeeVee.Android.MainActivity+<OnCreate>d__0.MoveNext () [0x00000] in <filename unknown>:0 
[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: Xamarin.Forms.Xaml.XamlParseException: No embeddedresources found for SeeVee.StartPage
[mono-rt]   at Xamarin.Forms.Xaml.XamlLoader.Load (Xamarin.Forms.BindableObject view, System.Type callingType) [0x00000] in <filename unknown>:0 
[mono-rt]   at Xamarin.Forms.Xaml.Extensions.LoadFromXaml[StartPage] (SeeVee.StartPage view, System.Type callingType) [0x00000] in <filename unknown>:0 
[mono-rt]   at SeeVee.StartPage.InitializeComponent () [0x00000] in <filename unknown>:0 
[mono-rt]   at SeeVee.StartPage..ctor () [0x00000] in <filename unknown>:0 
[mono-rt]   at SeeVee.App.GetMainPage () [0x00000] in <filename unknown>:0 
[mono-rt]   at SeeVee.Android.MainActivity+<OnCreate>d__0.MoveNext () [0x00000] in <filename unknown>:0 

I have to rebuild the app in xamarin studio and re-run and it works. Phew! this gets very tiring sometimes. I hope xamarin is aware of this silly bug and will fix it.


Solution

  • The fix that worked for me was the following

    In the main project .csproj file, I found that all my .xaml files where formatted like this :

    <EmbeddedResource Include="Source\Home\HomeContentView.xaml"> <Generator>MSBuild:UpdateDesignTimeXaml</Generator> </EmbeddedResource>

    Except one, the one that was failing had an extra line which looked like this

    <LogicalName>MyProject.Home.HomeContentView.xaml</LogicalName>

    Removing this line fixed the issue. I also saved my files, cleaned and rebuilt the project.