- Home /
The requested item has been unloaded
While broken into my code using MonoDevelop, if I attempt to inspect some - not all - variables, MonoDevelop says the value is "The requested item has been unloaded".
I have no idea what that means, or why MonoDevelop / Unity decided to 'unload' that particular value.
It is getting increasingly annoying as I have to resort to Debug.Log and then sifting through other people's Logs to find the ones I'm interested in.
I have tried Googling to no avail, please tell me someone else has had this problem?
I'm using Unity 4.0 Pro on Mac OS X 10.8.2.
Thanks in advance.
Edit: Example code:
Damage = (int)(content.getNumber("damage"));
Round = (int)(content.getNumber("seq"));
OpponentMove = (Move)int.Parse(content.getString("moveId"));
WinnerID = content.getString("winner");
Damage, Round and WinnerID may all be in scope, but OpponentMove will not.
Sometimes if I use the variable, for example, Debug.Log(OpponentMove), it will be available for inspection. But only sometimes.
I have this problem on my machine at work that's running Unity 4.1. Don't get it on my home machine that's running a version pre 4.0 (can't remember off the top of my head). The main thing I've noticed it on is enums, don't think I've ever been able to inspect one. If you find a solution I'd really appreciate it if you could let me know.
I have noticed that it happens on enums, I'm not 100% sure if it's exclusively enums but I'm fairly sure it's not with every enum. But as you probably noticed, Opponent$$anonymous$$ove is an enum.
Also seeing this here - don't suppose you found a solution or workaround?
Nope, I've resorted to using Debug.Log to exa$$anonymous$$e any enums I find. Although at the moment Unity locks up upon attempting to break into a function that contains any enums.
That new monodevelop is all shiny and full of new stuff, but it's also loaded with a LOT of annoying bugs ! Why has it been included in the Unity bundle while it's clearly in a beta state at best ?
$$anonymous$$ine also triggers the infamous "item has been unloaded" exception when I disable a breakpoint, start the program with the debugger attached, and re-enables the breakpoint (an error popup is then displayed and my breakpoint no longer works). This is not however an exotic use case !
Answer by Artless · Apr 12, 2015 at 01:47 PM
You can patch Unity Monodevelop source to fix this bug and rebuild some dlls. I did that and uploaded dlls, you can just download and replace: There are Dlls for Monodevelop version 2.8.2 and 4.0.1 https://www.dropbox.com/s/p5gnzv8y8pcbdor/MonoDevelop_Patches.zip?dl=0 These dlls work for me, if you get problems, you can download Unity Monodevelop source and build them manually (I will point what needs to be added below).
In this dlls there are two fixes: First for not showing enum, and second for not showing generic collections saying "unknown type 'System.Collections.Generic.CollectionDebuggerView'1 mscorlib". Fix for inspecting collections is just ignoring custom Debugger Proxy class and using plain inspector, so you will see all inner members of List and Dictionary.
Fix for Enum: in SoftDebuggerAdaptor.cs TryCast function you can "eat" AppDomainUnloadedException and continue
if (valueType is TypeMirror) {
fromType = (TypeMirror) valueType;
try {
if (toType != null && toType.IsAssignableFrom (fromType))
return obj;
}
catch (AppDomainUnloadedException excep) {
}
// Try casting the primitive type of the enum
EnumMirror em = obj as EnumMirror;
Fix for generic collections: In ObjectValueAdaptor.cs GetProxyObject function instead of throwing if Proxy Object could not be loaded, return plain object it ignores proxy attribute for List, Dictionary, etc:
try
{
if (ttype == null)
return obj;
object val = CreateValue (ctx, ttype, obj);
return val ?? obj;
} catch (Exception ex) {
ctx.WriteDebuggerError (ex);
return obj;
}
fyi: copy to /Applications/Unity/$$anonymous$$onoDevelop.app/Contents/$$anonymous$$acOS/lib
Answer by ICEYHOTSTUNTA · Sep 13, 2013 at 11:34 PM
Such an annoying problem... Re-attaching the debugger while the game is running seems to fix the issue for me, it's still lame I have to do all that clicking to see an enum... Hopefully this helps someone else out!
Answer by baddie · Sep 06, 2013 at 07:36 PM
This is a bug in MonoDevelop, been there for ages, probably won't be fixed for the next few years.
I've found the following work around. For every enum in your code, you can add:
public int debugView_enumName {get {return (int) enumName; }}
This will let you then view the enum casted to an int in the watch window. Certainly a dirty solution, but we have to do what we can in these dark times.
Can you clarify what you are doing with that function and where you are putting it?
The function just casts the enum that you want to view to an int, you put it alongside the member enum you want to view. Its just a way to make the debugger display the value (whereas usually it refuses to show the value of an enum).
Answer by bcooley · May 29, 2014 at 09:29 PM
This is not a MonoDevelop problem, it's actually a Unity problem - but there is a workaround (see below).
The issue is that Unity constantly re-creates the .csproj files for MonoDevelop, which is not the standard way that MonoDevelop (or any IDE for that matter) actually works. This causes MonoDevelop's caching system (which is based on some sort of hash of the project file) for it's completion data to become invalid, causing lots of issues related to code completion and debugging (not just enums). The completion data for the project is actually pointing to a previous completion cache file and will not pick up any new definitions of enums, which causes the debugger to throw an exception when trying to show the enum value.
The solution is this: every now and then clear the caches. These are located on Mac in /Users/yourusername/Library/Caches/MonoDevelop-Unity-4.0/DerivedData (there is a corresponding folder on Windows but I don' t know where it is exactly). Deleting all of the files in this folder will clear the completion data cache, and force MonoDevelop to re-create the caches. This of course will only work once as Unity will then blow away your project files the next time you run Unity - so you'll have to do it every now and then to have the IDE re-sync it's caches.
The ultimate solution is for Unity to stop trashing project files they way they are doing it and allow MonoDevelop to work the way it supposed to work. If they need to update the project files, they need to do so in such a way that MD can correctly associate the new project file with the cached completion data in its completion cache.
This also seems to fix a lot of other annoying issues in Unity-$$anonymous$$onoDevelop that seem to be related to stale/invalid completion data.
I tried this on windows (the relevant folder is C:\\Users\\yourlogin\\AppData\\Local\\$$anonymous$$onoDevelop-Unity-4.0\\Cache\\DerivedData), but in my case the requested items were more unloaded than ever.
Answer by ShawnFeatherly · Dec 06, 2013 at 08:31 PM
I've been having the same problem. I've been using this method to spam Debug.Log:
private string PropertyDump(object variable)
{
var stringPropertyNamesAndValues = variable.GetType().GetProperties()
.Where(pi => pi.PropertyType == typeof(string) && pi.GetGetMethod() != null)
.Select(pi => new
{
Name = pi.Name,
Value = pi.GetGetMethod().Invoke(variable, null)
});
System.Text.StringBuilder dump = new System.Text.StringBuilder();
foreach (var pair in stringPropertyNamesAndValues)
{
string pairAsString = string.Format("Name: {0} Value: {1}{2}", pair.Name, pair.Value, System.Environment.NewLine);
dump.Append(pairAsString);
}
return dump.ToString();
}
Your answer
Follow this Question
Related Questions
Breakpoints stopped triggering in MonoDevelop 4.0.1 4 Answers
Why does monodevelop sets "pink", nonfunctioning breakpoints ? 1 Answer
mono develop debugging stops on lines without breakpoints 2 Answers
Unity 4.3.1 - debugger won't break at breakpoints 0 Answers
How to access static members in the watch/immediate window when debugging with MonoDevelop 0 Answers