Hi, @GavinCrump
yes, your issue is related to this bug
The bug is present on IronPython2 and PythonNet 2.5, but has been fixed on IronPython3 and PythonNet 3.
opened 04:17PM - 24 Mar 22 UTC
closed 09:29PM - 27 Apr 22 UTC
confirmed
### Prerequisites
The issue tracker is used to report bugs and request new fe… atures, NOT to ask questions.
Questions should be posted to the users mailing list which can be accessed at
https://ironpython.groups.io/g/users.
* [x] Are you running the latest version?
* [x] Did you perform a cursory search?
### Description
.NET property is not accessible in derived classes where only the setter or the getter has been overridden
a workaround is to use the unbound base class instance method syntax (Ipy2 or Ipy3)
### Steps to Reproduce
C# lib
```
using System;
using System.Collections.Generic;
namespace TestGetter
{
public class BaseClass
{
protected string name = "noname";
public virtual string Name
{
get { return name; }
set {name = value; }
}
}
public class DerivedClass : BaseClass
{
public override string Name
{
set { base.Name = value.ToUpper();}
}
}
}
```
Python code
```
import clr
import sys
import System
print(sys.implementation)
print(sys.version)
sys.path.append(r'C:\Users\****l\Documents\SharpDevelop Projects\TestGetter\TestGetter\bin\Debug')
clr.AddReference("TestGetter")
from TestGetter import BaseClass, DerivedClass
d = DerivedClass()
b = BaseClass()
b.Name = 'BaseClass Name'
d.Name = 'DerivedClass Name'
print("#" * 40)
print(b.Name) # ok
print("#" * 40)
try:
print(d.Name) # TypeError: property cannot be read
except:
import traceback
print(traceback.format_exc())
print("#" * 40)
try:
print(BaseClass.Name.GetValue(d)) # workaround ok
except:
import traceback
print(traceback.format_exc())
```
Result

opened 08:43PM - 13 May 21 UTC
closed 04:42PM - 04 Jan 22 UTC
bug
### Environment
- Pythonnet version: 2.5.2
- Python version: 3.7
- Op… erating System: Windows 10
- .NET Runtime: 4.8
### Details
- Let's create a simple base class that exposes a property, then create a derived class that overrides the setter, but not the getter (that is supposed to be as it was defined in the base class)
```C#
namespace PythonNetTest
{
public class BaseClass
{
protected string name = "noname";
public virtual string Name { get => name; set => name = value; }
}
public class DerivedClass : BaseClass
{
public override string Name { set => base.Name = value.ToUpper(); }
}
}
```
- Let's now use the above classes in Python
```python
import clr
clr.AddReference("PythonNetTest")
from PythonNetTest import BaseClass, DerivedClass
d = DerivedClass()
b = BaseClass()
b.Name = 'BaseClass Name'
d.Name = 'DerivedClass Name'
print(b.Name) # ok
print(d.Name) # TypeError: property cannot be read
```
- Here the `print(d.Name)` will rise the exception `TypeError: property cannot be read`.
- As a workaround it is possible to use `print(d.GetType().BaseType.GetProperty('Name').GetValue(d))` instead, but it is not one would expect.
3 Likes