I made an "ASP.NET Empty Web Site" in Visual Studio Express 2010.
On a code file in the App_Code, I have the line "using System.Web.Script.Serialization;"
When I pushed the files to the server, I got the following error:
Exception message: c:\inetpub[....]\Extensions.cs(10): error CS0234: The type or namespace name 'Script' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
(The server is running Windows Server 2008 with IIS 7 with ASP.NET 4.0 installed.)
Since this is a web site, and not a web project, I couldn't use the "publish" feature as promoted here: The type or namespace name 'Script' does not exist in the namespace 'System.Web'
Finally, after some digging, I figured out that this namespace is included in the System.Web.Extension assembly, and that I had to manually include it via the web.config:
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</assemblies>
</compilation>
So, my question: is there a better way to go about this?
Since none of this is needed on my local project, how can I first determine what assemblies I'll need to reference manually, and second, how can I get the information required to do the referencing (i.e., how do I get the PublicKeyToken)?
UPDATE
Because this is a Web Site and not a Web Project, my list of references does not show up until after I add them to the Web.Config manually.
So, to select "Copy Local" to "true" does not work in this instance.
Looks like your provider does not have the dll System.Web.Extensions
in the GAC.
The namespace System.Web.Scripts
is part of the System.Web.Extensions.dll
.
You can solve your problem if you do.
System.Web.Extensions
in your project References Copy Local
to true
This ensures that you deploy this dll too.
Just add System.Web.Extensions as a reference to your project. You don't have to do it manually through web.config. Set Copy Local to true to make sure it is included in your distribution.
you can right click the project name/location in your web site project and choose Add Reference.... From there a dialog will display. Choose the .NET tab and select the System.Web.Extensions. This should add it to the project. You can do this for any namespaces that you need to add.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With