Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 FortisVenaliter · Jun 11, 2015 at 08:48 PM · c#webplayersocketsystem.io

How do you debug a System.IO exception Unity won't load in WebPlayer?

I'm working on a Web Player application with socket networking. Apparently Unity won't load most of System.IO on Web Player, which makes socket IO much harder.

My networking code is in a C# Managed DLL compiled against .NET 3.5 client profile.

The problem I'm running into now is that after connecting to the server and sending it a message, my program won't receive a message back. Looking at the logs, I see the following repeatedly:

 Could not load type 'System.IO.InvalidDataException' from assembly 'MyAssembly'.

But, it won't give me a stack trace. And since it won't load the exception, I have no idea what the problem actually is.

The worst part, though, is that this code works perfectly every time in the editor, but fails with that unloadable exception every time in any browser. Also, this same netcode has been used in a .NET WinForms application for over two years now with the same server, so it's well tested outside of Unity, but it's also very complex, so I can't just guess and check or I'll be at it for a month.

I've also tried adding extra try/catch blocks, but since it won't load the exception, it can't catch it.

So, my question is, how can I debug this? I'm hoping someone has an outside-of-the-box idea, because I've exhausted my store.

Comment
Add comment · Show 1
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 FortisVenaliter · Jun 12, 2015 at 07:39 PM 0
Share

Okay, a few updates from my testing frustration:

One, it was suggested here to try a global exception handler, but since it won't load the exception, that's not helping...

Two, this works perfectly in PC standalone (in-editor and built), Web Player (in-editor only), and on Android (in-editor and built).

Three, what's really driving me nuts is that Unity allows me to build and run the code, but it won't load the exception. So, why the hell is it successfully compiling code that can throw the exception it can't load in the first place?

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Dave-Carlile · Jun 12, 2015 at 09:22 PM

There's not stack trace because there's no stack to trace. Unity is unable to load your assembly because it is unable to load the assembly containing System.IO.InvalidDataException that your assembly is referencing.

I would guess that the web player allows a subset of the System.IO namespace, and that particular exception class isn't part of that subset.

Another guess is that you're referencing something that isn't part of the .NET 2.0 framework, but then it wouldn't run standalone either.

As far as Unity allowing you to compile... I assume your dll is compiled outside of Unity right? At compile time the referenced System.IO assembly has the proper pieces so it compiles okay (again, outside of Unity). But only when it actually runs under the context of the webplayer is it able to find out that the referenced type isn't available, so you get the runtime error.

Comment
Add comment · Show 5 · 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 FortisVenaliter · Jun 12, 2015 at 09:44 PM 0
Share

Hmmm.... okay that makes sense. So, it only happens if done in an external DLL. Still doesn't explain why it runs okay in the editor, though. I'm surprised Unity wouldn't just reject DLLs that make calls into functions it can't link.

But, the bottom line, and what will get you marked as the correct answer is... how do I debug it? The code base is too big to just bring the full source into the Unity editor. If the editor won't catch it at compile or runtime, and it only occurs in the wild with no stack trace, how do I even isolate the source?

avatar image Dave-Carlile · Jun 12, 2015 at 09:57 PM 0
Share

There's nothing really to debug in the code - you're referencing an assembly that Unity can't use in the web player. You said yourself, Unity won't load most of System.IO in the web player.

avatar image FortisVenaliter · Jun 13, 2015 at 01:20 PM 0
Share

Okay, so start from scratch, or abandon Unity as a platform for this project. Damn, I was hoping for something better than that. Thanks for your help though.

avatar image Dave-Carlile · Jun 13, 2015 at 03:13 PM 0
Share

What is it you're trying to do that requires System.IO?

avatar image FortisVenaliter · Jun 14, 2015 at 12:25 PM 0
Share

Just basic socket IO. Binaryreaders, $$anonymous$$emoryStreams, some compression, etc. No file-system accessing at all. If I can't do that, then my project is simply not viable with Unity, which is a damn shame.

avatar image
0

Answer by Jwizard93 · Dec 10, 2018 at 11:33 PM

If anyone still sees errors like this I saw one today when building to standalone. The solution was Edit->ProjectSettings-> Player. And then in the inspector there was API Compability = ".NET 2.0 Subset." I changed it to ".NET 2.0" and rebuilt.

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

23 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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

TCPClient and SslStreams in WebPlayer (C#) 0 Answers

Problem parsing a file by group of lines 0 Answers

Renderer on object disabled after level reload 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