Could not find System.Core

Hello,

I have been trying to build our iOS/Android projects as Windows Store Apps with mixed success. The first project works well but while the second one builds fine it runs into an exception every frame. I checked the log file created and find the following:

Exception: The type initializer for ‘UnityScript.Lang.UnityRuntimeServices’ threw an exception.
InnerException: Could not load file or assembly System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e or one of its dependencies. The system cannot find the file specified.
AdditionalInfo:
at UnityScript.Lang.UnityRuntimeServices.GetEnumerator(Object obj)

at StaticController.Update()

at StaticController.UnityFastInvoke_Update()

The application doesn’t crash but the same error is present in other objects during update which disables most of the functionality, can’t click buttons etc.

Both projects also get some strange warnings during build if i set the build output verbosity to detailed in visual studio:

There was a conflict between “mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089” and “mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e”.
1> “mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089” was chosen because it had a higher version.

The same warnings are present in both projects but the exception only happens in one of them. in addition to mscorlib, the same warning is shown for System and System.Core. It looks like this could be the problem but then how come one of the projects still work?

I’m using windows 8.1 and Visual Studio 2012, could this be an issue?

Any ideas or suggestions are welcome.

Which SDK are you using?
Visual Studio 2012 has only 8.0 SDK, so you can not select 8.1 in build settings.

I’m not very experienced with visual studio, where can i check which sdk is used?

Are you using JS, if so, it’s not supported in 4.2

I am using JS yes. Are you saying it is not supported in unity 4.2 when building a Windows Store App?

I made some progress with the specific exception. Using for-loops of the following syntax seemed to be the problem:

for(object in objects)
{
    object.Function();
}

using a normal for-loop fixed it:

for(var i = 0; i < objects.Count; i++)
{
    objects[i].Function();
}

Maybe it can help someone else, thanks for your input!

Whilst other platforms do, Windows Store currently does not support JavaScript. You’re going to have to convert over to C# to publish to the Windows Store.

I’m not sure what you mean exaclty. I have successfully built one of our projects that is using JavaScript and have it running on a Surface RT and HP ElitePad. Do you mean the actual publishing?

In 4.2 JavaScript is unreliable on Windows Store Apps. Some things may work, others not.

Aha, I see, thanks. That explains the randomness of the exceptions and some things not working properly. I’ll have to convert some scripts or wait for an update i guess.