What does "Could not produce class with id" mean in Unity? - unity3d

When I'm building my unity app, I noticed when I use the developer mode, I get an error called "could not produce class with id 362". When I removed a certain object with a script I created, the error goes away. I have no idea what is producing this error or how to fix it.

Below is a partial answer. First, is some useful research I found while writing it:
Under certain build configurations, either using IL2CPP or using Engine Stripping in WebGL, Unity will aggressively strip out components in order to reduce build size.
One potential error from Unity being overaggressive about it can be could not produce class with id xyz.
The WebGL plaform documentation states:
##Issues with code stripping
Code stripping might cause issues with your project if it strips code
which is actually necessary. This can be the case when you load
AssetBundles at run time which contain classes that are not included
in the main build, and have therefore been stripped from the project.
Error messages appear in your browser’s JavaScript console when this
happens (possibly followed by more errors). For example:
Could not produce class with ID XXX
. . .
If you suspect that stripping is causing problems with your build, you can also try disabling the Strip Engine Code option during testing.
From PlayerSettings.stripEngineCodedocumentation
Remove unused Engine code from your build (IL2CPP-only).
If this is enabled, unused modules and classes of the Unity Engine
codebase will be removed in IL2CPP builds. This will result in smaller
binary size. It is recommended to use this setting, however, you may
want to disable it if you suspect this causes issues with your
project. Note that byte code stripping of managed assemblies is always
enabled for the IL2CPP scripting backend.
In the WebGL platform documentation, there is this suggestion to troubleshooting the issue in general. Even though your problem is seemingly not caused by WebGL or IL2CPP stripping, this might help you:
To troubleshoot these errors, look up the ID (such as XXX in the
example above) in the Class ID Reference to see which class it is
trying to create an instance of. In such cases, you can force Unity to
include the code for that class in the build, either by adding a
reference to that class to your scripts or to your Scenes, or by
adding a link.xml file to your project.
Below is an example which makes sure that the Collider class (and
therefore the Physics module) gets preserved in a project. Add this
XML code to a file called link.xml, and put that file into your Assets
folder.
<linker>
<assembly fullname="UnityEngine">
<type fullname="UnityEngine.Collider" preserve="all"/>
</assembly>
</linker>

Related

error cs2001 source file could not be found 2018

Ever since i open my project in unity today every script existed/Created have been given me
Error cs2001 source file "ScriptName.Cs" could not be found
I have reinstalled Unity, Tried Updating it and even created a new project. Still same outcome.
Ever time i tried attached my scripts to a object, it's have given me the error
Can't add script behaviour VisualContainerAsset",Can't Add Script "The script needs to derive from MonoBehaviour!"
Here is some pics how it's looks after i create a C# Script.
Sorry if i sound a bit confused!
UPDATE!:
Malware Bytes was the problem, it would't allow mono developed.
Could you show me one of the scripts? Maybe it misses some of the imports (using UnityEngine;) at the top. Or maybe they don't inherit from MonoBehaviour (classname: MonoBehaviour). It's strange nonetheless...

Guidance for diagnosing {"message":"An error has occurred."}

Can someone point me in the direction of instructions for working out what has gone wrong with my Mobile Service App. It was working fine with a couple of simple tables. I then extended the data model using code first and migrations and now all I get when enter a url such as:
http://xxxxxxxx.azurewebsites.net/tables/firm?ZUMO-API-VERSION=2.0.0
is
{"message":"An error has occurred."}
I have now removed all new tables/data objects and controllers so that only one exists for a single table called "Firm" which has a single string property. I have switch OFF authentication/authorization in the Azure portal but I still get the same error.
I have tried both CustomErrors=Off and CustomErrors=RemoteOnly in the debug web config. I am publishing a debug build.
I have tried switching on logging and remote debugging etc in Azure but am unable to work out what is broken. I have tried remote debugging with a break point in my FirmController GetAllFirms method but error occurs before that point.
How do I get more useful information about what the problem is?
I have managed to solve this one myself. In fact now that I know what it is the answer was staring at me from the build output.
The issue was that when extending my model I referenced a .NET Standard 2.0 class library containing some enum definitions that are common to both the backend and the client.
I did not notice the warning that some assembly versions needed binding redirects added to web config. Double click on the warning message and VS2017 will add the necessary entries to web.config for you.
For more details see here on github.
I never did manage to get behind the {"message":"An error has occurred."} though. I solved this by rebuilding my backend project one step at a time and it was after adding the reference to the .NET standard project than I noticed the "Consider app.config remapping of assembly ..." messages in the build output window.

Unity built-in Packages Compiler Errors

I just started learning how to use Unity to make a simple 3D game.
It's working fine when it comes to creating the environment, but once I imported the built-in Character package it gave me a compiler error and wouldn't run (All compiler errors have to be fixed before you can enter playmode!).
Removing the imported package removes the error and it can run, I tried using other built-in packages like 2D or Cameras but same problem occurred.
After adding 2D package, here's the console (error with no text):
After adding a character from the package, here's what the Inspector says (the associated script cannot be loaded. please fix all compiler errors and assign a valid script):
As shown in the pictures I'm using unity 5.6.0f3 64-bit.
I tried uninstalling and re-downloading it again but that didn't work.
I tried creating a new empty project, import a package and hit run, still didn't work.
A working solution from this post.
Hi, I reported this as a bug and I just got the response from Unity today. Try changing system locale to not Arabic. Go to Control Panel > Change date, time or number format> Administrative tab> Change system locale
Check if the script file name is the same as the class name in the file? They should be the same.
UPDATE
See this part of the picture.
No Monobehaviour scripts in the file, or the names do not match the file name.
And from here,
MonoBehaviours inside namespaces break, if they have a method with a default parameter (such as public void Foo(bool bar=true)).
See also here.
And it seems an identical issue of Compile Error with empty message.
Solution from the post:
Could get a Error message on another computer and it's the same as
mentioned in this Thread:
Creating managed DLL for Unity fails with error when importing into Unity
Which lead to this:
http://forum.unity3d.com/threads/5-2-1p3-mono-cecil-assemblyresolutionexception-unityengine-ui-dll.361666/
I could actually solve it with manually deleting all remains of Unity
and Monodevelop after the deinstallation (ex.
C:\Users[YourUserName]\AppData\Local etc. ) and then reinstalling
5.2.3f.

Accidentally published CompositeC1 with precompile on

I accidentally published Composite C1 from Visual Studio with "Precompile during publishing" when I first set it up and have now come to realize that several plugins do not work with precompile turned on. Unfortunately I have no idea how to reverse this. I've tried several things to no avail. I usually end up with a 500.0 error. If I go to the admin interface everything is working properly, and I can even preview the pages, but from the customer side all I get is a 500.0 error.
Of course I could republish from the Visual Studio project I have, but that project has the default template on it. I've tried copying what appears to be changed on the server to the original project but I end up with a 500 error. I've tried removing all the precompiled stuff on the server but I end up with a 500 error. I'm pretty lost.
At this point I'm willing to do anything. Is there a doc explaining how to copy the content to a newly downloaded copy, kind of like an upgrade doc but "side-grading"? I am using the most current version at the time of writing this 4.2 Update 1
Thank you
Solved use the PackageCreator suggested by wysocki's answer. It was not exactly straight forward to create the package. The errors can very cryptic at times. So here are some of the issues I encountered and how I got past them:
wysocki was correct to suggesting starting with a bare bones installation even though my original project was started with the Venus theme. I tried both ways.
I encountered issues with the MasterLayout and the Page Template Features which are currently not supported by the PackageCreator, although they may be supported in future versions. The solution was to add the missing elements to the fresh C1 project from the original C1 installation in the App_Data/PageTemplates and App_Data/PageTemplateFeatures folders.
A few times I ran into an issue where I added the same page or function twice to the PackageCreator. This was obviously my fault, but it should be mentioned that you can add the same site element twice which throws and error on import. Make sure you are careful to only getting one of each when creating the package to be exported.
If you are getting and error and it uses and Id like "4061397b-ee9e-4512-984d-f2b2d41eb654" I've found that it was very helpful to extract the zip file you are trying to import and then search the extracted folders for that Id. The lines with the Id usually have more information on them that will help you to identify exactly what content page or whatever the error is being generated from.
If you are using installed packages in your project like SimpleSearch for example, make sure you don't add it's functions to the PackageCreator. Install them separately.
I had an issue where I somehow had an element in the Data section that didn't have a "type". The error simply "The type cannot be empty". This was obviously tough to find so I suppose the lesson is, less is more. If you think your project might have a few elements that are unnecessary, don't add them at first and see if the project you import them into complains about missing them. It's much easier to troubleshoot missing elements than it is to figure out which element is causing the issue that you really didn't need.
Is there a doc explaining how to copy the content to a newly downloaded copy
You can try and export content / templates / anything else related to a "package" via Composite.Tools.PackageCreator.
Its latest version gives you quite a lot of flexibility in what you can export ("package") - please its user manual.
Once the package is made and downloaded, you can go on and install it on a new website. If you export / import a lot of content / templates etc, it makes sense to have a "Bare Bones" site as the new one.
All the starter sites like "Neptune", "Venus" are installed as a bunch of packages in specific order during Composite C1's initial setup.

Packing an Actionscript (Flash Builder) application for iPhone

Recently I tried to build a flash application in Flash Builder, and I wanted to export it to my iPhone. I have gone through all the required steps in order to certify my application.
Now, with all that done, all that was left to be done is building the ".ipa" file in Flash Builder. Now, this gives the following error:
'Launching TestGame' has encountered a problem.
Error occurred while packaging the application:
NotBefore: Wed Apr 11 18:52:40 CEST 2012
Google didn't give me a decent answer, nor does Adobe's information regarding mobile application development. All I can think off, is that I can't build the application before that date. That's ridiculous, I can't imagine a certain check like that.
I'm pretty sure my ".p12" key file is generated correctly.
Is anyone else familiar with this error? Please, be so kind to guide me in the right direction.
Kind regards,
Matthias.
The error occurs because the compiler didn't find the files under the corresponding directory such as debug-bin or release-bin folder. (explains from: http://forums.adobe.com/thread/893772)
For example, if you are doing a debug-build, and you didn't select the project option: copy non-embeded files to the output folder. And debug-build needs some files such as icons files under the debug-bin folder, and it couldn't find it.
Solution: select project compiling option: the copy non-embeded file to the output folder.
Try again, if still not you will need to try the ADT build to get more details http://help.adobe.com/en_US/air/build/WS901d38e593cd1bac35eb7b4e12cddc5fbbb-8000.html
I suggest compiling from command line. I'd ported an AIR app to iOS and compiled using adt dirrectly (without FB or whatever), and there were more meanful messages then yours. Take a look at the manual on how to build ipa wit adt. The other advise is to check your iPhone node in app.xml (take a look here) and icons.
The "error" was thrown because the certificate wasn't valid yet. It became valid on the date shown above.
You could also fix the manifest file in the iOS developers center.
This problem does come up more often than needed. The error reporting is lacking distinctions but is also difficult to asses since there can be many factors causing this error. If it was one factor or even just a few then it would most likely let you know.
A great way to ensure that the error reporting can do its job and tell you where the problem is is to check your error log. It will tell you at least a few of the places that threw the block.
If you are unable to read those strange glyphs then just ensure that all your resources are being packaged. This does mean a little time of list checking but it is well worth it, for the errors and to get rid of development junk.
The first step in the asset list check is to go through each part of your Assets class (flash builder reference). If you do not have a direct Assets class then you may want to make one and move all of your asset calls to that one class - since it will save you time if this happens again.
Your Assets class is not the same as your Assets folder. Your folder is where the files are stored - i.e. images, bitmaps, sounds, etc. Your Assets class is what categorizes and assigns references to each individual file.
Go through your Assets class to ensure that each of those files exist in the folder as well. Then go to the Project menu (top near Navigate and Search) and select Clean. Either clean all your projects or check the current one. Once this is done you need to click on your Assets Folder (right click or highlight and hit edit or whatever), and select Refresh. This will check that all the files are still there and get rid of/update them.
If none of this throws an error -red X- or other errors then you need to check your project .xml file. This may take you some time to ensure that all of your add on packages and details are correct. Make sure you have the correct:
at the top and it matches your current air release.
Make sure all the filenames, names, ids, version numbers, aspect ratios, fullscreen, visible, icons, extensionIDs, and everything else are not only correct but actually there. Most of these statements should have something written and not be blank. If they are blank find out what to put in.
Ensure that you have the proper icon file extension. If it says assets/icon48.png and the icon48.png is actually in assets/pictures/images/icons/toomanyfilesextensions/whatever/icon48.png
you need to fix that link.
The last thing that you will need to check is when you want to either Release Build or Debug. You need to make sure that all assets are checked and selected.
Go to Project - Properties.
then select ActionScript Build Path.
Click the Native Extensions tab and see if there are any red X's. If there are tap the little arrow beside them and see what the matter it. Add the correct ANE or get rid of it or whatever you need to do.
Then in the same menu go to the left and select ActionScript Build Packaging. A little arrow should be beside that one too. Tap the arrow and it will open to Apple iOS, BlackBerry, Gooogle and whatever else you have (probably nothing more). Select the OS your want to use, lets say Apple, and you will have 4 tabs pop up. Make sure you have the correct certificates selected. If you have none or are confused about this you need to spend some time on Google.
The biggest one for this error is under the Package Contents tab. Most people miss this!
Open the tab and see if anything is not checked. There will 99.99% be something or many of them not checked if you are getting this error. Just check them all and you can figure out what you need and don't need later. Some of them will be listed because you just threw in a bunch of ANEs and .SWFs to have some awesome app. Those add on packages will throw in unnecessary contents into this package. That is fine and don't worry until you want to be picky. Just make sure they are all selected and hit Apply and Ok.
That's it. You should have a working Release Build if you did everything else correct and this error should be easy from now on (but time wasting).
You may get a 'slip' error now, but that is another story. But that is a great sign because you are getting closer to that stupid mistake that we all make: the elusive spelling mistake.