【问题标题】:The type or namespace name 'ProfileCommon' could not be found找不到类型或命名空间名称“ProfileCommon”
【发布时间】:2012-06-19 21:34:30
【问题描述】:

Gooday,我正在使用 Visual Studio 中的 C# 网站创建一个 ASP.NET。我使用 ProfileCommon 并偶然发现了这个错误:

找不到类型或命名空间名称“ProfileCommon”(您是 缺少 using 指令或程序集引用?)

希望它有一个快速修复? 我应该包含什么指令?非常感谢。

编辑:有什么建议吗? - 安装此插件后: http://archive.msdn.microsoft.com/WebProfileBuilder/Release/ProjectReleases.aspx?ReleaseId=980

Error 1 The "BuildWebProfile" task failed unexpectedly. System.ArgumentNullException: String reference not set to an instance of a String. Parameter name: s at System.Text.Encoding.GetBytes(String s) at WebProfileBuilder.Builder.IsProfileSame() at WebProfileBuilder.Builder.GenerateWebProfile(BuildWebProfile buildWebProfile) at WebProfileBuilder.BuildWebProfile.Execute()
at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult) Cinemax

【问题讨论】:

  • 网站或网络应用项目模板?
  • ASP.NET Web 应用程序,爱尔兰语。
  • 然后按照我的回答中的链接 :)
  • 谢谢你,爱尔兰人!你的选择是我尝试的第三个。第三次幸运,我希望!会告诉你进展如何。
  • 爱尔兰人,我应该用什么来代替“命名空间 LD.Sample.BLL”?或者我应该复制那行吗?这是什么意思?我正在阅读:leedumond.com/blog/asp-net-profiles-in-web-application-projects。我下载了存档并注意到您的项目/解决方案名为“LD.SAMPLE”。那么我应该写 [我的项目名称].BLL 吗?

标签: c# asp.net visual-studio-2008


【解决方案1】:

您很可能正在使用 Web 应用程序项目模板。配置文件仅随网站项目模板开箱即用。有关解决方案,请参阅 herehere

【讨论】:

    【解决方案2】:

    看这里:http://forums.asp.net/t/1031740.aspx/1 或这里Error "The type or namespace name 'ProfileCommon' could not be found"

    配置文件的基类是 ProfileBase 类,用于处理用户配置文件。 当 Web 应用程序启用用户配置文件时,将创建一个名为 ProfileCommon 的新类。此类用于配置文件配置部分中定义的每个属性的访问器。 ProfileCommon 类的访问器然后调用 getter 和 setter 来检索和设置属性值。

    您需要将using System.Configuration;System.Web.Profile; 添加到您的项目中。

    您可能会在此处获得更多信息: http://msdn.microsoft.com/en-us/library/system.web.profile.profilebase.aspx

    希望有帮助!

    【讨论】:

    • 谢谢杰森。我尝试了第一个链接并安装了加载项,但我仍然遇到同样的问题。
    • 尝试使用来自 MSDN 的解释的最后一个链接,这应该对您有所帮助。
    • 你在使用 System.Web.Profile; ?
    • 是的,我刚刚添加了 System.Web.Profile,但仍然是同样的错误。
    • 访问此链接您可能会找到答案weblogs.asp.net/joewrobel/archive/2008/02/03/…
    【解决方案3】:

    就我而言,我必须将配置文件元素添加到 web.config 文件中。

    <profile enabled="true" defaultProvider="MyCustomProfileProvider">
    ...
    </profile>
    

    MSDN -profile Element (ASP.NET Settings Schema)

    【讨论】:

      【解决方案4】:

      我花了很多时间来理解这个问题。对我来说,WebApplication 项目在本地运行良好,但在部署的 WebApplication 版本上出现此错误。 WebApplication 不会自动创建 ProfileCommon 类。因此,我在项目中创建了以下类(没有所有生成的代码都会看到的命名空间):

      public class ProfileCommon: ProfileBase
      {
      }
      

      就是这样!

      但如果您使用页面的 Profile 属性来获取和更新当前用户配置文件,则可以从您的配置文件类而不是 ProfileBase 继承

      【讨论】:

        【解决方案5】:

        我遇到了一个类似的问题,即找不到 ProfileCommon 并且我的 ASP.NET 网站无法构建,并出现非常无用的错误:

        The type initializer for 'System.Web.Compilation.CompilationLock' threw an exception.
        

        我可以通过将我的 Web.config 文件中 sessionState 模式的大写更正为:

        <sessionState mode="Off"/>
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2017-07-12
          • 2011-05-13
          • 2013-03-25
          • 2017-11-29
          • 2012-09-27
          • 2011-05-06
          相关资源
          最近更新 更多