views:

61

answers:

1

Hi all,

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 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

+1  A: 

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.

Kev
I know for a fact that the server is only running the beta version of 3.5 not RTM, we never upgraded it because we were worried it would mess up the stuff we already had running on the server. What I did do was locate System.ServiceModel.Web.dll and replace it with a newer version I found on one of our other servers which IS running RTM (and it had a bigger file size). Unfortunately I still got the same error.
jonhobbs
I'm thinking of just putting hte script on a newer server and calling it from there.
jonhobbs
@jonhobbs - when you say 'replace', how did you replace it?
Kev
I just deleted the old file and put the new one in it's place.
jonhobbs
@jobhobbs - unfortunately that won't work, see my update to the answer.
Kev
Thanks Kev, I hadn't heard of GACUTIL.exe. In this instance I think it's going to be safer to just run the script on another server but I've learnt quite a bit so thanks for your help.
jonhobbs
FYI if you're still running a beta version of .net on your servers to run prod apps, you're probably in breach of the go live license.
serialseb