none
mscorlib.dll updates for VS 2010 Development RRS feed

  • Question

  • Development Environment :

    When I checked mscorlib.dll which are internally used by Visual Studio (VS) 2010 and VS 2012, I observed the following versions :

    In VS 2010, the mscorlib.dll is used in the following path and its version number is 4.0.30319.1

    "C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0"

    In VS 2012, the mscorlib.dll is used in the following path and its version number is 4.0.30319.17929

    "C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5"

    Production Environment :

    It is observed that at production environment, any one of the following version of mscorlib.dll is present in the folder location

    C:\Windows\Microsoft.NET\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089

    For .NET 4.0 - 4.0.30319.1 (New Features)

    For .NET 4.5 - 4.0.30319.17929 (New Features)

    For .NET 4.5 January Updates - 4.0.30319.18033 (Bug Fixes)

    The development environment and production environment mscorlib.dll versions should be same to avoid breaking changes and maintain stability of the application.

    Do VS 2010 provide an update which can use  mscorlib.dll V4.0.30319.18033 (Bug Fixes) for development?


    Wednesday, April 3, 2013 1:57 PM

Answers

  • What you show in your example has nothing to do with mscorlib or any other framework library, it is about a compiler changed made in .NET 4.5.

    It appears to me that VS is using it's own compiler rathere than the framework one (csc.exe) and as a result VS2010 preserved the old compiler behavior even if you have installed .NET 4.5.

    It appears that is it possible to force VS2010 to behave like VS2012 by adding the following property to the .csproj file:

    <UseHostCompilerIfAvailable>false</UseHostCompilerIfAvailable>

    but I have no idea if this works properly in all situations.

    The alternative is to change the code like this:

    foreach (var word in new string[] { "hello", "world" })
    {
        var localWord = word;
        methods.Add(() => Console.Write(localWord + " "));
    }
    
    This way the lambda expression captures a copy of the foreach variable and so it will use the proper value instead of using the last value in the array.
    • Marked as answer by sans_india85 Tuesday, April 16, 2013 9:41 AM
    Monday, April 15, 2013 4:56 PM
    Moderator

All replies

  • Hi Sans,

    Thank you for report this on MSDN Forum.

    Would you like to tell us what issue do you encounter?

    How do we reproduce it?

    If you just look for an update for VS2010 or .Net 4.0, you can change the thread type to discussion and change the title more clear, so when any members know this information, they will follow this thread.

    Thanks.


    Mike Feng
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, April 4, 2013 6:09 AM
    Moderator
  • Would you like to tell us what issue do you encounter?

    How do we reproduce it?

    http://msdn.microsoft.com/en-us/library/vstudio/hh678682.aspx

    As mentioned in the above URL, there are breaking changes in Visual C# 2012.

    Development machine :

    I have compiled my code in VS2010. In VS 2010, the mscorlib.dll is used in the following path and its version number is 4.0.30319.1

    "C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0"

    Production machine :

    When I run my application  in production machine.The mscorlib.dll version is different as it got updated due to windows update. Check the folder C:\Windows\Microsoft.NET\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__XXXXXXX

    For .NET 4.5 January 2013 Updates - the mscorlib.dll version is 4.0.30319.18033 (Bug Fixes)

    My application is built against mscorlib.dll V4.0.30319.1 in development machine and it is run against mscorlib.dll V4.0.30319.18033 in the production machine. Due to breaking changes as mentioned in the above URL, the behavior of the application will differ. How do I handle this scenario if I continue using VS 2010?

    Thursday, April 4, 2013 9:52 AM
  • Hi Sans,

    >>Due to breaking changes as mentioned in the above URL, the behavior of the application will differ. How do I handle this scenario if I continue using VS 2010?

    When in V4.0.30319.18033, it generates the correct output, generally, you should be happy this issue has been fixed, and the fix code against this issue is excess. In my mind, you can just leave it there, or remove such code to make it looks clear.

    If this is not your situation, would you like to make a specific scenario to tell us your confusion.

    Thank you.


    Mike Feng
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, April 4, 2013 1:59 PM
    Moderator
  • Hi Mike,

    Thanks for the reply.

    >>When in V4.0.30319.18033, it generates the correct output, generally, you should be happy this issue has been fixed, and the fix code against this issue is excess.

    I'm happy for the issues which are fixed.

    My confusion is that to get correct output : Do I need to migrate my development environment from VS2010 to VS2012? Can't I get the correct output in VS2010 itself?

    Regards,

    Sandeep

    Thursday, April 4, 2013 7:10 PM
  • Hi Sandeep,

    VS2010/2012 just a tool, a development tool, you don't have to upgrade to VS2012. The key point is the framework should be OK and you have installed the update. The tool effect this issue little.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, April 9, 2013 5:03 AM
    Moderator
  • Hi Mike,

    Thanks for the reply.

    I have VS2010 in my development machine.Its version is

    Visual Studio 2010
    Version 10.0.40219.1 SP1 Rel

    Microsoft .NET Framework
    Version 4.5.50709 SP1 Rel

    I have VS2012 in my development machine.Its version is

    Visual Studio 2012
    Version 11.0.511060.01 Update 1

    Microsoft .NET Framework
    Version 4.5.50709

    I have targeted .NET Framework 4.0 in both VS2010 and VS2012 and wrote the following code in a console application :

    static void Main()
    {
        var methods = new List<Action>();
        foreach (var word in new string[] { "hello", "world" })
        {
            methods.Add(() => Console.Write(word + " "));
        }
    
        methods[0]();
        methods[1]();
    }
    

    In VS2010, I get the following output :

    In 2012, I get the following output :

    >>VS2010/2012 just a tool, a development tool, you don't have to upgrade to VS2012.

    Now, to get the same output in VS2010 as it comes in VS2012. What I should update in VS2010?

    Regards,

    Sandeep.

    Monday, April 15, 2013 12:32 PM
  • What you show in your example has nothing to do with mscorlib or any other framework library, it is about a compiler changed made in .NET 4.5.

    It appears to me that VS is using it's own compiler rathere than the framework one (csc.exe) and as a result VS2010 preserved the old compiler behavior even if you have installed .NET 4.5.

    It appears that is it possible to force VS2010 to behave like VS2012 by adding the following property to the .csproj file:

    <UseHostCompilerIfAvailable>false</UseHostCompilerIfAvailable>

    but I have no idea if this works properly in all situations.

    The alternative is to change the code like this:

    foreach (var word in new string[] { "hello", "world" })
    {
        var localWord = word;
        methods.Add(() => Console.Write(localWord + " "));
    }
    
    This way the lambda expression captures a copy of the foreach variable and so it will use the proper value instead of using the last value in the array.
    • Marked as answer by sans_india85 Tuesday, April 16, 2013 9:41 AM
    Monday, April 15, 2013 4:56 PM
    Moderator
  • Hi Mike,

    Thanks for your inputs and agree with compilers.

    I observed that Visual Studio 2012 always use new compilers as they get updated very frequently. Till now Update1 and Update2. <--They are pretty fast and updates happen quarterly.

    The same logic does not get applied to VS2010.

    http://msmvps.com/blogs/kathleen/archive/2013/03/29/module-1-high-points-side-by-side-implications.aspx <-- Some useful info on .NET 4.0

    I observed that hotfixes and breaking changes are no longer available in VS2010 compiler as they are available in VS2012.

    Regards & thanks,

    Sandeep.


    Tuesday, April 16, 2013 9:38 AM