Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Curious to mscorlib reference

I am curious as to the mscorlib reference in different project templates.

When I create a WPF project, I cannot find the mscorlib file in the reference folder. I think it is referenced by default.

When I create a Silverlight project, I can find it in the folder. It links to the Silverlight framework. Then I tried to delete it and of course it cannot be compiled. Then I tried to re-add this assembly to the reference again; it cannot be added and cannot be compiled anymore. It's weird.

When I create a MonoDroid project, I can still find the mscorlib reference. But after I deleted this reference, the project still can be compiled; but I'm not sure if it runs fine.

Does anyone knows what causes this behavior?

Thanks, Howard

like image 558
Howard Avatar asked Apr 15 '11 03:04

Howard


People also ask

What is Mscorlib error?

MSCORLIB. DLL is an essential component for some Windows applications, and the error message is a sign that the file is corrupt or missing, which affects the program. This could be caused by malicious software, incorrect installations, faulty programs, registry issues, etc.

What does Mscorlib contain?

The mscorlib. dll file is among the pre-coded solutions that form the framework's Base Class Library. The mscorlib. dll program file included in the BCL encapsulates a large number of common functions, such as file reading and writing, graphic rendering, database interaction, and XML document manipulation.

Where is Mscorlib dll located?

I also notice that a bunch of these are in directories named: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework. NETPortable\v4. 0\Profile\ProfileXXX\mscorlib. dll, where XXX is a 1-3 digit number.


1 Answers

Just so someone does not have to google it. I was missing the mscorlib and found the exact way CuiPengFei suggested to do this in the project file, here:Microsoft Connect Feedback in the workaround which was posted by James Wightman on 12/9/2009 at 2:52 AM below:

As I said in the bug report, one workaround is to manually add the reference back into the project manually by editing the csproj file using (for example) notepad:

Find this section in the csproj file - obviously if you have different/additional references that's what you're looking for:

<ItemGroup>
 <Reference Include="System.Windows" />
 <Reference Include="system" />
 <Reference Include="System.Net" />
 <Reference Include="System.Xml" />
 <Reference Include="System.Windows.Browser" />
</ItemGroup>

Add a line for each of the missing references - in this case, mscorlib and System.Core - and your csproj file should now look something like this:

<ItemGroup>
 <Reference Include="mscorlib" />
 <Reference Include="System.Core" />
 <Reference Include="System.Windows" />
 <Reference Include="system" />
 <Reference Include="System.Net" />
 <Reference Include="System.Xml" />
 <Reference Include="System.Windows.Browser" />
</ItemGroup>
like image 124
Brian Avatar answered Sep 25 '22 02:09

Brian