简体   繁体   中英

Cannot resolve symbol 'EnterpriseLibraryContainer'

I just started to try out the new MS Enterprise Library 6.0 Logger block. When I try to create a LogWriter, I get the error:

Cannot resolve symbol 'EnterpriseLibraryContainer'

I have all the references and usings in place, but can't get past this error.

Is there a solution to this issue?

Halleluiah! I just found a post (on a link that has since disappeared). Here's the story:

The bootstrapping code for all of the blocks has changed in version 6 of Enterprise Library. The blocks no longer use Unity to manage the initialization and configuration, and each block now includes its own bootstrapping code. Any calls to the EnterpriseLibraryContainer.Current.GetInstance method to resolve a type from one of the Enterprise Library blocks should be replaced with the block specific bootstrap code. For example, to create a LogWriter instance based on configuration in the app.config file, you can now use the following code:

LogWriterFactory logWriterFactory = new LogWriterFactory();
var logWriter = logWriterFactory.Create();

I believe that this blurb is from the "Microsoft Enterprise Library 6 and Unity 3 Migration Guide".

I've entered the code as shown and don't have the compiler complaining. Now I can continue to see how the logging works.

Yes, even I was facing issues whilst creating an object for ValidationFactory using Ent Lib 6.0. Just for info to create an instance of ValidationFactory see following code:

private Validator<Customer> customerValidator;
customerValidator = ValidationFactory.CreateValidator<Customer>();

This is not required now

EnterpriseLibraryContainer.Current.GetInstance<ValidatorFactory>()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM