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 /
  • Help Room /
avatar image
0
Question by macho · Mar 23, 2017 at 03:56 PM · visual studiodllnative pluginlibrarydll error

Move C# scripts to DLLs targeting UWP/Net deployment: the type or namespace 'SerializeAttribute/Serializable' could not be found?

I created some C# code for one of my Unity 5.4.0-f3HTP projects (developing on Win10, x64). This code "lives" in the Assets folder of the Unity project. I wrote the code so that the project can be deployed to HoloLens/UWP, and other platforms (of which only Windows/Osx are used). The C# code depends on access to code that lives in the UnityEngine namespace, the System. namespace, and the Microsoft. (for the UWP platform specific backend) namespace.

My goal is to take the C# code out of the assets folder, and use visual studio 2015 to compile it into two platform specific DLL's. One that is .net 3.5 (for Windows/OSX), the other is for UWP. The .net 3.5 DLL is not a problem. I can't figure out how to set up VS2015 to compile the UWP DLL though.

If I compile a "hello world" UWP dll (referencing Microsoft.NETCore.UniversalWindowsPlatform), things work just fine (including referencing the UnityEngine.dll from "C:\Program Files\Unity HoloLens 5.4.0f3-HTP\Editor\Data\Managed\UnityEngine.dll"). But as soon as I add code from the Assets folder, I get a number of errors:

Error CS0246 The type or namespace name 'SerializableAttribute' could not be found (are you missing a using directive or an assembly reference?)
Error CS0246 The type or namespace name 'Serializable' could not be found (are you missing a using directive or an assembly reference?)

Note that I am not making any changes to the code as I move it from the Assets folder; and I am setting up the appropriate preprocessor defines for the UWP/Mono backend.

I've tried several things to mitigate the problem, including splitting the code into two DLLs; one containing generic code that only depends on .NET and/or UnityEngine.dll, another that has platform specific code for either .NET or UnityEngine - but that did not work (I think I could not add the DLL containing the generic code as a reference to the UWP DLL). So I gave up on exploring this potential solution (but I'm still not sure if I did something wrong vs. it not being possible to do what I envisioned)

Has anyone encountered this before?

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 hexagonius · Mar 23, 2017 at 11:09 PM 0
Share

I know at least Serializable is part of System, not UnityEngine. have you included that?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by macho · Mar 24, 2017 at 01:31 AM

Apparently System.Serializable has been removed in UWP.

http://stackoverflow.com/questions/32446989/system-serializable-attribute-gone-in-windows-10-uwp-apps

After some more headscratching and chinstroking, I am now pursuing this approach:

I've tried several things to mitigate the problem, including splitting the code into two DLLs; one containing generic code that only depends on Mono and references UnityEngine.dll, another that has platform specific code for either Mono or UWP that is referenced by this 'generic' DLL

During runtime, I have a script in my unity scene that figures out what the appropriate platform specific DLL is, loads it from the streamingresources folder, and registers the factory creation methods for the platform specific class/interface implementations for either Mono or UWP

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

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

VS Code missing UnityEngine.UI 1 Answer

How to attach Visual Studio to Unity in order to debug a native dll? 1 Answer

Using RuntimeInitializeOnLoadMethod inside dll and using in iOS build 1 Answer

Transfer scene from project that uses DLL back to original source code 0 Answers

Vistual Studio Code won't let me access Unity Methods 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