The error means the code is trying to initialize an instance type with another instance type where there is not way to guarantee the order.
The sample code shown is full of syntax errors and does not compile. Obviously the code shown is not the same as the code that is causing the compiler error.
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
The sample code shown is full of syntax errors and does not compile. Obviously the code shown is not the same as the code that is causing the compiler error.
how?
Yuki Tao
Where is the error?
Could you please post more details?
i try to share one instance of unit of work to avoid An entity object cannot be referenced by multiple instances of IEntityChangeTrackerexeption
when i have instantiate a unit of work at controller in mvc application, i get this error
c# a field initializer cannot reference the non-static field method or property
You posted code that does not compile and I'm unable to reproduce the issue after fixing all the syntax errors.
I explained the error and the error is easily Googled. Also, the compiler or error message show the line of code(s) that cause the issue. Start there...
Member
11 Points
84 Posts
c# a field initializer cannot reference the non-static field method or property + unit of work
Jan 10, 2019 02:26 PM|bensam16|LINK
when i try to share one instance of unit of work i get this error compiler in mvc controller code
c# a field initializer cannot reference the non-static field method or property
how o fix this?
this my Business logic
BLLBase
the BLL classes
a controller codes
All-Star
52971 Points
23571 Posts
Re: c# a field initializer cannot reference the non-static field method or property + unit of wor...
Jan 10, 2019 07:40 PM|mgebhard|LINK
The error means the code is trying to initialize an instance type with another instance type where there is not way to guarantee the order.
The sample code shown is full of syntax errors and does not compile. Obviously the code shown is not the same as the code that is causing the compiler error.
Contributor
3710 Points
1431 Posts
Re: c# a field initializer cannot reference the non-static field method or property + unit of wor...
Jan 11, 2019 09:53 AM|Yuki Tao|LINK
Hi bensam16,
Where is the error?
Could you please post more details?
This feature generally prevents you from initialization of the field with something which might not be yet ready.
I think you could refer to these links which similar to your issue:
https://stackoverflow.com/questions/15204420/a-field-initializer-cannot-reference-the-non-static-field-method-or-property
https://www.codeproject.com/Questions/793644/Error-A-field-initializer-cannot-reference-the-non
Best Regards.
Yuki Tao
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
11 Points
84 Posts
Re: c# a field initializer cannot reference the non-static field method or property + unit of wor...
Jan 11, 2019 09:06 PM|bensam16|LINK
how?
i try to share one instance of unit of work to avoid An entity object cannot be referenced by multiple instances of IEntityChangeTrackerexeption
when i have instantiate a unit of work at controller in mvc application, i get this error
c# a field initializer cannot reference the non-static field method or property
controller code:
how to fix this?
All-Star
52971 Points
23571 Posts
Re: c# a field initializer cannot reference the non-static field method or property + unit of wor...
Jan 11, 2019 09:30 PM|mgebhard|LINK
You posted code that does not compile and I'm unable to reproduce the issue after fixing all the syntax errors.
I explained the error and the error is easily Googled. Also, the compiler or error message show the line of code(s) that cause the issue. Start there...