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 axonJeff · May 13, 2016 at 08:27 PM · visual studiobug-perhapsmonocompiler error

Bizarre compile errors in Unity while Visual Studio will build project successfully

I'm writing a system to handle computation on a background thread, and I've been experiencing the weirdest compile-time errors I've seen in a while from Unity, and I'm convinced that Unity is getting it wrong. Visual Studio 2015 will build my code successfully without skipping a beat. I'm at my wit's end and I'm asking in desperation in case someone knows what trickery is necessary to get Unity to compile this.

Unity claims that a class property and a class method that are clearly defined are not in scope. The symbols in question are TaskSetTimeoutMS and ThreadProc(). I'm sure they exist and work fine because I was running tests using this code at runtime only hours ago and it has barely changed.

The compile errors I'm presented with are as follows:

  1. Assets/Threading/Worker.cs(50,13): error CS0103: The name 'TaskSetTimeoutMS' does not exist in the current context.

  2. Assets/Threading/Worker.cs(55,36): error CS0103: The name 'ThreadProc' does not exist in the current context.

  3. Assets/Threading/Worker.cs(55,48): error CS1502: The best overloaded method match for 'System.Threading.Thread.Thread(System.Threading.ThreadStart)' has some invalid arguments.

  4. Assets/Threading/Worker.cs(55,48): error CS1503: Argument '#1' cannot convert 'object' expression to type 'System.Threading.ThreadStart.

Errors 1 and 2 are the only ones that really matter. 3 and 4 are just side-effects of 2 and will be resolved if 2 goes away.

My code is as follows. I omitted the guts of ThreadProc() since they're long and irrelevant.

 using System;
 using System.Linq;
 using System.Threading;
 
 namespace Axon.Threading
 {
     public class Worker<TContext>
     {
         // Private
         ManualResetEvent __beganWorkHandle;
         ConcurrentQueue<Exception> __exceptionQueue;
         bool __isStopping;
         WaitHandle[] __taskDoneSignals;
         ConcurrentQueue<Task<TContext>[]> __taskQueue;
         int __taskSetTimeoutMS;
         Thread __thread;
         ManualResetEvent __waitHandle;
 
         // Properties
         public int TaskSetTimeoutMS
         {
             get { return __taskSetTimeoutMS; }
             set
             {
                 __taskSetTimeoutMS =
                     ( value < 0 )
                         ? Timeout.Infinite
                         : value;
             }
         }
 
         // Computed Properties
         public WaitHandle BeganWorkSignal
         {
             get { return __beganWorkHandle; }
         }
         public WaitHandle WaitHandle
         {
             get { return __waitHandle; }
         }
         public bool IsWorking
         {
             get { return __beganWorkHandle.WaitOne( 0 ); }
         }
 
 
         // Constructor
         public Worker( int timeoutMS = Timeout.Infinite )
         {
             TaskSetTimeoutMS = timeoutMS;
             __beganWorkHandle = new ManualResetEvent( false );
             __exceptionQueue = new ConcurrentQueue<Exception>();
             __taskQueue = new ConcurrentQueue<Task<TContext>[]>();
             __waitHandle = new ManualResetEvent( false );
             __thread = new Thread( ThreadProc );
             __thread.Start();
         }
 
 
         // Thread Worker
         void ThreadProc()
         {
             // ...
         }
 
 
         public WaitHandle EnqueueWork( Task<TContext>[] tasks )
         {
             // Reset the work finished signal before allowing ThreadProc() to run.
             __waitHandle.Reset();
 
             // Push the new tasks onto the task queue to be handled in parallel by ThreadProc().
             // If the queue was previously empty, then the begin work signal should be set to start
             // ThreadProc() up again.
             __taskQueue.Enqueue( tasks );
             if ( __taskQueue.Count == 1 )
             {
                 __beganWorkHandle.Set();
             }
 
             // Return the wait handle to the caller as a convenience to save them having to look up
             // the WaitHandle member separately.
             return __waitHandle;
         }


         public Exception[] GetAndClearExceptions()
         {
             Exception[] exceptions = __exceptionQueue.CopyToArray();
             __exceptionQueue.Clear();
             return exceptions;
         }


         public void Stop()
         {
             __isStopping = true;
         }
     }
 }
 

It should be fairly obvious that errors 1 and 2 are bogus. Both TaskSetTimeoutMS and ThreadProc() are defined as class members and are clearly in scope.

Visual Studio agrees with me, anyway. So what do I do about Unity?

I've tried:

  • creating a new project and copying my files over

  • deleting my project's temp files and .suo files to force a fresh build

  • every permutation of code order I can think of (as though that should even matter)

  • causing errors and then getting rid of them

  • cleaning and rebuilding in VS

None of this has helped.

And to top it off, if I remove all of the offending code from the file, Unity simply gives me the very same errors for the EnqueueWork() and Stop() symbols instead, while Visual Studio is still perfectly content to build the project.

I had a perfectly good working project only hours ago. Any idea what I can do with this? I'm having a rough day.

I'm running Unity 5.2.4f1.

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

0 Replies

· Add your reply
  • Sort: 

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

53 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

Related Questions

Visual Studio 2019 Wont Compile After Unity 2019.3.12f1 update 4 Answers

Unable to load project - specified pathname not found compilation error 0 Answers

DOTS / ECS: Burst error BC1022: Accessing a managed array is not supported 0 Answers

UWP build crashes with "Windows.Gaming.Input.dll: Access denied" - what does it mean? 0 Answers

Missing type/namespaces do not allow me to playtest? 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