【问题标题】:Adventures on Enterprise Library 5.0: Who moved my cheese (namespace)Enterprise Library 5.0 历险记:谁动了我的奶酪(命名空间)
【发布时间】:2010-06-07 23:24:59
【问题描述】:

耶稣,克里希纳,佛陀!

我已迁移到 EntLib 5.0,但不再识别像 ISymmetricCryptoProvider 这样的类。有趣的是,Data、Logging 和其他块正在正常编译。

这是有问题的类:

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

为什么有些命名空间可以找到而有些则不能?

【问题讨论】:

    标签: visual-studio-2010 namespaces enterprise-library-5


    【解决方案1】:

    根据您拥有的 4.1 引用,您仍在引用 Enterprise Library 4.1 程序集。您需要删除这些引用并添加对 Enterprise Library 5.0 程序集的引用。

    加密块应该可以按原样使用,而无需更改您的代码。还要确保更新所有配置文件中的“参考”。

    【讨论】:

      【解决方案2】:

      在构建时共享命令行(输出窗口、带有所有 -r 的 csc.exe 命令行以查看编译器的引用)?这可能表明了问题。

      【讨论】:

      • 我注意到输出窗口显示:编译完成 -- 3 个错误,0 个警告 C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9 ):警告 MSB3245:无法解析此引用。找不到程序集“Microsoft.Practices.EnterpriseLibrary.Common,Version=4.1.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,processorArchitecture=MSIL”。检查以确保该程序集存在于磁盘上。如果您的代码需要此引用,则可能会出现编译错误。
      • 此 4.1.0.0 版本未安装,我在此 .targets 文件中看不到任何参考。 dll不存在,没有被引用,不知道为什么VS2010会显示这个信息
      • 底层 .csproj 文件在这里列为<Reference> 元素是什么?听起来无论它是什么,都是错误的。发布整个 .csproj 文件以帮助诊断可能很有用。
      • 好吧,现在它正在工作,即使认为解决方案上的 Clean 选项会对我有所帮助,我还是为每个项目擦除了 bin 和 out 文件夹。所以我发现有第二个类库使用两个古老的 dll。我在那里添加了新的,现在它编译得很好。解决方案资源管理器上的这个“清理”选项可能有问题?!
      猜你喜欢
      • 2013-06-20
      • 2011-08-27
      • 1970-01-01
      • 2023-04-04
      • 1970-01-01
      • 1970-01-01
      • 2011-03-13
      • 2011-09-19
      • 1970-01-01
      相关资源
      最近更新 更多