0

I have a really strange situation on my hands. For starters, this is my first Caliburn.Micro project.

The project is using Caliburn.Micro 3.1.0 and it's targeting .net 4.0. The problem is that the application works great on systems that have 4.6.1 but won't work only with .net 4.0.

I tried to install all available Caliburn.Micro versions but the issue remains. The only way I could debug the application was through a various Thread.Sleeps or MessageBoxes. In the end I came with this major difference between the two systems for the above code that lies in the Bootstrapper:

     protected override object GetInstance(Type serviceType, string key)
    {
        MessageBox.Show(container.Catalog.Parts.ToString());
        MessageBox.Show(container.Catalog.Parts.Count().ToString());
        MessageBox.Show("3rd message.");

        var contract = string.IsNullOrEmpty(key) ? AttributedModelServices.GetContractName(serviceType) : key;

        var exports = container.GetExportedValues<object>(contract);

        if (exports.Any())
            return exports.First();
        throw new Exception(string.Format("Could not locate any instances of contract {0}.", contract));
    }

On the machine with 4.6.1 I see all message boxes with the first message resolving to

System.ComponentModel.Composition.Hosting.AggregateCatalog

but on the machines running only 4.0 I can only see the first message that is resolved to

System.ComponentModel.Composition.Hosting.ComposablePartCatalogCollection.SelectMany(catalog => catalog.Parts)

so it seams to be a difference between System.ComponentModel.Composition from .net 4.0 installed from the web on a Windows 7 machine and the .net 4.0 that came with Windows 10. But the file that I use on my developing machine and the one on my Windows 7 .net 4.0 machine have the same version 4.0.30319.1. So the files must be the same.

At this point i'm so stuck. Why the application runs on 4.6.1 but give the following error on .net 4.0?

enter image description here

andySF
  • 556
  • 7
  • 30

1 Answers1

0

The problem was in one of the projects that was referenced. The project was .net 4.5 but after changing it to .net 4.0 the package System.Net.Http 4.0.0 remained. After I remove it all is working.

As a future note I would suggest reinstalling all NuGet packages and recompile all projects in the solution.

The real issue was that I was using Microsoft.Bcl.Async without the KB246871

At this point I don't know if I should delete the question and answer.

andySF
  • 556
  • 7
  • 30
  • It's helpful to members who start with CM, and also for those who are working with it for years, so no, don't delete it. – sharp Nov 30 '17 at 08:36