错误21找不到类型或命名空间名称'JsonValueProviderFactory'(您是否缺少using指令或程序集引用?) [英] Error 21 The type or namespace name 'JsonValueProviderFactory' could not be found (are you missing a using directive or an assembly reference?)

查看:101
本文介绍了错误21找不到类型或命名空间名称'JsonValueProviderFactory'(您是否缺少using指令或程序集引用?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在bin中添加了system.web.mvc引用和system.web.mvc.dll ..但是当我在global.asax中使用以下代码时,它在MVC2中给出了上述错误



 protected void Application_Start()< br /> 
{< br />
AreaRegistration.RegisterAllAreas();< br />
RegisterRoutes(RouteTable.Routes);< br />
ValueProviderFactories.Factories.Add(new JsonValueProviderFactory());< br />
}



Plz帮助我错过了什么???。这个JsonValueProviderFactory()给出错误

解决方案

请尝试如下。



 受保护  void  Application_Start()
{
AreaRegistration.RegisterAllAreas();

RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);

// Remove和JsonValueProviderFactory并添加JsonDotNetValueProviderFactory
ValueProviderFactories。 Factories.Remove(ValueProviderFactories.Factories.OfType< JsonValueProviderFactory>()FirstOrDefault());

ValueProviderFactories.Factories.Add( new JsonDotNetValueProviderFactory());
}







请阅读下面提到的文章以获取有关如何配置的更多详细信息使用Json.Net的JsonValueProviderFactory。



JsonValueProviderFactory使用Json.Net



更新



这是我从项目中提取的样本。请根据您的情况进行更改。



JS



 


.ajax({
url:/ PetBooking / GetSelectedCategoryTypeServices,
dataType:'json',
data:{providerKey:'<%:Model.Provider.Key% >',serviceCategoryTypeId:serviceCategoryTypeId},
success:function(data){

( #ddlService)fillSelect(数据)。
whenOnlyService();


I have already added system.web.mvc reference and system.web.mvc.dll in bin ..But when i am using following code in global.asax it is giving above error in MVC2

protected void Application_Start()<br />
       {<br />
           AreaRegistration.RegisterAllAreas();<br />
           RegisterRoutes(RouteTable.Routes);<br />
           ValueProviderFactories.Factories.Add(new JsonValueProviderFactory());<br />
       }


Plz help what i am missing???.tthis JsonValueProviderFactory() is giving error

解决方案

Please try is as below.

protected void Application_Start()
        {
          AreaRegistration.RegisterAllAreas();

          RegisterGlobalFilters(GlobalFilters.Filters);
          RegisterRoutes(RouteTable.Routes);

         //Remove and JsonValueProviderFactory and add JsonDotNetValueProviderFactory
            ValueProviderFactories.Factories.Remove(ValueProviderFactories.Factories.OfType<JsonValueProviderFactory>().FirstOrDefault());

      ValueProviderFactories.Factories.Add(new JsonDotNetValueProviderFactory());
        }




Please read the below mentioned article to get more details about how to configure JsonValueProviderFactory using Json.Net.

JsonValueProviderFactory using Json.Net

UPDATE

This is a sample which I extracted from my project.Please change it according to your situation.

JS


.ajax({ url: "/PetBooking/GetSelectedCategoryTypeServices", dataType: 'json', data: { providerKey: '<%:Model.Provider.Key%>', serviceCategoryTypeId: serviceCategoryTypeId }, success: function (data) {


("#ddlService").fillSelect(data); whenOnlyService();


这篇关于错误21找不到类型或命名空间名称'JsonValueProviderFactory'(您是否缺少using指令或程序集引用?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆