开发者

JavaScriptSerializer Error Message - Duplicate type, how do I resolve?

I'm trying to serialize some strings and return through an ajax call and I'm seeing an odd error. Any help would be very much appreciated:

Compiler Error Message: </b>CS0433: 
The type 'System.Web.Script.Serialization.JavaScriptS开发者_运维知识库erializer' exists in both
 'c:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions\1.0.61025.0__31bf3856ad364e35\System.Web.Extensions.dll' and
 'c:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions\3.5.0.0__31bf3856ad364e35\System.Web.Extensions.dll'


The resolution I found to this was: Using the code for a JavascriptSerializer seems to throw exceptions when used within a webform. Place the class call in a web service and it worked perfectly. Perhaps there's some restrictions on the class?!


In my case, this was happening in an existing project. To fix it, I removed the entry for Web Extensions in the Web.config assemblies section. Once I did this it worked fine

    <compilation debug="true">
            <assemblies>
   ...
   <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,   PublicKeyToken=31bf3856ad364e35"/>
   ...

   </assemblies>
   </compilation>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜