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 BerggreenDK · Jul 24, 2011 at 08:25 PM · monoserializedeserialize

Serialize/deserialize on ASP.NET (c#) server - possible?

I have different objects I would like to be able to load and save on a webserver. So I have made them as Class objects.

As example I have [Score] which I will be using for producing a hiscore on a server.

Score.cs

 using System.Runtime.Serialization;
 [System.Serializable]
 public class Score
 {
     public long Total;
     public string Name;
     public Score(){}
     public Score(string name, long total)
     {
         Total = total;
         Name = name;
     }
 
 }


This code I want to use as data structure (n-tier architecture) in both Unity3D as clientside structure and in my ASP.NET server I use it as serverside object too.

What I do is that I want to build a list-array like this:

 List<Score> hiscores = new List<Score>();
 hiscores.add (new Score("Player 1", 10000));
 hiscores.add (new Score("Player 2", 20000));
 hiscores.add (new Score("Player 3", 30000));
 hiscores.add (new Score("Player 4", 40000));

... then I want to serialize it into a bytearray so I can use WWWform to POST it:

 MemoryStream membytes = new MemoryStream(); 
 BinaryFormatter binFormatter = new BinaryFormatter();
 binFormatter.Serialize(membytes, hiscores );

...

then I call my WWWform and it goes to the webserver as expected.

BUT - on the webserver, in ASP.NET/C# I get an error 500 telling me that it cannot load the assemble for deserializing the data???

HUH?! I've read someone suggesting to make the assemble outside Unity3D and then link it externally, but as Unity3D uses MONO and ASP.NET uses .NET... is that possible in my situation or am I on the wrong path somehow?

I can easily transfer a simle bytearray with values from 0x00 to 0xff to my ASP.NET and save it. But once I start using serialize/deserialize things messes up?

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

4 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · Jul 24, 2011 at 08:54 PM

That's no problem managed code is managed code ;) C# (and of course UnityScript and boo) is compiled to the common intermediate language. If you create a C# dll in visual studio you can use it in Unity like a script file ;)

I never used ASP (neither with .NET or without ;)) so i can't say if there are problems to use a "normal" managed dll but i'm quite sure it will work just fine ...

Comment
Add comment · Show 2 · 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 BerggreenDK · Jul 24, 2011 at 08:58 PM 0
Share

so, what you are saying is that I just make a Visual Studio Project for a DLL and place all my data objects inside that, build it and then drag it into the Unity folder?

avatar image Bunny83 · Jul 24, 2011 at 11:19 PM 0
Share

Yep, you can even create classes that derive from $$anonymous$$onoBehaviour that can be attached to GameObjects. You just need to add the UnityEngine.dll to the project but that's not what you need in your case ;)

$$anonymous$$onoBehaviours in dlls get also "transfered" into the global namespace at import and appear as sub-objects of the dll asset. Those sub-assets represents the script / class. All custom classes will stay in their namespace.

avatar image
0

Answer by rausank03 · Sep 22, 2014 at 12:42 PM

You can visit to this link to get help regarding your queries http://techgurulab.com/

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
0

Answer by rausank03 · Sep 22, 2014 at 12:42 PM

if you want to increase your programming skills and also play to quiz then most welcome to this website: http://techgurulab.com/

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
0

Answer by Louis Watson · Sep 22, 2014 at 01:26 PM

sounds like you need to use a dll containing the definition of the serializable class/classes. for serialization to work the code that calls the method needs access to the definition aka the object graph.

if you target .Net v2.0 then mono will have no issues since that is what it is built off, or just target mono since its on your system. Note this only applies to your dll.

So package a dll with the class definition and import it from asp page and unity.

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

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Error Deserializing Dictionary 1 Answer

Passing lists to serialize and deserialize methods for XML parsing 0 Answers

webplayer serialize/deserialize error advice plz 0 Answers

Class not deserializing properly 0 Answers

Need Help Serializing/Deserializing XML 0 Answers


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