Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by $$anonymous$$ · Nov 21, 2017 at 06:41 AM · reference assemblies

Impossible reference Issue

Assets/Scripts/Data.cs(3,18): error CS0234: The type or namespace name \`Script' does not exist in the namespace \`System.Web'. Are you missing an assembly reference?

My file is Data.cs -> using System.Web.Script.Serialization;

When I try to Edit References one of two things happens - 1. ) the build fails because of the above error and prevents me from being able to Edit References 2. ) i comment out the offending code and go to Edit Reference, checkmark the Web.Extensions option which is what I've learned is the correct one, uncomment the code and the error goes away, go to Unity which still complains with the above error, I go back to Monodevelop and suddenly have the same error again.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Bunny83 · Nov 22, 2017 at 04:48 AM

Once and for all you can't manually edit external references in your C# project for several reasons:

  • First of all Unity doesn't use the project it generates at all. It just generates the project so it can be opened in a scripting IDE like VisualStudio or MonoDevelop.

  • Second Unity will actually overwrite the project each time it syncs the project. That happens whenever a script gets added / removed or if you simply move a script around inside Unity (move it from one folder to another).

  • Finally Unity doesn't use any external references at all. Unity has it's framework and some core assemblies which it automatically references when it builds / compiles your scripts. Unity doesn't rely on an installed .NET or Mono framework on the endusers device. Unity includes the Mono framework in the build. If you want to use a non-core / non-automatically-included assembly you have to physically copy that assembly and all it's dependencies into your project's assets folder.


So you can't just link your project to externally located assemblies. When you actually copy an assembly into your project it will be automatically added to the references. Of course not every assembly can be included in a Unity project as it might has unsupported dependencies or rely on native code which might not be available for your target platform.


Note that for platforms which do not use an embedded scripting runtime (like Windows Phone afaik which uses the actual .NET the OS provides) the behaviour might be different. Also certain thing could change in the future. However since I work with Untiy (version 2.6 around 2010) nothing has changed so far.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image $$anonymous$$ · Nov 22, 2017 at 04:03 PM 0
Share

thanks for the help, but i'm afraid i'm stuck - physically copy that assembly and all it's dependencies into your project's assets folder. I found System.Web.Extensions.dll and copied it over to Assets/Scripts/Assemblies, is that right? It's not having any effect on my issue. If this issue has existed for at least 7 years, shouldn't there be an easy solution? If i checkmark the reference and I also check 'local copy' one would think that an actual local physical copy is made if that's what unity needs...

avatar image Bunny83 $$anonymous$$ · Nov 22, 2017 at 09:53 PM 1
Share

I just copied the "System.Web.Extensions.dll" located at:

 C:\Program Files\Unity\Editor\Data\$$anonymous$$ono\lib\mono\2.0\

Into my test project. I created this test class:

 using UnityEngine;
 using System.Web.Script.Serialization;
 
 public class TestData
 {
     public string someText = "Hello world";
 }
 
 public class WebScriptSerializationTest : $$anonymous$$onoBehaviour
 {
     void Start ()
     {
         var serializer = new JavaScriptSerializer();
         Debug.Log("Data: " + serializer.Serialize(new TestData()));
     }
 }

attached it to a gameobject and run the game. I get a Log in the console that reads:

 Data: {"someText":"Hello world"}

What's your exact problem? Some assemblies requires .NET 2.0 compatibility however my test project is set to ".NET 2.0 Subset" (the default).


ps: I copied the assembly into `Assets\UATests\WebScriptSerialization` however the path shouldn't really matter.

avatar image $$anonymous$$ Bunny83 · Nov 23, 2017 at 12:23 AM 0
Share

awesome thank you so much! $$anonymous$$y problem seems to have been that I copied the .dll from \lib\mono\gac\ ins$$anonymous$$d of \lib\mono\2.0\ . but now I'm getting a new error TypeLoadException: Could not load type 'System.Web.UI.Script$$anonymous$$anager' from assembly 'System.Web.Extensions, Version=3.5.0.0, Culture=neutral, Public$$anonymous$$eyToken=31bf3856ad364e35' I copied over all System.Web.X.dll's but no luck. Going to search now.

BTW, I'm on $$anonymous$$ac, maybe that is my problem.

avatar image
1

Answer by ZeN12 · Nov 21, 2017 at 09:27 AM

Check API compatibility level. Try to set it to .NET 2.0. File -> Build Settings -> Player Settings -> Other Settings.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by pako · Nov 21, 2017 at 01:04 PM

As far as I can tell System.Web.Script.Serialization is not included in the Mono version that Unity uses. The last Mono Compatibility List that I could find is this:

https://docs.unity3d.com/401/Documentation/ScriptReference/MonoCompatibility.html

...which is outdated.

With Unity 2017.1 an experimental version of the core scripting runtime upgraded to Mono/.NET 4,6 runtime was introduced: https://blogs.unity3d.com/2017/07/11/introducing-unity-2017/

However, in VS2017 System.Web.Script.Serialization is not available in IntelliSense, which leads me to believe that this namespace is still not available in the Mono version that Unity uses.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image $$anonymous$$ · Nov 22, 2017 at 04:06 AM 0
Share

any idea how i can get JavascriptSerializer or if its a thing in the newer verison?

avatar image pako $$anonymous$$ · Nov 22, 2017 at 11:45 AM 0
Share

@$$anonymous$$ I believe that @Bunny83 has already answered this question. $$anonymous$$aybe you should consider different ways to achieve what you want.

avatar image $$anonymous$$ pako · Nov 22, 2017 at 07:26 PM 0
Share

thanks they posted that answer an hour after i checked back and commented to you so i missed it, unfortunately what they say about physically copying over the assembly doesn't help me or i'm not doing everything correctly as the advice is vague, I believe I can solve my issue though by using the guide here https://unity3d.com/learn/tutorials/topics/scripting/persistence-saving-and-loading-data

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

73 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Command line build fails after updating to Unity 2019.4 1 Answer

How to add Unity API reference to Visual Studio's keyboard shortcuts? 1 Answer

.NET dll seen as native in Unity3D 1 Answer

accessing a class by interface requries reference to other unrelated interface's assembly 0 Answers

How to properly use class from custom DLL project in 'Assembly-CSharp-Editor' 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges