开发者

ASP.net error message when using REST starter kit

I've written some code using the REST starter kit and it works fine on my development machine. However, when I upload it to our开发者_StackOverflow中文版 server the page gives me the following error message...

CS1684: Warning as Error: Reference to type 'System.Runtime.Serialization.Json.DataContractJsonSerializer' claims it is defined in 'c:\WINNT\assembly\GAC_MSIL\System.ServiceModel.Web\3.5.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll', but it could not be found

I've removed code line by line and it appears that the following line of code is triggering the error...

HttpContent newOrganizationContent = HttpContentExtensions.CreateXmlSerializable(newOrganizationXml);

Really haven't got a clue how to fix it. I assumed it might be because it needs a newer version of the framework to run, but looking in IIS it says it's running version 2.0.50727 which I think is the lates version because it says that even when we're using framework 3.5

Very confused, any ideas?

Jon


At first I thought this was possibly because the server you're deploying to didn't have .NET Framework 3.5SP1 installed and only .NET 3.5RTM.

However, upon checking a .NET 3.5 RTM System.ServiceModel.Web.dll assembly I see that the System.Runtime.Serialization.Json.DataContractJsonSerializer is actually defined.

The compiler warning CS1684 suggests that there is a System.ServiceModel.Web.dll assembly in the server's GAC, but one that doesn't have the System.Runtime.Serialization.Json. DataContractJsonSerializer defined.

So things I would check:

  • Check that the deployment server is running at least .NET 3.5 RTM and that a beta or release candidate isn't in use or hasn't been left over.

  • In Visual Studio 2008 make sure you select a "Target Framework" of .NET 3.5 in the project properties.

One final check you could do to see if the problem lies with the server's framework install is to knock up a simple application to consume the DataContractJsonSerializer directly. There's an example on the MSDN documentation page for the class:

DataContractJsonSerializer Class (MSDN)

As a last resort, if the server is under your control then I'd uninstall .NET Framework 3.5 and then re-install from:

Microsoft .NET Framework 3.5 Service Pack 1 (Full Install)

Update:

As per your comments:

If you're running a beta of 3.5 then chances are that DataContractJsonSerializer isn't in the System.ServiceModel.Web.dll assembly.

I seem to remember back around the CTP, betas and release candidates there were late breaking changes in this area. I vaguely remember the DataContractJsonSerializer was one of these late additions/changes due to the increased popularity of JSON and community pressure. My memory is a bit vague but it rings a bell.

To replace the DLL you need to unregister the current version from the GAC then register the RTM one using the GACUTIL.exe tool. I wouldn't advise mixing RTM and beta bits, you're leaving yourself open to unpredictable behavour.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜