When you release or debug the asp.net program, you often find that the program cannot be loaded to the corresponding assembly. This problem is often plagued by new users like me, so after I read many documents, I sorted it out as follows. We hope that experts can participate in the discussion.
Concept 1. the Configuration System is layered, and the highest level is machine. config in \ % windows % \ Microsoft. under the Net \ Framework \ VersionNumber \ CONFIG directory, there is a global web within the machine scope. config, each directory and sub-directory in each web application can have only one web. config file. If the configuration information contained in the web. config file conflicts with the higher-level configuration, the lower-level Configuration overwrites and applies to its own directory and all its subdirectories. The edit global configuration in the figure below is to modify the global web. config at the machine level, and edit configuration is to modify the web. config of each application. Concept 2. reference must be added when any assembly is used, including the System namespace. However, we do not need to manually add the System namespace. If you open \ % windows % \ Microsoft. net \ Framework \ VersionNumber \ CONFIG directory. the following configuration nodes can be found in the config file:
<Assemblies>
<Add assembly = "mscorlib"/>
<Add assembly = "System, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089"/>
<Add assembly = "System. Configuration, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a"/>
<Add assembly = "System. Web, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a"/>
<Add assembly = "System. Data, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089"/>
<Add assembly = "System. Web. Services, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a"/>
<Add assembly = "System. Xml, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089"/>
<Add assembly = "System. Drawing, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a"/>
<Add assembly = "System. EnterpriseServices, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a"/>
<Add assembly = "System. Web. Mobile, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a"/>
<Add assembly = "*"/>
<Add assembly = "System. ServiceModel. Web, Version = 3.5.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35"/>
<Add assembly = "System. WorkflowServices, Version = 3.5.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35"/>
<Add assembly = "System. Runtime. Serialization, Version = 3.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089, processorArchitecture = MSIL"/>
<Add assembly = "System. IdentityModel, Version = 3.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089, processorArchitecture = MSIL"/>
<Add assembly = "System. ServiceModel, Version = 3.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089"/>
</Assemblies>
This is why we generally do not need to add the System reference in the web. config of our own independent application (of course, we are willing to write it again, and there will be no problem ).
When you want to add an external assembly, you will right-click the bin directory and selectAdd reference, Then the bin directory will get a copy of the dll file, but if there is a. net assembly, but will not get the copy, but in the <assemblies> with an additional add
Concept 3. Classification of an assembly ()
CLR divides an assembly into a private assembly set and GAC
GAC = Global Assembly Cache, which is the Global assembly Cache or shared Assembly Cache. The assembly registered to GAC can be found in the \ windows \ Assembly directory.
The Assembly name, version number, culture, and Public Key (publicTokenKey). If you want to reference it, there are two methods in
1. add an add node in manual web. config
2. Add reference under the bin directory to find the corresponding Assembly (the first step will be automatically performed)
Method 1 fails when our own external Assembly needs to be referenced, because our own assembly is private and not registered to GAC, how do you know where to find your Assembly by adding an add system? So right-click the bin directoryAdd referenceThe bin directory will get a copy of the dll.
Question 1. Why is the GAC directory \ windows \ assembly?
A: The Path is changeable and configurable.
Question 2. CLR search assembly sequence
A: First GAC and then search for the Application Assembly Cache (such as the bin directory and app_code directory)