Error message when you use the C# compiler to compile an ASP.NET resource: "Compiler Error Message: CS1595" (318274)
The information in this article applies to:
- Microsoft Visual C# .NET (2003)
- Microsoft ASP.NET (included with the .NET Framework 1.1)
- Microsoft Visual C# .NET (2002)
- Microsoft ASP.NET (included with the .NET Framework) 1.0
This article was previously published under Q318274 SYMPTOMS When you use the C# compiler (Csc.exe) to compile an
ASP.NET resource, you may receive a compiler error message that is similar to
one of the following error messages: Compiler Error
Message: CS1595: 'System.Collections.ArrayList' is defined in multiple places;
using definition from 'c:\winnt\microsoft.net\framework\v1.0.3705\mscorlib.dll'
Compiler Error Message: CS1595:
'System.Runtime.CompilerServices.CompilerGlobalScopeAttribute' is defined in
multiple places; using definition from
'c:\windows\microsoft.net\framework\v1.0.3705\mscorlib.dll' This
issue may occur when you try to run a Visual C# .NET Web application for the
first time or when you run a Microsoft Visual Basic .NET or Visual C# .NET Web
service. CAUSE This issue occurs because the C# compiler does not have
permission to access the folders in the path to the mscorlib.dll assembly.
RESOLUTION To resolve this issue, use one of the following methods.
(The methods are listed in the order of preference.) Method 1 Modify the compiler definition for the
C# compiler to include the /nostdlib option. The /nostdlib option prevents the
import of the mscorlib.dll assembly, which defines the entire System namespace. To include the /nostdlib option in the C#
compiler definition on a computer, follow these steps:
- Open the Machine.config file, and then locate the <compilers> section.
- In the <compiler> definition for C#, add the compilerOptions attribute with a value of /nostdlib. For example:
<compiler language="c#;cs;csharp"
extension=".cs"
type="Microsoft.CSharp.CSharpCodeProvider, System,
Version=1.0.3300.0,
Culture=neutral,
PublicKeyToken=b77a5c561934e089"
warningLevel="1"
compilerOptions="/nostdlib" />
Note The compilerOptions attribute is not additive. If you need to override this option in
a Web.config file or on a given page, you must add the /nostdlib option in
addition to your customizations. Note You cannot use this method for applications that use the XmlSerializer class or Web services because the compiler invocation that XmlSerializer uses does not inherit these options. Method 2Grant List permissions to the process identity that is being used to run the ASP.NET
worker process for every folder in the path of the mscorlib.dll assembly. Typically, this path
is %WinDir%\Microsoft.NET\Framework\ Version.
This is generally the root of the volume where the account does not have
permissions. For example, the root may be C:\. Note Do not use this method if the following conditions are true: - You use the /nostdlib option.
- You
are not using Web services.
Method 3 Grant "List Folder/Read
Data" permissions to one of the following accounts:
- The ASPNET account, or the NetworkService account for
applications that run on Microsoft Internet Information Services (IIS)
6.0
- The group that includes the ASPNET account (or NetworkService
account)
STATUSThis
behavior is by design.MORE INFORMATION Web services use the C# compiler to compile their proxies,
regardless of whether they are written in Visual Basic .NET or Visual C# .NET.
Therefore, you may receive this error message even if you are working with a
Visual Basic .NET project.
Note that you can also receive similar
compiler error messages if you combine the src and the codebehind attributes in a single page. However, this is considered a
developer error. If you are encountering the specific issue that is described
in this article, the error message always specifies the mscorlib.dll
assembly.
Default access control lists on a volume grant the Everyone
and the Users groups permission to read and to list files. However, sometimes
these permissions are removed to provide a more secure environment. When this
occurs, Csc.exe cannot cannibalize path names. Because ASP.NET does not
currently provide the /nostdlib option to the compiler, the compiler contains
multiple instances of assemblies. This issue does not occur when you use the
Visual Basic .NET compiler (Vbc.exe) to compile resources. REFERENCES For more information, visit the following Microsoft Developer Network (MSDN) Web site:
Modification Type: | Major | Last Reviewed: | 5/15/2006 |
---|
Keywords: | kbCompiler kbLangC kbprb kbSecurity KB318274 kbAudDeveloper |
---|
|