Share via

Visual Studio 2021 debugger doesn't work with dynamic type

Miguel 21 Reputation points
2021-11-30T05:52:52.82+00:00

I am using dynamic data type to create an object using inheritance of ExpandoObject and/or DynamicObject adding dynamically properties and fields. Everything seems to work, but I am not able to debug. When debugging (adding a watch, immediate or command window) a dynamic object created with
error CS1061: 'object' does not contain a definition for 'Hotels1' and no accessible extension method 'Hotels1' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)

Even though when running the code it works fine
Console.WriteLine(entity.hotels2);
Console.WriteLine(entity.hotels2.id);
Console.WriteLine(entity.hotels2.name);
Console.WriteLine(entity.hotels30.name);
Console.WriteLine(entity.hotels32.name);

All these objects bring me correct information and the information is printed on console, everything works but debugger always bring me errors when using dynamic objects.

Developer technologies | Visual Studio | Debugging
Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.