Caliburn.Micro version 4.0.212. Projects version .NET6
With Caliburn.Micro 3.0 and .Net Framework 4.7.2 it works
I am getting an error when I try to open a simple viewModel located in another project: "The component does not have a resource identified by the URI" I am using the Caliburn Micro example: https://github.com/Caliburn-Micro/Caliburn.Micro/tree/master/samples/tutorals/WPF/Wpf.Tutorial
To reproduce the error I created another project to the solution: "CommonView" I moved AboutViewModel from the main project to this one as I show in the image below:
In the bootstrapper I need to modify the SelectAssemblies method to add the files from this new project
protected override IEnumerable<Assembly> SelectAssemblies()
{
var assemblies = new List<Assembly>();
assemblies.AddRange(base.SelectAssemblies());
string[] fileEntries = Directory.GetFiles(Directory.GetCurrentDirectory());
foreach (string fileName in fileEntries)
{
if (!fileName.Contains(".conf") && fileName.Contains("CommonView.dll"))
{
assemblies.Add(Assembly.LoadFile(fileName));
}
}
return assemblies;
}
Now, when I call the About class from the button, Caliburn tries to get the instance, but it is not found so I get the error.
protected override object GetInstance(Type service, string key)
{
var instance = _container.GetInstance(service, key);
//instance is null
return instance;
}
However if I debug when CategoryViewModel is called, it returns the instance correctly
I saw this post where Juan Carlos overrides InitializeComponent(), but I think It should have a easier aproachment: The component does not have a resource identified by the uri
Thank you in advance. Regards
The problem is in the loading of the assembly, which should be like this assemblies.Add(Assembly.LoadFrom(fileName));
https://learn.microsoft.com/en-us/archive/blogs/suzcook/loadfile-vs-loadfrom
Live long and prosper