# Handling structs with PVI services

**URL:** <https://community.br-automation.com/t/handling-structs-with-pvi-services/2908>\
**Category:** Programming\
**Tags:** pvi\
**Created:** [April 17, 2024, 2:58pm UTC](https://community.br-automation.com/t/handling-structs-with-pvi-services/2908 "2024-04-17T14:58:19Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![unterbergerc](https://avatars.discourse-cdn.com/v4/letter/u/FF8800/32.png) [@unterbergerc](https://community.br-automation.com/u/unterbergerc)\
**Post date:** [April 19, 2024, 6:37am UTC](https://community.br-automation.com/t/handling-structs-with-pvi-services/2908/3 "2024-04-19T06:37:25Z")

</div>

If you connect a structure variable in C# then the whole variable will be read / written. It might appear different because of the property struct\_variable.WriteValueAutomatic which is true by default and causes writes of the whole structure whenever a member is written to.

To prevent this and manually write the whole sturcture when you are ready, you can either set struct\_variable.WriteValueAutomatic = false; or you can assign values instead of writing them.

e.g.

struct\_variable.WriteValueAutomatic = false;  
struct\_variable.Value[“member1”] = 1;  
struct\_variable.Value[“member2”] = 1;  
struct\_variable.WriteValue();

OR

struct\_variable.WriteValueAutomatic = true;  
struct\_variable.Value[“member1”].Assign(1);  
struct\_variable.Value[“member2”].Assign(2);  
struct\_variable.WriteValue();

Notice that in both cases you have to write the variable by calling WriteValue() on the actual struct variable not its members.

Variable instances under struct\_variable.Members are not registered with the PviManager as individual variables by themselves and only serve to represent the member in .NET.

---

_[View the full topic](https://community.br-automation.com/t/handling-structs-with-pvi-services/2908)._
