Cannot resolve symbol 'EnterpriseLibraryContainer'

萝らか妹 提交于 2019-12-10 03:31:58

问题


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?


回答1:


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.




回答2:


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>()


来源:https://stackoverflow.com/questions/16323252/cannot-resolve-symbol-enterpriselibrarycontainer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!