"Cs1595: defined in multiple locations" error details

Source: Internet
Author: User
I recently found another method, which may be the simplest and most effective.

It is to change the names of all namespaces as long as they are different from the original ones.

It is also the worst way to find out that there is no way, and I did not expect it to be the most effective. I have basically tried the following methods, but I still can't. I have also changed the permission configuration. I think the following methods can only be referenced, because we usually do web Program It is impossible to use mscorelib. dll.

The following are Microsoft's explanations and my understanding.

Http://support.microsoft.com /? Id = 318274

PRB: when compiling ASP. NET resources using the C # compiler, an error message is displayed. "Compilation error message: cs1595" the release number of this article was chs318274.
Whether the Web Service is written in Visual Basic. Net or Visual C #. net, the Web Service uses the C # compiler to compile their proxies. Therefore, you may receive this error even if you are using a Visual Basic. Net project.

Note that if you mergeSRCAndCodebehindProperties, you will also receive a similar compiler error message. However, this is considered a developer error. If you encounter a specific problem described in this article, this error message always specifies the mscorlib. dll assembly.

The default access control list on the volume grants the everyone and users groups the permission to read and list files. However, these permissions are sometimes deleted to provide a safer environment. In this case, csc.exe cannot allocate the path name. Because ASP. NET does not provide options to the compiler, the compiler contains multiple routines of the Assembly. This issue does not occur when you use Visual Basic. Net compiler (vbc.exe) to compile resources.

Content on this page

Symptom
Cause
Solution
Status
More information
Reference
Symptom when you use the C # compiler (csc.exe) to compile ASP. NET Resources, you may receive a compiler error message similar to the following error message:

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 '-or-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 problem may occur when you try to run the Visual C #. NET web application or Microsoft Visual Basic. Net or Visual C #. NET web service for the first time.

This problem occurs because the C # compiler does not have access to the folder in the path of the mscorlib. dll assembly. To solve this problem, use one of the following methods (in priority ).
Method 1: Include the/nostdlib option in the C # compiler Definition

To solve this problem, modify the C # compiler definition to include the/nostdlib option. The/nostdlib option prohibits the import of mscorlib. dll assembly. mscorlib. dll is defined throughoutSystemNamespace.

To include the/nostdlib option in the C # compiler definition on a computer, follow these steps:

1. Open the machine. config file and find<Compilers>.
2. In C #,<Compiler>Definition, addCompileroptionsProperty, value:/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 "/>

Remarks:CompileroptionsThe property is not incremental. If you want to ignore this option in the web. config file or on a given page, you must add the/nostdlib option in addition to custom content.

Remarks: You cannot use this methodXmlserializerClass or web service application, becauseXmlserializerThe compiler call used does not inherit these options.
Method 2: grant the listing permission to the ASPNET account

To solve this problem, you can also grant the "List folders/read data" permission to one of the following accounts: (I think the permission for site directories in IIS may also be %Windir% \ Microsoft. NET \ framework \VersionI have set both directories.)

ASPNET account.
The group that includes the ASPNET account.
Process ID, used for mscorlib. dll assembly path (usually %Windir% \ Microsoft. NET \ framework \Version. This is usually the volume root directory (for example, c: \), where the account has no permission.

Remarks: If the/nostdlib option is used and the Web service is not used, do not use this method. This is the result of design.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.