none
MEF behavior unexpected change after installation of .NET 4.5 beta

    Pergunta

  • Hello, I've installed Visual Studio 2011 beta, which comes with .NET 4.5 beta, on a machine with Visual Studio 2010 and .NET 4 SP1.

    I have a project which is using MEF, built on and targetting .NET 4 that wasn't touched at all, and a unit test making use of MEF which tested open generics support started failing after I installed .NET 4.5 beta. The impression in therefore that for some reason this installation affected a piece of code which wasn't supposed to be influenced at all.

    Any idea why this might be happening?


    Simone Busoli

    sábado, 3 de março de 2012 11:21

Respostas

  • Simone, we've discussed this within the team and don't expect to change this behavior, given that existing 4.0 applications seem highly unlikely to rely the absence of this feature. If we're missing something and you can see this impacting a production scenario please let us know.

    Thanks again for bringing this to our attention, we appreciate your effort in reporting this and in following up.

    Best regards,

    Nick (BCL Team)

    terça-feira, 13 de março de 2012 16:15

Todas as Respostas

  • Sure. .NET Framework is an extension of 4.0. Installing the beta software probably (read almost certainly) replaced some 4.0 files with 4.5 updates. I'm sure of this because I had occasion to uninstall .NET 4.5 beta from a system. To get 4.0 working again, I had to reinstall it from the standalone installer.

    If you feel the behavior you've experienced is a bug, please report it to the developers via MS Connect, here:

    http://connect.microsoft.com/VisualStudio 

    You'll need to sign in with your Live ID.

    sábado, 3 de março de 2012 17:36
  • So do you think this is expected? If that's the case what is the point of keep targetting .NET 4 if you get the 4.5 breaking changes anyway?

    Simone Busoli

    segunda-feira, 5 de março de 2012 09:19
  • I'm sorry. I did not mean to imply that "this is expected". Quite the contrary. That's why it's important that you report to the developers via Connect, as I linked in my first reply.
    segunda-feira, 5 de março de 2012 15:19
  • Hi Simone,

    Thanks for bringing this to our attention. I'm on the team that delivers MEF - we'd like to get to the bottom of this ASAP, are you able to provide more information?

    You mention open generics support, but this is a new feature in 4.5 so I don't understand what you mean by having a unit test for it that now breaks.

    Any additional information much appreciated, especially a stack trace or example of code that is broken.

    Regards,

    Nick

    segunda-feira, 5 de março de 2012 17:33
  • Hi Nicholas, the only ignored test you can see in this file passes when on the machine is installed the .NET fx 4.0 only, and breaks when on the machine is installed also .NET 4.5 beta.
    I can understand that the new bits of MEF support open generics, and it's good, I just didn't expect that installing .NET 4.5 beta side-by-side to .NET 4.0 without changing anything in an existing app would imply that the app would start using them.

    quarta-feira, 7 de março de 2012 11:16
  • Simone, thank you very much for the details; I'll loop back with the team and let you know what the status of this is.

    Nick

    quinta-feira, 8 de março de 2012 21:12
  • Simone, we've discussed this within the team and don't expect to change this behavior, given that existing 4.0 applications seem highly unlikely to rely the absence of this feature. If we're missing something and you can see this impacting a production scenario please let us know.

    Thanks again for bringing this to our attention, we appreciate your effort in reporting this and in following up.

    Best regards,

    Nick (BCL Team)

    terça-feira, 13 de março de 2012 16:15
  • Hi Nicholas,

    We are also experiencing regression in our application after simply installing the .NET 4.5 Framework on a given machine.

    We were using the MefContrib open generics support, which is now failing.  So, indeed, is the 4.5 open generics.  Here's an old example:

          
         //[InheritedExport]
        interface ITest<T>
        {

        }

        [Export(typeof(ITest<>))]
        class TestClass<T> : ITest<T>
        {

        }

        
        class Program
        {
            static void Main(string[] args)
            {
                var catalog = new AssemblyCatalog(typeof(Program).Assembly);
                var container = new CompositionContainer(new GenericCatalog(catalog));

                var tests = container.GetExportedValues<ITest<string>>();
            }
        }

    (This can be checked with or without the MefContrib GenericCatalog if using 4.5).   If the InheritedExport is commented in and the Export is commented out; it fails with an ugly exception.  If the code is as above it works as expected.

    This in my mind is a bug as it breaks existing code simply through installing a new version of the Framework.

    Regards,

    Steve

    sexta-feira, 17 de agosto de 2012 08:59