Nirav Shah
Nirav Shah

Reputation: 2084

The "XamlCTask" task failed unexpectedly on visual studio for xamarin

When I am trying to run application on Xamarin on visual studio, I am getting error as mentioned below and not able to run the application on device or emulator:

The "XamlCTask" task failed unexpectedly.
Microsoft.Cci.Pdb.PdbDebugException: Unknown custom metadata item kind: 6
   at Microsoft.Cci.Pdb.PdbFunction.ReadCustomMetadata(BitAccess bits)
   at Microsoft.Cci.Pdb.PdbFunction..ctor(ManProcSym proc, BitAccess bits)
   at Microsoft.Cci.Pdb.PdbFunction.LoadManagedFunctions(BitAccess bits, UInt32 limit, Boolean readStrings)
   at Microsoft.Cci.Pdb.PdbFile.LoadFuncsFromDbiModule(BitAccess bits, DbiModuleInfo info, IntHashTable names, ArrayList funcList, Boolean readStrings, MsfDirectory dir, Dictionary`2 nameIndex, PdbReader reader)
   at Microsoft.Cci.Pdb.PdbFile.LoadFunctions(Stream read, Dictionary`2& tokenToSourceMapping, String& sourceServerData)
   at Mono.Cecil.Pdb.PdbReader.PopulateFunctions()
   at Mono.Cecil.Pdb.PdbReader.ProcessDebugHeader(ImageDebugDirectory directory, Byte[] header)
   at Mono.Cecil.ModuleDefinition.ProcessDebugHeader()
   at Mono.Cecil.ModuleDefinition.ReadSymbols(ISymbolReader reader)
   at Mono.Cecil.ModuleReader.ReadSymbols(ModuleDefinition module, ReaderParameters parameters)
   at Mono.Cecil.ModuleReader.CreateModuleFrom(Image image, ReaderParameters parameters)
   at Mono.Cecil.ModuleDefinition.ReadModule(Stream stream, ReaderParameters parameters)
   at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters)
   at Xamarin.Forms.Build.Tasks.XamlCTask.Compile()
   at Xamarin.Forms.Build.Tasks.XamlCTask.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__1.MoveNext()  MyFirstProject      

Before adding this "Xamarin.Forms.Maps" NuGet package, my application working but as I have added this suddenly application stops running and getting error.

Anybody could help me what causes this type of issue?

Upvotes: 36

Views: 31111

Answers (8)

knocte
knocte

Reputation: 17949

If you have XML errors in your XAML files, this may happen too. Example:

<Label Text="<- go back" />

(You cannot use the character < there, use &lt; instead.)

Or two attributes with the same name:

<Label Text="someText" HorizontalOptions="Center" Text="someText" />

Upvotes: 1

suraj
suraj

Reputation: 316

This kind of issue may also come if by mistake you have any syntactical error like in my case: two text cells were present in the ListView -

<ListView x:Name="ProductsView">
    <ListView.ItemTemplate>
        <DataTemplate>
            <TextCell Text="{Binding ProductId}" />
            <TextCell Text="{Binding ProductDescription}" />
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

I went through other posts for this issue and found the same issue occurred due to the presence of syntactical errors, which VS doesn't report directly. So look for this, otherwise, reinstall the compatible version of xamarin.forms -> clean solutions -> rebuild by reopening VS.

Upvotes: 15

Vivek Mishra
Vivek Mishra

Reputation: 7

When We Add ContentPage Page in Xamarin.Forms. and in that page we add more then one ContentPage.Content in same page. Then also we get this type of the error.

Upvotes: 0

Paramjit
Paramjit

Reputation: 860

I am getting this error with Xamarin.Mac in Visual Studio for Mac. I unloded the Xamarin.Mac Project. Than remove it from solution. Finally delete the xamarin.Mac folder from the solution folder. Atlast deleted the packages folder from the solution folder. Remove all nuget packages from xamarin forms project. Now I again add the nuget packages to xamarin forms project. Added Xamarin.Mac project to the solution and make necessary modifications. This results in a successful build. Though my problem was with xamarin.mac this process may solve problem with other projects also.

Upvotes: 0

bharathi kumar
bharathi kumar

Reputation: 208

Updating Xamarin.Forms to the latest version on both android and iOS project and reopened the project worked for me.

Upvotes: 0

gotnull
gotnull

Reputation: 27214

Delete your old package /[your project root]/packages/Xamarin.Forms.[old version number].

Upvotes: 19

lukag
lukag

Reputation: 41

I removed all Xamarin references from ALL projects, removed ALL Xamaring packages. Deleted all mention of Xamarin in PROJ files and readded all nuget packages for Xamarin. (lost days on this) :)

Upvotes: 4

Nirav Shah
Nirav Shah

Reputation: 2084

This issue arise, if your Xamarin.Form version is not compatible/matching with your NuGet package which you have installed.

So, I have just updated Xamarin.Forms for both xx.Droid and PCL and make the match the dependencies with NuGet package.

Now it is working fine. Hope so this will work for you.

Upvotes: 52

Related Questions