question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Property or indexer cannot be assigned to -- it is read only

See original GitHub issue

What im trying to do is transport simple string list over grpc. However i cannot assign value repeated string Role = 16;. Getting me error Property or indexer cannot be assigned to – it is read only

What version of gRPC and what language are you using?

grpc 2.30

What operating system (Linux, Windows,…) and version?

Window

What runtime / compiler are you using (e.g. .NET Core SDK version dotnet --info)

.NET Core SDK (reflecting any global.json): Version: 3.1.302 Commit: 41faccf259

Runtime Environment: OS Name: Windows OS Version: 10.0.19041 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.1.302\

Host (useful for support): Version: 3.1.6 Commit: 3acd9b0cd1

.NET Core SDKs installed: 3.1.301 [C:\Program Files\dotnet\sdk] 3.1.302 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download

What did you see instead?

Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

See TROUBLESHOOTING.md for how to diagnose problems better.

Anything else we should know about your project / environment?

Property or indexer ‘UserModelGRPC.Roles’ cannot be assigned to – it is read only

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
michalsscommented, Aug 8, 2020

OK thx understand it now. for others like me where it is how to make it work:

var iUser = new UserModelGRPC();
iUser.Roles.Add(iList<string>)
1reaction
JamesNKcommented, Aug 8, 2020

You can’t set the roles collection. You need to add values to the collection.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Property or indexer cannot be assigned to "--" it is read only
It has no setter, which makes it a readonly property, change it to: public string Passvalue { get { return Username; } set...
Read more >
CS0200 – Property or indexer 'property' cannot be assigned to
You will receive this error in your C# code when you attempt to assign a value to a property that does not have...
Read more >
Compiler Error CS0200
To assign to a property or indexer 'property' that's read-only, add a set accessor or assign the value in the object's constructor. C#...
Read more >
Property or indexer cannot be assigned to "--" it is read only
Anyway, here is how it looks: you specifically created a read-only member yourself and trying to assign a value to it. Your intention...
Read more >
Property or indexer cannot be assigned to -- it is read only
Anonymous types encapsulate read-only properies. The exception is thrown since you attempt to set a value of the proeprty. You should use a ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found