Search Issue Tracker
Fixed in 2019.1.X
Votes
0
Found in
Issue ID
985941
Regression
Yes
bin-linux64 expected by Runtime Compiler
https://forum.unity.com/threads/bin-linux64-expected-by-runtime-compiler.510843/
Code (CSharp):
using System;
using System.CodeDom.Compiler;
using System.Linq;
using System.Reflection;
using System.Text;
using Microsoft.CSharp;
using UnityEngine;
public class RuntimeCompiler : MonoBehaviour
{
public void Start()
{
Debug.Log(CreateFunction().Invoke(null,new object[]{2,3}));
}
public static MethodInfo CreateFunction()
{
var code = @"
using UnityEngine;
public class Test
{
public static void Foo(int a, int b)
{
Debug.Log(""Hello, World!"" + a + """" + b);
}
}";
var param = new CompilerParameters();
// Add ALL of the assembly references
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies().Where(p => !p.IsDynamic))
{
param.ReferencedAssemblies.Add(assembly.Location);
}
// Add specific assembly references
param.ReferencedAssemblies.Add("System.dll");
// Generate a dll in memory
param.GenerateExecutable = false;
param.GenerateInMemory = true;
CSharpCodeProvider provider = new CSharpCodeProvider();
CompilerResults results = provider.CompileAssemblyFromSource(param, code);
if (results.Errors.Count > 0) {
var msg = new StringBuilder();
foreach (CompilerError error in results.Errors) {
msg.AppendFormat("Error ({0}): {1}\n",
error.ErrorNumber, error.ErrorText);
}
throw new Exception(msg.ToString());
}
Debug.Log(results.CompiledAssembly);
Type binaryFunction = results.CompiledAssembly.GetType("Test");
return binaryFunction.GetMethod("Foo");
}
}
Above is a simple example of a bug, where the .net compiler is looking for mono in a folder called bin-linux64 while the correct folder would be just bin.
It's fixed if you copy and paste
/opt/Unity/Editor/Data/MonoBleedingEdge/bin
and rename it to bin-linux64 .
Ran script under .Net 4.6 .
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- [URP] Invalid update of shader stripping settings
- [HDRP] Errors on Shader stripper that do not stripp shaders.
- Usage of Adaptive Probe Volumes throws a lot of IndexOutOfRangeException and Assertion Failed errors
- Prefab overrides don't recover missing managed references
- Trail Renderer visual doesn't match the positions of vertices when they have been offset
Add comment