Xamarin.forms: Errors when inheriting from any class in a local NET Standard library project.

Created on 1 Nov 2018  路  1Comment  路  Source: xamarin/Xamarin.Forms

Description

Errors result when inheriting from any class in a referenced local project.

Steps to Reproduce

  1. Create a .NET Standard library project (I name it Commons.Forms).
  2. Create any class inside that project.
  3. In a Xamarin Forms cross-platform project (MyProject), add Commons.Forms project in the solution then reference it in MyProject.
  4. Create a class inside MyProject inheriting from the class in step 2.
  5. Run MyProject.UWP

Expected Behavior

No errors.

Actual Behavior

If MyProject was not built before (or if it was cleaned), a build/compilation error occurs:

Severity    Code    Description Project Project Rank    Path    File    Line    Column  Category    Source  Suppression State   Tool
Error       Could not copy the file "obj\x86\Debug\MainPage.xbf" because it was not found.  Prayer.UWP  4                       Build       
Error       Could not copy the file "obj\x86\Debug\App.xbf" because it was not found.   Prayer.UWP  4                       Build       
Error       Cannot resolve Assembly or Windows Metadata file 'Type universe cannot resolve assembly: Commons.Forms, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.' Prayer.UWP  4   {PATH_HERE}\MyProject.UWP.csproj                Build       

If MyProject was successfully built before (like when it is was previously built before the bug is introduced), a runtime error occurs on Xamarin.Forms.Forms.Init(e):

System.Runtime.InteropServices.COMException: 'Error HRESULT E_FAIL has been returned from a call to a COM component.'

Basic Information

  • Version with issue: tested both 3.1 and 3.3
  • Last known good version: ?
  • IDE: VS 15.8.7
  • Platform Target Frameworks:

    • iOS: haven't tested yet

    • Android: haven't tested yet

    • UWP: latest Windows 10

  • Android Support Library Version:
  • Nuget Packages: barely added any (just starting learning Xamarin forms)
  • Affected Devices:
2 good first issue help wanted low inactive UWP bug up-for-grabs

Most helpful comment

It looks like you can get around the error by explicitly adding the class library as a reference to the UWP project. This might be more of a VS issue but I'll leave it open for now.

>All comments

It looks like you can get around the error by explicitly adding the class library as a reference to the UWP project. This might be more of a VS issue but I'll leave it open for now.

Was this page helpful?
0 / 5 - 0 ratings