1

I am having an issue using Catel.Fody in a .NET Core 3.1 WPF application. I add the NuGet package Catel.Fody and the FodyWeavers.xml file is generated, shown below.

The using Catel.Fody; statement gives an error: the namespace Catel cannot be found.

Is Catel.Fody not compatable with .NET Core WPF?

<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
  <Catel />
</Weavers>

Edit: I'm following the MVVM pattern and my Views & ViewModels are in the UI layer which is where I need to use Catel.Fody.

juicebyjustin
  • 434
  • 7
  • 16

2 Answers2

2

They should all be compatible. Please check out the Orc components (https://github.com/wildgums). These are all.net core 3.1 and.net 5.0 compatible and use Catel.Fody.

Geert van Horrik
  • 5,689
  • 1
  • 18
  • 32
  • Thanks. However, I could not find anything useful for this instance in the WildGums GitHub. I have used Catel.Fody in a .net standard 2.0 library no problem. I am using a blank WPF .net core 3.1 app in VS 2019. Is there anything aside from Catel.Fody that I need to have that namespace become available in the WPF app? I also have Catel.Core and Catel.MVVM installed. – juicebyjustin Dec 01 '20 at 22:15
  • 1
    No, it should work, but without a repro it's hard to tell. Please check out LogViewer, Csv Text Editor and Orchestra as well. All open source WPF apps using Catel (and Fody). – Geert van Horrik Dec 01 '20 at 22:24
  • Thanks for your help. I'm not sure why but when I copied the package references from LogViewer to my WPF app and built it Catel.Fody is suddenly available. Hopefully I will be able to carry over this fix in my original project. Even after removing all references except Catel.Fody/MVVM/Core. Here's the repo with the projects that still are in error if you're interested. However, it might just be my machine needs a reboot. https://github.com/juicebyjustin/catel-fody-wpf-core-3-1/tree/master/CatelFodyWpfCoreTest – juicebyjustin Dec 01 '20 at 22:56
2

I had this same issue and solved it by replacing the following code in the project file:

<PackageReference Include="Catel.Fody">
  <Version>4.7.0</Version>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
  <PrivateAssets>all</PrivateAssets>
</PackageReference>

With:

<PackageReference Include="Catel.Fody" Version="4.7.0" PrivateAssets="all" />

The problem was with the <IncludeAssets> element. It needs to have compile listed in it's content. By removing the <IncludeAssets> element the default value of all is used.

Further information on Package Reference available on Microsoft NuGet Docs.