- Home /
Error occured performing webclient request. Application runs in editor but fails in standalone player
Hi,
I have an application that uses the webclient class in System.net to download a file and data from a website using the downloadData() and downloadFile() methods.
They work perfectly fine when running in the unity editor but when I build a Windows or Mac standalone player, the application crashes and throws an exception in the console log of:
InvalidProgramException: Invalid IL code in System.Configuration.ConfigurationManager:GetSection (string): IL_0000: ret
and
Rethrow as WebException: An error occurred performing a WebClient request.
The full exception:
Begin MonoManager ReloadAssembly
- Completed reload, in 1.031 seconds
UnloadTime: 3.595814 ms
Uploading Crash Report
InvalidProgramException: Invalid IL code in System.Configuration.ConfigurationManager:GetSection (string): IL_0000: ret
at System.Net.WebRequest..cctor () [0x00000] in <filename unknown>:0
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for System.Net.WebRequest
at System.Net.WebClient.GetWebRequest (System.Uri address) [0x00000] in <filename unknown>:0
at System.Net.WebClient.SetupRequest (System.Uri uri) [0x00000] in <filename unknown>:0
at System.Net.WebClient.DownloadDataCore (System.Uri address, System.Object userToken) [0x00000] in <filename unknown>:0
Rethrow as WebException: An error occurred performing a WebClient request.
at System.Net.WebClient.DownloadDataCore (System.Uri address, System.Object userToken) [0x00000] in <filename unknown>:0
at System.Net.WebClient.DownloadData (System.Uri address) [0x00000] in <filename unknown>:0
at System.Net.WebClient.DownloadData (System.String address) [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.Net.WebClient:DownloadData (string)
at IntravisionHelper.getIpAndPort () [0x00000] in <filename unknown>:0
at IntravisionHelper.launch () [0x00000] in <filename unknown>:0
at LaunchScript.Start () [0x00000] in <filename unknown>:0
I have no idea why this error is occurring especially when the application runs fine in the unity editor when running this code and only fails in the standalone players.
When I remove the webclient code and rebuild the standalone players, they run fine and do not crash so there is something about the webclient methods that are causing the standalone players to crash.
Any help and guidance would be appreciated.
Thanks
Answer by LelandGreen · Dec 29, 2018 at 10:17 PM
Possibly something is initialized during design-time &/or you have a config file that you're not copying over?
It's hard to say from only the above stack trace, but an educated guess would be that you're making the GetSection() call on a config that's somehow invalid. Two possibilities may be that the item may not exist in in the config file, or the config file itself is missing. (Both of which I've easily done many times. Ha!)
If this is not it and you want to post some code &/or config file with read/write snippets, someone might see something more definite.