问题
I have a .NET 4.0 C# console application. The application is deployed to a network file share (which I believe is a Windows 2000 Server file server) like this:
\\server\share\Apps\Beta\Group\JobName\JobName.exe
The agent machine that will execute the application is a Windows 2008 R2 Server, x64. I use a domain user account to run the application from the command line. When run under a certain account we'll call UserBeta, the application throws the following exception when trying to connect to a WCF service:
System.Configuration.ConfigurationErrorsException: Error creating the Web Proxy specified in the 'system.net/defaultProxy' configuration section. ---> System.Net.Sockets.SocketException: An invalid argument was supplied
The user account, UserBeta, has Modify, Read & Execute, List folder contents, Read and Write permissions introduced at the folder Beta and inherited by the child folders in the above path. If I use a second user account, UserStage, which has the same permissions except that they are introduced one folder higher, at the Apps folder, the application runs without exception. Both accounts belong to the local Administrators group on the agent server.
Interestingly enough, if the application is executed as UserBeta within 15 seconds or so of it being executed as UserStage, it will also run successfully.
I should also note that the application runs fine if run from a local drive as the GroupBeta account, so there seems to be some sort of trust issue with the particular account running from the network share.
I need the application to run as the UserBeta account from the network share. ClickOnce is currently not an option. I believe I could solve the problem by adding the permissions for UserBeta at the Apps folder, however I don't like throwing more access at something unless that's really the issue. If anyone has any other ideas or can point me to the reason adjusting permissions is the correct course of action, I'd be much appreciative.
来源:https://stackoverflow.com/questions/16194823/exception-when-running-net-4-0-application-from-network-share