I have a .NET 2.0 application with nothing fancy in it. It worked until yesterday on every PC I installed or copied it to, no matter if 2.0, 3.0, 3.5 or 3.5 SP1 was installed, no matter if it was Win2000, XP or even Win7 (in total 100+ machines).
Yesterday I did my normal installation procedure and wanted to start it one time to check if everything is working...and it wasn't. The program crashed hard leaving me with the uninformative "Do you wanna report this error?" dialog. The problem is an exception in the Main(String[] args)
routine of my application.
The event viewer is showing the following entry:
Event Type: ErrorEvent
Source: .NET Runtime 2.0 Error Reporting
Event Category: None
Event ID: 5000
Date: 05/05/2010
Time: 16:09:09
User: N/A
Computer: myClientPC
Description:
EventType clr20r3, P1 apomenu.exe, P2 1.4.90.53, P3 4bdedea4,
P4 system.configuration, P5 2.0.0.0, P6 4889de74, P7 1a6, P8 136,
P9 ioibmurhynrxkw0zxkyrvfn0boyyufow, P10 NIL.
Well...great information. After a lot of searching I finally was able to get further information about this exception (by adding a handler for UnhandledExceptions
directly in My.MyApplication.New(), Application.开发者_StackOverflow社区Designer.vb
):
System.Configuration.ConfigurationErrorsException
Configuration system failed to initialize
at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
at System.Configuration.ClientConfigurationSystem.PrepareClientConfigSystem(String sectionName)
at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at System.Configuration.PrivilegedConfigurationManager.GetSection(String sectionName)
at System.Net.Configuration.SettingsSectionInternal.get_Section()
at System.Net.Sockets.Socket.InitializeSockets()
at System.Net.Sockets.Socket.get_SupportsIPv4()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.get_HostName()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.RegisterChannel(Boolean SecureChannel)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at MyAppNameHere.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:Line 81.
And at this point I'm stuck...I'm out of ideas. I'm not using any kind of configuration system from the framework (no reference to System.Configuration, and there never was a MyAppnameHere.exe.config generated or distributed, nor have I seen this error before). I also found a bug report at Microsoft (Google Cache) about this bug (in another context, though). But as it seems, they won't even look at it.
Every help is greatly appreciated!
Edit: I'm using Visual Studio 2008 Prof.. Crash happens in Release- and Debug-Build on the client machine. Debugging the application directly on this machine is out of question I fear, 300+ Miles and they only have two computers to work with.
Edit2: Other .NET applications are working fine.
Edit3: After Andrey pointed it out, I also had a look at the Inner-Exception (I always forget that this thing exists):
System.Configuration.ConfigurationErrorsException
Unknown configraution directive "system.serviceModel". (c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\machine.config line 145)
at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)
at System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()
at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
I removed this section and everything is now working es expected...but now one question is haunting me: Why did other applications work?
On A windows 2008 R2 machine we had similar symptoms. We discvoered that installing .NET framework 3.5.1 from features resolved our issue. This was the difference between two machines where one was working the other (missing 3.5.1) was not.
That error indicates there is something wrong with a .config file. This could be the application's config file, or maybe machine.config.
I'd suggest uninstalling/reinstalling .net on that machine.
Another thing to try is to see if the user can run your app as elevated (run as administrator). The config system may be trying to access a file that the user doesn't have rights to. If they can run as admin, figure out what files are accessed by the config system and then instruct the user to allow their account rights to those files.
Judging by the call stack, it looks as if the channel is incorrectly configured due to an obscure reason, when you look at it at another way, perhaps there was a change in the network somewhere without your knowledge - after all you did say it worked, I just cannot help thinking that the system wide config file (machine.config) has an incorrect setting perhaps due to permissions?
The system wide configuration is found in the windows folder deep within the .NET folder...I guess the runtime did not start properly...have you tried restarting the .NET runtime optimization service?
It looks as if you're application is trying to set-up a socket, perhaps the client PC has a firewall that is blocking the socket or maybe the code is being prevented from running due to some security software. Have you tried running your code as administrator and with all security software disabled?
Did you attempt to delete the file "...\Documents and Settings\<user>\Local Settings\Application Data\<application_name>...\user.config" as detailed in http://support.microsoft.com/kb/956762/en-gb? The path may be different on later Windows versions.
I would guess that the machine has a bad install of the framework.
Try uninstalling, then reinstalling .Net.
I was getting this error when i deployed my app to the production server, on my local develop machine produces no error. So i relized the cause: My server has an x64 OS, my app was compiled with the default x86 platform, changed to 'Any CPU' option, and no more errors!!!
精彩评论