Share via


Mscorlib.dll

At least for v2 and earlier, mscorlib.dll is a special case. That causes it and its types to be loaded differently from other assemblies.

Loading Mscorlib.dll Without a Path
It and the execution engine are so closely integrated that it's required that they match each other. So, once a version of the CLR is chosen, the version of mscorlib is also chosen automatically. That means that, when late binding (Assembly.Load(), etc.) for it without a path, the 'official' mscorlib Assembly will always be returned - regardless of the version that was requested. The same thing goes for loading by static reference to it.

This doesn't mean that it's okay to give an incomplete or incorrect reference for it! If/when mscorlib.dll is factored away from the execution engine, it won't be such a special case and bad references will start to fail to load.

Reflecting On Another Mscorlib.dll
It's possible to load another mscorlib.dll if it's loaded by path. But, it's not possible to load its types, due to optimizations done by the CLR's execution engine. (Same goes for ReflectionOnlyLoadFrom() on another mscorlib.dll.) This means that even if you rename the mscorlib.dll that you want to reflect over, it may be loaded, but its types will still be unloadable. So, the options for working around this are:

  • Reflect on the 'official' mscorlib.dll. You could change the version of the CLR that your app loads in order to reflect on the desired mscorlib version.
  • Use the unmanaged metadata API to get the desired info.
  • Create an asmmeta file for the desired mscorlib.dll and parse it at runtime.

Comments

  • Anonymous
    June 30, 2003
    Could you take a look at my comment here about Assembly.Load? Also, is the source code in the SSCLI for the threading & networking services the same in both the SSCLI and the .NET framework?

  • Anonymous
    June 30, 2003
    Oops I meant the comment in your post on Assembly.Codebase and Location.

  • Anonymous
    June 30, 2003
    Sure. Sorry, my responses are sometimes delayed, since I'm busy working on the product, not technical support. If you need a quicker response, you may want to consider talking to Microsoft's official tech support channels. Microsoft's official newsgroups are also good, since some non-MS MVP's may also answer your questions quickly (in addition to the MS people who answer).Anyway, yes, the code for that is basically the same for both (though, of course, it takes time for changes from the CLR to propagate to SSCLI).

  • Anonymous
    June 30, 2003
    Thanks

  • Anonymous
    November 11, 2003
    Can you give me some pointers (articles, links to examples) about the unmanaged metadata API you mentioned at the end of your article, please? What newsgroups or forums I could ask about these kind of problems?Many thanksCris

  • Anonymous
    November 13, 2003
    Try ms-help://MS.MSDNQTR.2003OCT.1033/dnmag00/html/metadata.htm from MSDN, or search for ".NET Unmanaged Metadata API" on the web.For newsgroups, try microsoft.public.dotnet.* (the CLR newsgroup is best for questions about metadata).

  • Anonymous
    November 18, 2003
    Thanks Suzanne!

  • Anonymous
    February 29, 2004
    I am working in vb.net. I am getting an eror "Object reference not set to an instance of an object " which its error source in mscorlib. I am getting this error while working with the farpoint grid which has one of a columns as checkbox .When the statement .value = 1 (which checks the checkbox) it throws this error
    plz help me out

  • Anonymous
    February 29, 2004
    Binal Dalal, please keep comments here related to the loader. See http://blogs.msdn.com/suzcook/archive/2003/12/05/57253.aspx for general support.

  • Anonymous
    May 07, 2004
    i have visual C++ 6 and not exist mscorlib...
    Why;
    help please

  • Anonymous
    May 08, 2004
    It's not there because the CLR is not installed. VS6 is pre-.NET. VS.NET starts with version 7.

  • Anonymous
    May 12, 2004
    I'm still reading through your archives, but what is a asmmeta file? Google returns 0 hits, and I can't find it in MSDN.

  • Anonymous
    May 19, 2005
    Hello!

    I have unmanaged C++ code which I want to be managed, and than I want to make web service from that managed code. The best way to do it?

    Thanks!

  • Anonymous
    April 18, 2006
    i got this problem, after downloading the sample code from msdn/

  • Anonymous
    June 09, 2006


    I am a programmer of vb6 . now i am using VB.Net . i am trying to communicate the machine on serial port using vb.net. But i am facing a Error "Exception from HRESULT: 0x800A1F45". Remember i am using MSCOMM32 for serial communication. as we did in vb6.0

    File Include as Refenece
    (1)Interop.MSCommLib
    (2)mscorlib

    Plz Help me as soon as posible
    Regards
    Saqib

  • Anonymous
    June 28, 2006
    The comment has been removed

  • Anonymous
    August 01, 2006
    What exactly is mscorlib all about? Is this the base building block for the primary namespaces in .Net?

    Can I open it and view it's code?

  • Anonymous
    September 13, 2006
    I am havin visual studio1.1. Can i use System.Collections.Generic Namespace??

  • Anonymous
    October 10, 2006
    i am using .NET 2003 ,i install to my computer crystal report 10 and then all my reports in the project return to crystal report 10. And when i create a setup project All files dependency is mscorlib WHAT CAN I DO TO SOLVE THIS PROBLEM

  • Anonymous
    December 27, 2006
    hai,   While using the Crystal Report XI in ASP.NET there is an Error  Not Enough Memory for operation.

  • Anonymous
    April 12, 2007
    By "Frameworks assemblies," I mean the assemblies that ship with the CLR. But, I'm not counting mscorlib.dll

  • Anonymous
    May 22, 2007
    I'm getting this error: Description:  Input string was not in correct format Source:  mscorlib Can you tell me what this might be about

  • Anonymous
    July 10, 2007
    Hi  I am using Vb.net. whenever i call the ***.dll i got the following error mscorlib:Could not find file 'C:Outputdebug.ddd'. and also Exception has been thrown by the target of an invocation.

  • Anonymous
    March 11, 2008
    I want to know that when we double click a .net exe, how does the Hosting API gets called for loading the CLR in the process. Thanks and Regards Saurabh Jain itsaurabh@yahoo.com

  • Anonymous
    March 13, 2008
    mscorlib is working on application at developmnent but not working after publish in the same machine. Please give me a suitable solution for the same. Thanks & regards Ramesh H. Sahoo

  • Anonymous
    May 25, 2008
    The comment has been removed

  • Anonymous
    June 06, 2008
    The comment has been removed