'的类型初始值设定项'抛出一个例外

时间:2014-06-16 16:08:28

标签: c# web-config repository-pattern

我见过类似的帖子..但我的问题是特定于代码的我猜... 我有存储库模式.. 在DropDown更改时,我使用Hit WebMethod进行Ajax调用,并将继续执行Get Operation .... 点击获取方法后......我得到了这个例外......

  

的类型初始值设定项   'Dashboard.Model.UFZillaErrorStatus.UFZillaErrorStatusService'扔了   例外。

内部异常是

"{"The method or operation is not implemented."}"

我的网络方法(UFZillaErrorStatus.aspx.cs)

 public partial class UFZillaErrorStatus : System.Web.UI.Page
    {

        [WebMethod]
        public static UFZillaErrorStatusList GetErrorStatusList(string program)
        {
            return Dashboard.Model.UFZillaErrorStatus.UFZillaErrorStatusService.Get(program);
        }
    }

我的服务代码:

namespace Dashboard.Model.UFZillaErrorStatus
{
    public static class UFZillaErrorStatusService
    {

        public static UFZillaErrorStatusList Get(string program)

        {
            UFZillaErrorStatusList il = new UFZillaErrorStatusList();
            foreach(UFZillaErrorStatusModel pts in _UFZillaErrorStatusList)
            {
                if (pts.Program == program)
                {
                    il.Add(pts);

                }

            }
            return il;
        }


        /// <summary>
        /// Refresh Repository
        /// </summary>
        /// <returns>True or False</returns>
        public static bool RefreshRepository()
        {

            _UFZillaErrorStatusList = repository.GetUFZillaErrorStatusList();
            return true;
        }

    }
}

在web.config中,我们必须注册repositoryMapping和entityMapping ......

<repositoryMappingsConfiguration>
    <repositoryMappings>

  <repositoryMapping interfaceShortTypeName="IUFZillaErrorStatusRepository" repositoryFullTypeName="Dashboard.Infrastructure.Repositories.UFZillaErrorStatus.UFZillaErrorStatusRepository, Dashboard.Infrastructure.Repositories, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
</repositoryMappings>

</repositoryMappingsConfiguration>
<entityMappingsConfiguration>
    <entityMappings>

  <entityMapping entityShortTypeName="UFZillaErrorStatusModel" entityFactoryFullTypeName="Dashboard.Infrastructure.Repositories.UFZillaErrorStatus.UFZillaErrorStatusFactory, Dashboard.Infrastructure.Repositories, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>

</entityMappings>
</entityMappingsConfiguration>

我的存储库类;

namespace Dashboard.Infrastructure.Repositories.UFZillaErrorStatus
{
    public class UFZillaErrorStatusRepository :  RepositoryBase<UFZillaErrorStatusModel>, IUFZillaErrorStatusRepository
    {

        //Get operation and save collection in UFZillaErrorStatusList 

        }


    }

和工厂类

namespace Dashboard.Infrastructure.Repositories.UFZillaErrorStatus
{
    public class UFZillaErrorStatusFactory : IEntityFactory<UFZillaErrorStatusModel>
    {
        #region IEntityFactory<UFZillaErrorStatus> Members

        public UFZillaErrorStatusModel BuildEntity(System.Data.IDataReader reader)
        {
            // Data Binding of Reader object to Model Class Properties
        }

        #endregion
    }
}

代码肯定太大......但我不知道我放错了什么......

0 个答案:

没有答案