To add to Daniel's reply,
Create an object that encapsulates the differences in functionality that you
need between your dev environment and your production environment (and any
others). You can have multiple child classes, one for each environment, all
inheriting from the same interface.
Then, when your app starts, call a factory method to return a child object
that matches the environment. The factory method can either refer to the
config file to detect the environment or use machine name or whatever you
want (I prefer config file, but it's your call). After that, none of your
code needs to ever write a line of different code for "production" vs "dev
environment" .
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik
Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Marc Jennings" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks for that. I guess I would have seen this if I had read the
> docs properly.
>
> It's not a problem, though. I'll just have to go back to the old
> switch(Environment.MachineName) kind of thing (Which I probably prefer
> anyway...)
>
> Thanks again, both responders...
>
> On Mon, 10 Jan 2005 09:53:12 -0500, "Nicholas Paldino [.NET/C# MVP]"
> <(E-Mail Removed)> wrote:
>
> >Marc,
> >
> > You aren't going to be able to do this. The reason is that the
> >Conditional attribute is evaluated at compile-time, not run-time. It is
> >strictly for pre-processor values, not environment values.
> >
> > If you want to do something based on the environment, you are going
to
> >have to write code that will detect the environment you are in, and then
> >make the appropriate calls.
> >
> > Hope this helps.
>