Enterprise Library 5.0历险记:谁动了我的奶酪(命名空间)
耶稣、克里希纳、佛陀!
我已迁移到 EntLib 5.0,但像 ISymmetricCryptoProvider
这样的类不再被识别。有趣的是,数据、日志记录和其他块都可以正常编译。
这是有问题的类:
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;//-->it's not working anymore
using Microsoft.Practices.EnterpriseLibrary.Security.Cryptography;//-->it's not working anymore
namespace MyClassLibrary.Security.EnterpriseLibrary
{
public sealed class Crypto
{
public static ISymmetricCryptoProvider MyProvider
{
get
{
//IConfigurationSource is not recognized either, neither SystemConfigurationSource
IConfigurationSource cs = new SystemConfigurationSource();
SymmetricCryptoProviderFactory scpf = new SymmetricCryptoProviderFactory(cs);
ISymmetricCryptoProvider p = scpf.CreateDefault();
return p;
}
}
项目上的参考文献也很好。我真的不知道为什么这个特定的项目在 VS2010 上造成了太多麻烦!旧的引用被删除,项目被清理,重建,但无法编译:-(
引用是:
Microsoft.Practices.EnterpriseLibrary.Common
Microsoft.Practices.EnterpriseLibrary.Logging
Microsoft.Practices.EnterpriseLibrary.Logging.Database
Microsoft.Practices.EnterpriseLibrary.Security
Microsoft.Practices.EnterpriseLibrary.Security.Cryptography
为什么有些名称空间可以找到,而其他名称空间却找不到?
Jesus, Krishna, Budda!
I've migrated to EntLib 5.0, but classes like ISymmetricCryptoProvider
are not recognized anymore. Funny to say that Data, Logging and other blocks are working compiling fine.
Here's the problematic class:
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;//-->it's not working anymore
using Microsoft.Practices.EnterpriseLibrary.Security.Cryptography;//-->it's not working anymore
namespace MyClassLibrary.Security.EnterpriseLibrary
{
public sealed class Crypto
{
public static ISymmetricCryptoProvider MyProvider
{
get
{
//IConfigurationSource is not recognized either, neither SystemConfigurationSource
IConfigurationSource cs = new SystemConfigurationSource();
SymmetricCryptoProviderFactory scpf = new SymmetricCryptoProviderFactory(cs);
ISymmetricCryptoProvider p = scpf.CreateDefault();
return p;
}
}
The references are fine on project too. I really don't know why this particular project it's causing too many trouble on VS2010! Older references were deleted, project was cleaned, rebuilt, but can't make it compile :-(
The references are:
Microsoft.Practices.EnterpriseLibrary.Common
Microsoft.Practices.EnterpriseLibrary.Logging
Microsoft.Practices.EnterpriseLibrary.Logging.Database
Microsoft.Practices.EnterpriseLibrary.Security
Microsoft.Practices.EnterpriseLibrary.Security.Cryptography
Why some namespaces can be found while others can't?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据您拥有的 4.1 引用,您仍然引用 Enterprise Library 4.1 程序集。您需要删除这些引用并添加对 Enterprise Library 5.0 程序集的引用。
加密块应该可以按原样使用,而无需更改代码。还要确保更新所有配置文件中的“引用”。
Based on the 4.1 references that you have, you are still referencing the Enterprise Library 4.1 assemblies. You need to remove those references and add references to the Enterprise Library 5.0 assemblies.
The cryptography block should be usable as is without changing your code. Also make sure to update the "references" in all of your configuration files.
构建时共享命令行(输出窗口、csc.exe 命令行以及所有 -r 以查看编译器的引用)?它可能会提示问题。
Share the command-line when building (output window, csc.exe command line with all the -r's to see what references are going to the compiler)? It might suggest the problem.