- Home /
Error while creating WP8 build
Hi,
I getting below error when im trying to make a build for WP8 platform.
Error building Player: Exception: Failed to run assembly preprocessor with command line "Temp/StagingArea/Data/Managed\Assembly-CSharp.dll" -injectCtor -assemblyPath "Temp/StagingArea" -pdb.[Temp/StagingArea/Data/Managed\Assembly-CSharp.dll] Symbols will be read from Temp/StagingArea/Data/Managed\Assembly-CSharp.dll.mdb Injecting ctor Injecting fast invokes Error while in assembly preprocessor Temp/StagingArea/Data/Managed\Assembly-CSharp.dll
/////////////
For all other platforms its working fine. So can you guys let me know what seems to be going wrong.
Thanks
Answer by Thomas GF · Oct 17, 2013 at 09:39 AM
Hi,
I've been having a similar problem and was able to debug into it using ProcMon.exe (a free Windows tool) and .NET Reflector Pro (not so free but ABSOLUTELY worth its money).
With ProcMon I managed to find the actual command line tool with the Parameters it is called with. On my system, the call was
"C:\\Program Files (x86)\\Unity4\\Editor\\Data\\PlaybackEngines\\wp8support\\Tools\\AssemblyPreprocessor.exe" "C:\\projectname\\Temp/StagingArea/Data/Managed\Assembly-CSharp.dll" -injectCtor -assemblyPath "C:\\projectname\\Temp/StagingArea" -pdb
With .NET Reflector I was able to decompile the tool and debug into it quite easily (as I said, .NET Reflector rocks). In my case, the problem turned out to be caused by an abstract Start() method in a MonoBehaviour. AssemblyPreprocessor.exe can't handle that and crashes.
Maybe this helps you resolve your problem as well (it should!).
Hey $$anonymous$$, I'm trying to port an "old" game of $$anonymous$$e to Windows Phone 8 and I'm having the exact same error the OP was having. As my project is quite old and big, finding out where all the dll errors I'm having are by trial and error is almost an impossible task. I got quite interested by your solution as it is the first one I've found that seems to show exactly where the errors are. I've downloaded the programs you mentioned, but I'm afraid I'm not sure what I'm supposed to look for to get to the source of the problem. Would you $$anonymous$$d explaining in more detail the process you went through in order to find out about your issue? (in that case, the abstract Start())
Answer by npruehs · Jul 10, 2014 at 09:48 AM
Hey Seraph, these methods are not available in the Editor. Be sure to wrap the respective calls with proper defines. This code snipped from our code base should give you a start. You'll still need to import System.Reflection, as you've figured out already.
#if !UNITY_EDITOR && UNITY_WINRT
public static bool IsValueType(Type type)
{
return type.GetTypeInfo().IsValueType;
}
private static IEnumerable<Type> GetBaseTypes(Type type)
{
yield return type;
var baseType = type.GetTypeInfo().BaseType;
if (baseType != null)
{
foreach (var t in GetBaseTypes(baseType))
{
yield return t;
}
}
}
public static PropertyInfo GetProperty(Type type, string name)
{
return
GetBaseTypes(type)
.Select(baseType => baseType.GetTypeInfo().GetDeclaredProperty(name))
.FirstOrDefault(property => property != null);
}
public static MethodInfo GetMethod(Type type, string name)
{
return
GetBaseTypes(type)
.Select(baseType => baseType.GetTypeInfo().GetDeclaredMethod(name))
.FirstOrDefault(method => method != null);
}
public static FieldInfo GetField(Type type, string name)
{
return
GetBaseTypes(type)
.Select(baseType => baseType.GetTypeInfo().GetDeclaredField(name))
.FirstOrDefault(field => field != null);
}
public static bool IsEnum(Type type)
{
return type.GetTypeInfo().IsEnum;
}
public static Delegate CreateDelegate(Type type, object target, MethodInfo method)
{
return method.CreateDelegate(type, target);
}
public static bool IsAssignableFrom(Type first, Type second)
{
return first.GetTypeInfo().IsAssignableFrom(second.GetTypeInfo());
}
#else
public static bool IsValueType(Type type)
{
return type.IsValueType;
}
public static PropertyInfo GetProperty(Type type, string name)
{
return type.GetProperty(name);
}
public static MethodInfo GetMethod(Type type, string name)
{
return type.GetMethod(name);
}
public static bool IsEnum(Type type)
{
return type.IsEnum;
}
public static FieldInfo GetField(Type type, string name)
{
return type.GetField(name);
}
public static Delegate CreateDelegate(Type type, object target, MethodInfo method)
{
return Delegate.CreateDelegate(type, target, method);
}
public static bool IsAssignableFrom(Type first, Type second)
{
return first.IsAssignableFrom(second);
}
#endif
Hi npruehs - I'm curious how you got this to build in Unity. I'm still getting a build error when it's creating the actual VS project despite "using System.Reflection" and adding the conditionals. $$anonymous$$y guess is that Unity isn't referencing the right assembly behind the scenes, but that's just a guess.
Answer by Seraph Auto · Sep 26, 2013 at 09:54 AM
I also get the same error. In addition, another error is also comes with it.
Type System.Type' does not contain a definition for
GetTypeInfo' and no extension method GetTypeInfo' of type
System.Type' could be found (are you missing a using directive or an assembly reference?)
but I already added using System.Reflection and I checked this method is supported by Windows Store App and WP8.
Did any other guy have similar problem?
Thanks
Answer by itachi4365 · Apr 10, 2014 at 07:07 PM
Just make sure that no project is open in Visual Studio while you are building it. Closing visual studio worked for me.
Answer by apparition · Aug 25, 2015 at 02:48 PM
As npruehs says, wrap the code with #IF !UNITY_EDITOR && UNITY_WINRT, and also make sure you have using System.Reflection;
GetTypeInfo is an extension method in the System.Reflection namespace.