Failed 'System.Security.Permissions.EnvironmentPermission' when C# application ran in another desktop

I have a C# application running well in one system, but it got the system security permission error in another system. How to resolve it?

The errors are
Unhandled Exception: System.TypeInitializationException: The type initializer for 'LM.DataCapture.Common.MachineInfo' threw an exception. ---> System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.EnvironmentPermission, mscorlib, Version=, Culture=neutral, PublicKeyToken=*************' failed.
   at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
   at System.Security.CodeAccessPermission.Demand()
   at System.Environment.get_UserName()
The action that failed was:
The type of the first permission that failed was:
The first permission that failed was:
<IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=, Culture=neutral, PublicKeyToken=*********" version="1" Read="UserName"/>

The demand was for:
<IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=, Culture=neutral, PublicKeyToken=**********" version="1" Read="UserName"/>
Who is Participating?
CuteBugConnect With a Mentor Commented:
Is your application trying to access the environment variables?
If that is the case, then make sure you have provided full trust to your application.
jl66Author Commented:
Yes. How to provide the full trust to my application. Could you say it in a little bit detail or point me a link? Thanks
jl66Author Commented:
Is the password wrong after moving? The password is in a xml file coming with C# application.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.