Trying to update the managed reference registry with invalid propertyPath - c#

I have got this error while running my project: Trying to update the managed reference registry with invalid propertyPath(likely caused by a missing reference instance)'managedReferences[5133702300286058497].value', with value '2' in Unity 2021.3.9f1 Personal.
I have no clue what causes it and the error doesn't link to any of my scripts (or anything at all).
It happens only when I click on the run button and the project still works normally after unpausing it.
Does anybody know where to look to fix it (I checked the last properties I added) or what may cause it?
Thanks for your help

I still don't what really caused this error but I managed to fix it.
After discovering that propertyPath is a method of SerializedProperty, I tried to force the reserialization of my objects.
The fix was simply to remove the main script of my project containing lots of parameters I set through the inspector (I use OdinInspector) and recreate it.

Related

Xamarin.ios, Failed to lookup the required marshalling information

I am trying to use an outlet to alter the text in a TextField, but whenever I make any reference to the outlet, I receive an error saying "Failed to lookup the required marshaling information". I am new to Xamarin.IOS, and working with Xcode, and I have searched for an answer to my issue but there is nothing that fixes my issue.
ClientClass.cs
ClientClass.designer.cs
Inspector of ViewController using ClientClass
I figured it out, The issue with my case is I wasn't writing my code in the correct method. I guess you have to write your code in the ViewDidLoad method as I understand.

C# Visual Studio Debug DoDragDrop causes Win32 Exception clipboard format registration did not suceed

So I've been trying to pass Tuple data types in the DoDragDrop method of a winforms control. This does not appear to possible. I do get a Win32 Exception saying that clipboard was unable to register the format. It works fine with other datatypes which are not Tuple.
Is there any way to pass a tuple in a DataObject?
This applies to both normal Tuples and Value Tuples.
This does not happen with every Tuple .... Currently the following has been observed:
Tuple<RefType, RefType> does not work
Tuple<RefType, baseType> does work
Tuple<RefType> does work
Tuple<object, object> does work
This appears to be somewhat specific to my project as I am currently unable to make a minimal example that shows the same behaviour ...
Apparently its specific to the solution. I did make a minimal test project in the solution the error appears in and made it an independent project that starts up by itself. The error happens. If I reference that project in a different solution and run it, the error does not happen.
The error also only happens in Debug mode. If I run the application outside of Visual Studio it does not happen.
It turned out that this had nothing to do with DoDragDrop or Tuples in the end.
Deleting the .vs folder inside the solution made the error go away. Apparently something was misconfigured/broken inside there. No clue what however.
You might try this if you run into a similar problem

Hi when i try to capture the date from a text box it was not capture when i try to watch that parameter it was showing error [duplicate]

Here is the error
Cannot evaluate expression because a thread is stopped at a point where garbage collection is impossible, possibly because the code is optimized.
I am writing a simple console app and the first line of code is this:
List<MyObjectModel> list = MyObjectModel.GetNonCompletedReturns();
and the code for the function is:
public static List<MyObjectModel> GetNonCompletedReturns()
{
MyObject service = new MyObject();
List<MyObject> entities =
(from recs in service.Retrieve() where select recs).ToList();
List<MyObjectModel> models = new List<MyObjectModel>();
foreach (MyObject entity in entities)
{
models.Add(BindModel(entity));
}
return models;
}
and if I try to step through the code, as soon as I get back to the main of my app and hover over the list, I get the error message that I showed.
Can anyone help?
If your project is compiled in release (with optimizations turned on), you may see this. Have you tried the DEBUG configuration?
This error fires only when you are trying to use Watch dialog during debug.
Try to use some other technique to output the variables, like Debug.WriteLine, Console.WriteLine and so on.
None of the answers solved my problem so I'm posting the solution that helped me.
"If there is to much data in the parameters then this error can occure,
a simple solution is to make an object, not a struct because that's a dataobject.
Put this object in your parameters instead of all the different variables,
normally the problem will no longer take place."
Here's a little trick just in case you want to examine some objects and you are not able to change the parameters:
I've created a call to a new temporary function, inside the function from where I was unable to watch my object. Then, inside that new function I was able to watch my object. After the job is done, just delete the function.
While it's true that the "Cannot evaluate expression because a thread is stopped at a point where garbage collection is impossible, possibly because the code is optimized" error appears when in release mode, most developers just ensure that their projects are configured to compile as a debug build. BUT to be sure that you have no release-DLL issues, you also must check the references to DLLs that are in your solution and make sure that you don't have a reference to a release-build DLL. If you find that this is the case, delete the DLL reference and then add a project reference rather than a DLL reference. The project reference will ensure that your solution references debug or release versions of the DLL as specified in your build configuration.
Note that the above advice applies, of course, to only those DLLs to which you have source code and which are built from a project in your solution.
I got this too, when I hit a NullReferenceException from a 3rd party control.
In this one case, I found that if I set a breakpoint before I hit the exception, I could then single step through the rest of the code without seeing the problem.
No idea why, but this worked for me - in this case at least.
For what it's worth, this error can also be caused by an infinite loop in a property getter (simplified version below). When the debugger attempts to evaluate the property (e.g. in the watch window) the UI will hang for a few seconds and the "Cannot evaluate expression..." error will appear for many of the other properties in the same class.
public int MyProperty
{
get
{
while (true) { }
return 0;
}
}
First make sure that you're running your code in DEBUG mode and with code optimization turned off. you can turn that off from the properties of your project.
If you made all of the above and the problem persists, then it's probably a problem with the stack having Debug.Break() on top of it. The solution for this is very easy, just press F10 to move to the next line and you should be able to evaluate the expression.
You can check this SO question for more information about this issue.
I was experiencing the same error message in the Visual Studio debugger when evaluating a linq expression.
Disabling the VS debugger config setting 'Enable Just My Code' resolved the issue for me:
To enable or disable Just My Code, choose the Tools > Options menu in
Visual Studio. In the Debugging > General node, choose or clear Enable
Just My Code.
https://learn.microsoft.com/en-us/visualstudio/debugger/just-my-code
I was having same issue in Visual Studio 2017. Going to Debug> Options> Debugging> General and checking "Suppress JIT optimization on module load(Managed only)" fixed my issue

Null Reference Exception not related to a Null Object

I am confused ( that is easy enough!). I have a small snippet of code that I have taken a screenshot of.
The NRE arises after a failed test for a file path. Nothing there is null. The SceneryAreas object is initialized just before this test. However (and my screenshot did not pick it up) it seems that in the line SceneryAreas.Clear(); that SceneryAreas is null. Is it possible that the error is being shown on the wrong line and more to the point how could the instantiated object become null at this point?
Many thanks for any suggestions - I have never seen this before.
Your source code or symbols file is not in synch with your compiled code, hence the debugger is highlighting the wrong line.
If you recompile and re-run it should break on the line in your source which is causing the problem.
It is possible that the error's shown against the wrong line. Try rebuilding your project to make sure that the source files are in sync with the code being debugged. Also, check the stack trace under View Detail... to see exactly where the exception is being thrown.
As others said, the file does not correspond with the one used to build the assembly. The easiest way to check this is trying to set a breakpoint on the file, you will see a red circle saying that the file is different from the built one.

VS 2005 Compile on Save C#

This is baffling me, I am unable to find this setting if it exists.
I am 90% sure that my code used to compile on save before.
I only started having this issue when using C#, .net worked fine.
But now I am only able to get rid of error lines etc, when choosing to enter debug mode.
For example when I have a method
public bool Method1(){
//No code added yet so I get a blue line saying return something
}
Even when I add what to return inside the method the line remains there on save. It only goes away when I build.
(This is just one example it seems to happen with lots of other things)
EDIT - In regards to options to compile on save.
The options in Build and Run are set Correctly
That should produce a red underline and an entry in the Error List window: "not all code paths return a value". It is produced by the IntelliSense parser, not the compiler. Saving the file does not remove the error hint, only opening another project does. And fixing the code of course.
There is a bug of sorts in this logic, in some cases the Error List doesn't get purged. The only workaround I've seen is to restart Visual Studio. I've only seen this with certain IntelliSense warnings and it only affects the Error List, not the editor. I can't remember the exact type of warning that triggers this, it only ever happened when opening a project with code I didn't write. These messages don't normally last long when I'm editing code. Which is by far the best solution.
Should it not be the other way around? Save on compile.
Anyway, you can simple change the ctrl+s key combination to build and save in the settings menu.

Categories

Resources