It is strange that it is throwing a security exception when trying to do a DNS lookup. Is your machine part of a domain where restrictive group policy settings might be pushed down to your machine? Possibly a restrictive .NET trust policy has been pushed down to your machine.
You might try change localhost to 127.0.0.1 in your connection string, maybe that would bypass the dns lookup.
Hope it helps,