• 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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



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

Cinemachine (or the unity compiler) broken due to some unknown reason 1 Answer

I upgraded to Unity 2019.3.7 from 2018.4.0. Firebase cannot found dll. Below is the error which appears on pressing Play button. 0 Answers

Visual studio from unity not recognizing imported c++ CLR DLL 1 Answer

Removing Stubborn Dependencies in Visual Studio 1 Answer

Native DLL saying FileNotFoundException 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges