I. Reference an Enterprise Library assembly
1. reference the Enterprise Library assembly
In Visual Studio, right-click your project in solution, select Add reference, and find the corresponding assembly.
REFERENCE The following Assembly
Microsoft. Practices. enterpriselibrary. Logging. dll
Microsoft. Practices. enterpriselibrary. Common. dll
Microsoft. Practices. servicelocation. dll
Microsoft. Practices. Unity. dll
Microsoft. Practices. Unity. Interception. dll.
To reference a specific unified configuration class in your code, you must reference Microsoft. Practices. Unity. configuration. dll. In most cases, you do not need to reference this assembly.
2. enterprise database namespace
All application modules of the Enterprise Library belong to the same namespace. The code for all enterprise libraries is in the Microsoft. Practices. enterpriselibrary space. To use the corresponding application, you must reference the corresponding namespace.
Use Using in C. Use import. Net in VB.net.
For example, use the logging application module
C # copy Code <br/> using Microsoft. practices. enterpriselibrary. logging; <br/> using Microsoft. practices. enterpriselibrary. logging. database; <br/> using Microsoft. practices. enterpriselibrary. logging. filters; <br/> using Microsoft. practices. enterpriselibrary. logging. extrainformation; </P> <p> Visual Basic copy Code <br/> imports Microsoft. practices. enterpriselibrary. logging <br/> imports Microsoft. practices. enterpriselibrary. logging. database <br/> imports Microsoft. practices. enterpriselibrary. logging. filters <br/> imports Microsoft. practices. enterpriselibrary. logging. extrainformation
If you want to use more advanced methods to fully use Unity's dependency injection capabilities.
C # copy Code <br/> using Microsoft. practices. enterpriselibrary. common. configuration. unity; <br/> using Microsoft. practices. unity; </P> <p> Visual Basic copy Code <br/> imports Microsoft. practices. enterpriselibrary. common. configuration. unity <br/> imports Microsoft. practices. unity <br/>
II. Dependencies in the Enterprise Library
Dependencies of all application modules:
1. Unified dependency injection mechanism. Perform all repeated and required object creation and cancellation tasks in a unified manner, and provide high flexibility. The unified mechanism is included in the Microsoft. Practices. Unity. dll assembly and Microsoft. Practices. Unity. Interception. dll assembly.
2. Service localization Assembly dependent on the injection mechanism. This Assembly can integrate any suitable dependency injection container by providing the abstraction layer for dependency injection. Included in Microsoft. Practices. servicelocation. dll.
3. core library functions. The Enterprise Library provides services such as configuration and instrumentation. It is a shared dependency of all application modules except unity. Included in Microsoft. Practices. enterpriselibrary. Common. dll.
Note: unity can be used as a separate dependency injection container. To support this feature, unity has its own configuration system. Therefore, you can use unity without deploying the configuration system at the core of the enterprise database.
Module dependency diagram:
Additional dependencies of the cache application module:
1. If a database is used as a backup storage, the database needs to access the application module.
2. If you want to encrypt data in the cache, You need to encrypt the application module (cryptography Application Block)
Additional dependencies of the exception handling application module:
1. If you use the logging application module to record exceptions, you need Microsoft. Practices. enterpriselibrary. Logging. dll and Microsoft. Practices. enterpriselibrary. exceptionhandling. Logging. dll.
2. In addition, the exception handling application module may also depend on other code, including the logging application module and data access application module. If the logging application module is configured to use the Database Listener, data is used to access the application module.
Additional dependencies of the dependency injection application module:
1. If authorization is performed, the Security Application Block is required ).
2. If exception handling is performed, the exception handling application module is required.
3. If logs are recorded, the application module must be logged.
4. If verification is performed, the application module needs to be verified.
Additional dependencies of the security application module:
1. cache application module. The security application module uses the cache application module to cache security information and obtain it as needed. Of course, you can also use your own cache provider to replace the cache application module. This depends on how you configure the cache reference module. You may also use the data access module.