UnityEditor unusable ? :: error CS0016
Hello my friends...
im getting the following errors every time I try to compile my scripts:
error CS0016: Could not write to file `Temp/Assembly-CSharp.dll', cause: Sharing violation on path C:\Users\Office\Documents\Jumper\Temp\Assembly-CSharp.dll.mdb
Compilation failed: 1 error(s), 0 warnings
AND
UNetWeaver error: Exception :System.ArgumentException: Member 'System.Int32 UnityEngine.Networking.NetworkConnection::hostId' is declared in another module and needs to be imported
at Mono.Cecil.MetadataBuilder.LookupToken (IMetadataTokenProvider provider) [0x00000] in <filename unknown>:0
at Mono.Cecil.Cil.CodeWriter.WriteOperand (Mono.Cecil.Cil.Instruction instruction) [0x00000] in <filename unknown>:0
at Mono.Cecil.Cil.CodeWriter.WriteInstructions () [0x00000] in <filename unknown>:0
at Mono.Cecil.Cil.CodeWriter.WriteResolvedMethodBody (Mono.Cecil.MethodDefinition method) [0x00000] in <filename unknown>:0
at Mono.Cecil.Cil.CodeWriter.WriteMethodBody (Mono.Cecil.MethodDefinition method) [0x00000] in <filename unknown>:0
at Mono.Cecil.MetadataBuilder.AddMethod (Mono.Cecil.MethodDefinition method) [0x00000] in <filename unknown>:0
at Mono.Cecil.MetadataBuilder.AddMethods (Mono.Cecil.TypeDefinition type) [0x00000] in <filename unknown>:0
at Mono.Cecil.MetadataBuilder.AddType (Mono.Cecil.TypeDefinition type) [0x00000] in <filename unknown>:0
at Mono.Cecil.MetadataBuilder.AddTypeDefs () [0x00000] in <filename unknown>:0
at Mono.Cecil.MetadataBuilder.BuildTypes () [0x00000] in <filename unknown>:0
at Mono.Cecil.MetadataBuilder.BuildModule () [0x00000] in <filename unknown>:0
at Mono.Cecil.MetadataBuilder.BuildMetadata () [0x00000] in <filename unknown>:0
at Mono.Cecil.ModuleWriter.<BuildMetadata>b__0 (Mono.Cecil.MetadataBuilder builder, Mono.Cecil.MetadataReader _) [0x00000] in <filename unknown>:0
at Mono.Cecil.ModuleDefinition.Read[MetadataBuilder,MetadataBuilder] (Mono.Cecil.MetadataBuilder item, System.Func`3 read) [0x00000] in <filename unknown>:0
at Mono.Cecil.ModuleWriter.BuildMetadata (Mono.Cecil.ModuleDefinition module, Mono.Cecil.MetadataBuilder metadata) [0x00000] in <filename unknown>:0
at Mono.Cecil.ModuleWriter.WriteModuleTo (Mono.Cecil.ModuleDefinition module, System.IO.Stream stream, Mono.Cecil.WriterParameters parameters) [0x00000] in <filename unknown>:0
at Mono.Cecil.ModuleDefinition.Write (System.IO.Stream stream, Mono.Cecil.WriterParameters parameters) [0x00000] in <filename unknown>:0
at Mono.Cecil.ModuleDefinition.Write (System.String fileName, Mono.Cecil.WriterParameters parameters) [0x00000] in <filename unknown>:0
at Mono.Cecil.AssemblyDefinition.Write (System.String fileName, Mono.Cecil.WriterParameters parameters) [0x00000] in <filename unknown>:0
at Unity.UNetWeaver.Weaver.Weave (System.String assName, IEnumerable`1 dependencies, IAssemblyResolver assemblyResolver, System.String unityEngineDLLPath, System.String unityUNetDLLPath, System.String outputDir) [0x00212] in C:\buildslave\unity\build\Extensions\Networking\Weaver\UNetWeaver.cs:1733
at Unity.UNetWeaver.Weaver.WeaveAssemblies (IEnumerable`1 assemblies, IEnumerable`1 dependencies, IAssemblyResolver assemblyResolver, System.String outputDir, System.String unityEngineDLLPath, System.String unityUNetDLLPath) [0x00062] in C:\buildslave\unity\build\Extensions\Networking\Weaver\UNetWeaver.cs:1757
UnityEngine.Debug:LogError(Object)
Unity.UNetWeaver.Log:Error(String) (at C:/buildslave/unity/build/Extensions/Networking/Weaver/Program.cs:20)
Unity.UNetWeaver.Weaver:WeaveAssemblies(IEnumerable`1, IEnumerable`1, IAssemblyResolver, String, String, String) (at C:/buildslave/unity/build/Extensions/Networking/Weaver/UNetWeaver.cs:1764)
Unity.UNetWeaver.Program:Process(String, String, String, String[], String[], IAssemblyResolver, Action`1, Action`1) (at C:/buildslave/unity/build/Extensions/Networking/Weaver/Program.cs:34)
UnityEditor.Scripting.Serialization.Weaver:WeaveUnetFromEditor(String, String, String, String, Boolean)
AND FINALLY
Failure generating network code.
UnityEditor.Scripting.Serialization.Weaver:WeaveUnetFromEditor(String, String, String, String, Boolean)
I dont know what happend it was just there. Im trying to get rid of this error since 2 days but I dont know what the problem could be. I saw the part with "hostId" but i dont even use this variable.
And I know this question was asked before and the most time they say I should turn off my anti virus but i dont even have such a program installed ¯_(ツ)_/¯
I hope someone of you has a solution for this problem !
What does your code look like? Are you passing a NetworkConnection in a command or something similar? That was the problem in the other post.
Indeed I am passing a NetworkConnection but even if I comment it out I cant compile my scripts:
Am I missing something ?
Here is the code:
using UnityEngine;
using UnityEngine.Networking;
using System.Collections.Generic;
public class Networking$$anonymous$$anager : Network$$anonymous$$anager {
public static Networking$$anonymous$$anager INSTANCE;
public List<OnlinePlayer> onlinePlayers = new List<OnlinePlayer>();
void Awake () {
INSTANCE = this;
}
/**
* SERVER
**/
public override void OnServerConnect(NetworkConnection conn) {
Debug.Log("Player connected !");
onlinePlayers.Add(new OnlinePlayer(/*conn*/));
Debug.Log("Waiting for name...");
}
public override void OnServerDisconnect(NetworkConnection conn)
{
Debug.Log("Player disconnected !");
for (int i = 0; i < onlinePlayers.Count; i++)
{
//if (/*onlinePlayers[i].networkConnection == conn*/)
//{
Debug.Log("Player " + onlinePlayers[i].name + " disconnected from server");
onlinePlayers.RemoveAt(i);
break;
//}
}
//Clean up
NetworkServer.DestroyPlayersForConnection(conn);
}
/**
* CLIENT
**/
public void Reset$$anonymous$$anager()
{
Destroy(gameObject);
onlinePlayers = new List<OnlinePlayer>();
}
}
public class OnlinePlayer
{
public string name = "Connecting...";
public int score = 0;
public int deaths = 0;
//public NetworkConnection networkConnection;
public OnlinePlayer(/*NetworkConnection conn*/)
{
//networkConnection = conn;
}
public void SetName(string _name)
{
name = _name;
Scoreboard$$anonymous$$anager.INSTANC$$anonymous$$UpdateScoreboard();
}
public void $$anonymous$$ick()
{
//networkConnection.Disconnect();
}
public void Reset()
{
score = 0;
deaths = 0;
}
public void Died()
{
deaths++;
Scoreboard$$anonymous$$anager.INSTANC$$anonymous$$UpdateScoreboard();
}
}
Answer by Uelmuel2 · Jan 15, 2016 at 02:24 PM
Yeah finally I discovered the problem . There was an error with the following script:
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Networking;
using System.Collections.Generic;
public class ScoreboardManager : NetworkBehaviour
{
public static ScoreboardManager INSTANCE;
public GameObject scoreboardItem;
public Transform scoreboardContainer;
public SyncListScoreboardEntry scoreboardEntrys = new SyncListScoreboardEntry ();
void Start ()
{
INSTANCE = this;
}
[ClientRpc]
void RpcRefreshScoreboard ()
{
Debug.Log ("Scoreboard needs to refresh !");
if (scoreboardEntrys == null)
return;
var children = new List<GameObject> ();
foreach (Transform child in scoreboardContainer)
children.Add (child.gameObject);
children.RemoveAt (0);
children.ForEach (child => Destroy (child));
foreach (ScoreboardEntry element in scoreboardEntrys) {
GameObject item = (GameObject)Instantiate (scoreboardItem, Vector2.zero, Quaternion.identity);
item.transform.GetChild (0).GetComponent<Text> ().text = element.name;
item.transform.GetChild (1).GetComponent<Text> ().text = element.score.ToString ();
item.transform.GetChild (2).GetComponent<Text> ().text = element.deaths.ToString ();
item.transform.SetParent (scoreboardContainer);
item.transform.localPosition = Vector2.zero;
item.GetComponent<RectTransform> ().localScale = Vector3.one;
//GUILayout.Box("Name: " + element.name + " Score: " + element.score);
}
}
[Server]
public void UpdateScoreboard ()
{
OnlinePlayer[] pls = NetworkingManager.INSTANCE.onlinePlayers.ToArray ();
if (scoreboardEntrys != null)
scoreboardEntrys.Clear ();
for (int i = 0; i < pls.Length; i++) {
ScoreboardEntry entry = new ScoreboardEntry ();
entry.name = pls [i].name;
entry.deaths = pls [i].deaths;
entry.score = pls [i].score;
//entry.conn = pls[i].networkConnection;
scoreboardEntrys.Add (entry);
Debug.Log (i + "Info:" + pls [i].name + " " + pls [i].deaths);
}
RpcRefreshScoreboard ();
}
public struct ScoreboardEntry
{
public string name;
public int score;
public int deaths;
//public NetworkConnection conn;
}
public class SyncListScoreboardEntry : SyncListStruct<ScoreboardEntry>
{
}
}
In this script I used the NetworkConnection and if I comment it out and restart the Unity3D-Editor the error is gone. But I think it is very annoying that I have to restart Unity to get rid of this error. But thank you
Thank you Jessespike for the hint with the NetworkConnection :)
Your answer
Follow this Question
Related Questions
Change assembly name 4 Answers
Can i change defualt target framework in .csproj to 4.7.2? 0 Answers
Namespace inside DLL file 0 Answers
How to apply steerAngle on car like in Traffic Racer game? 0 Answers