简体   繁体   中英

Unity3d Compiler Error

I have installed Unity 2018.1.0f2. I created a simple project that displays a cube for the HoloLens. Then when I try to build the project in Visual Studio 2017 I get the following errors in the file App.cs.

Error CS0012 The type 'CoreApplicationView' is defined in an assembly that is not referenced. You must add a reference to assembly 'Windows, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime'. PKproject3 C:\\Users\\Puran Kansakar\\Documents\\PKproject3\\App\\PKproject3\\App.cs 34 Active

Error CS0012 The type 'CoreWindow' is defined in an assembly that is not referenced. You must add a reference to assembly 'Windows, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime'. PKproject3 C:\\Users\\Puran Kansakar\\Documents\\PKproject3\\App\\PKproject3\\App.cs 58 Active

How do I solve it?

Puran

使用Unity而不是Visual Studio 2017构建项目。

Clean the project and rebuild it and hit start (blue play button). This might solve your problem.

Here, try following this workflow:

  1. Create a new project
  2. Add a cube to scene, set its position to (0,0,1)
  3. Click on Main Camera. Change Clear Flags to "Solid Color", Background to black, and position to (0,0,0)
  4. Click File -> Build Settings
  5. Under Platform, switch to Windows Universal Platform (if you do not have this installed, you will need to install it)
  6. Click Switch Platform
  7. Click Player Settings. Under Configuration, Change Scripting Backend to .NET (If desired, change Scripting Runtime Version to .NET 4.x -- I recommend this)
  8. Under XR Settings, check Virtual Reality Supported. Make sure under "Virtual Reality SDKs" you see Windows Mixed Reality.
  9. Go back to Build Settings, check Unity C# Projects
  10. Click Build and Run. When it opens a new window, make a new folder, name it "App". Double click into it and then click Select Folder
  11. When it finishes building, a folder will open automatically. Double click the VS solution in the main project folder. From here you can release

If that doesn't work in your Unity version, try a different Unity version. 5.5.x is stable for HoloLens, and I've had luck with the newest ones, such as 2018.2. I have never had luck working with IL2CPP over .NET personally, always led to compiler errors for me.

When you say you are building the project in VS are you first building the project in Unity and then opening the VS Solution file that is created and then building that? You also have to pay close attention to the .NET versions and scripting backend in your build settings as this affects what assemblies are referenced. I would recommend using IL2CPP instead of the .NET scripting backend since the .NET scripting backend is being deprecated. I would also recommend using the highest version of the Scripting runtime version and API compatibility release if you are starting a new project.

Edit: Definitely try the IL2CPP option I described as this gives you the highest .NET surface availalbe.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM