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=2.0.0.0, 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:
Demand
The type of the first permission that failed was:
System.Security.Permissions.EnvironmentPermission
The first permission that failed was:
<IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=*********" version="1" Read="UserName"/>

The demand was for:
<IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=**********" version="1" Read="UserName"/>
jl66Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CuteBugCommented:
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.
0
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
0
jl66Author Commented:
Is the password wrong after moving? The password is in a xml file coming with C# application.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.