2

I have to modify a C# project to add new features using VS 2012 and first I am trying to build it and run it before modifying anything to make sure I have everything before starting.

When I run the app, it stops because it tries to find an environment variable and can't figure out how to create that variable without modifying the code.

Here is the piece of code where it looks for the variable:

string searchPath = Environment.GetEnvironmentVariable("OWN_VARIABLE_PATH");

I have tried to add user and system environment variables but without success.

I would really appreciate any advise.

diditexas
  • 121
  • 1
  • 10
  • 1
    http://itechtalk.com/thread3595.html – Steve Oct 01 '13 at 11:19
  • This looks like a smell to me, because the variable would need to be set on any machine running that module. If possible, I would try to find the person who implemented that line and ask her, what she was trying to achieve. Maybe a config setting could be a simple alternative. – EagleBeak Oct 01 '13 at 11:36
  • possible duplicate of [How do I get and set Environment variables in C#?](http://stackoverflow.com/questions/185208/how-do-i-get-and-set-environment-variables-in-c) – Akanksha Gaur Oct 01 '13 at 11:54

1 Answers1

1

Have you made sure that the variable is set in your Environment Settings?

See this link:

http://www.beansoftware.com/NET-Tutorials/Environment-Variables.aspx