Public Key of Enterprise Library problems [tested by yourself]

Source: Internet
Author: User
Enterprise Library configuration is a tool attached to Enterprise Library to edit app. config. After enterprise library is installed, it is compiled and generated. It is very convenient to use this tool to edit app. config, but some usage problems are also encountered. Record it for future reference.

Cause: In the debugging process, you want to track the Enterprise Library, so you canCodeAdd to your project and reference these components in the project.

Problem description: Use the Enterprise Library configuration plug-in of vsts to edit and save the app. config of the project. During compilation, select "re-compile all" and pass the code smoothly (some minor problems are encountered in the middle, but this is not the focus of this document ). During running, once the component is called to the Enterprise Library, the following error message is reported:

Failed to Load file orProgramSet "Microsoft. Practices. enterpriselibrary. Data, version = 4.0.0.0, culture = neutral, publickeytoken = 31bf3856ad364e35" or one of its Dependencies. Find the Assembly list definition does not match the assembly. (Exception from ......)

Problem Analysis:

1. When we see publickeytoken, we guess it is because of the strong naming relationship, that is, the list does not match the referenced program set's strong naming (specifically, the public key and private key do not match ).

2. Cause of mismatch: The Assembly released by Microsoft contains a high life cycle (that is, "... *. Dll in \ Enterprise Library 4 \ bin ). The Assembly compiled by the local machine does not contain a strongly-named assembly (that is, "... *. Dll in Enterprise Library 4 \ entlib4scr \ bin)

3. The Enterprise Library configuration embedded in vsts is released by Microsoft, so you can use it to edit the app. config will introduce a strong name in the configuration file, and the project references the locally compiled assembly, which naturally does not match.

Solution:

1. Use the Enterprise Library configuration ("... \ Enterprise Library 4 \ bin) to edit the configuration file, but the referenced assembly must be released by Microsoft ("... \ Enterprise Library 4 \ bin ").

2. Use the Enterprise Library configuration ("... Enterprise Library 4 \ entlib4scr \ bin) to edit the configuration file. The referenced assembly can be compiled by the Local Machine ("… Enterprise Library 4 \ entlib4scr \ bin ").

In fact, the principle is very simple, that is, you must use the supporting items, either published by Microsoft or compiled by the local machine.

Postscript:

1. I wanted to use the Enterprise Library and edit the code. I didn't expect to be self-defeating. Version control must be very strict for enterprises like Microsoft, so if you want to modify the Enterprise Library version, it is reasonable to add a strong name (a huge job) to each project in the Enterprise Library ).

2. for clarity, the locally compiled assembly ("... Enterprise Library 4 \ entlib4scr \ bin) is actually obtained when installing the Enterprise Library. If you want to use an Assembly that has been modified by you, you should use Enterprise Library 4 \ entlib4scr \ block \ Configuration \ SRC \ console \ bin \ debug to edit your configuration file to ensure that it is correct.

3. Most of the online statements are to remove the "publickeytoken = 31bf3856ad364e35" in the configuration file. I think this is not very reasonable. Although it can be used, it obviously loses a lot of controllability. The principle is that the locally compiled Assembly itself is "publickeytoken = NULL", so it can pass through.

At last, I got a little understanding, and I was just too easy to learn. It took so long to solve such a simple problem, but I am glad that I have gained a little bit. Another thing I have not figured out is: the plug-in path in vsts is saved somewhere. It would be nice to know how to directly change it to the locally compiled path. I did not find the path in both the local file and the Registry (this path exists in the registry, but it does not work after it is changed ). I hope the passing experts can tell me, thank you first.

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.