What are the challenges you face when working across database platforms? Take the survey

Startup Error : System.TypeInitializationException

pshahpshah Posts: 3
edited January 23, 2012 11:32AM in SQL Prompt Previous Versions
I had upgraded to SQL Prompt 5.1 and worked ok, until I installed VS 2010 (which also installed SQL 2008). I am trying to open my SQL 2005 management studio and receiving an exception that prevents SQL Prompt add-in to be loaded. Please help!

On starting SQL 2005 studio I see : addin 5.1 failed to load.
Error number : 80131604

The exception in log file :
17 Jun 2011 13:49:00,071 [1] INFO RedGate.SqlPrompt.Engine.LogService - Starting new SQL Prompt editor session
17 Jun 2011 13:49:00,326 [1] ERROR RedGate.SqlPrompt.Engine.Options.OptionsBase - Error deserializing options for RedGate.SQLPrompt.CommonUI.Options.UIOptions. Resetting to defaults.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'RedGate.SQLPrompt.CommonUI.Options.SqlPromptApplication' threw an exception. ---> System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.Configuration.ConfigurationErrorsException: Unrecognized configuration section system.serviceModel. (C:\Windows\Microsoft.NET\Framework\v2.0.50727\Config\machine.config line 137)
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)
--- End of inner exception stack trace ---
at System.Configuration.ConfigurationManager.PrepareConfigSystem()
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.IPAddress.InternalParse(String ipString, Boolean tryParse)
at System.Net.NetworkInformation.IpAddrString.ToIPAddressCollection()
at System.Net.NetworkInformation.SystemIPGlobalProperties.GetFixedInfo()
at System.Net.NetworkInformation.SystemNetworkInterface.PostWin2KGetNetworkInterfaces(AddressFamily family)
at System.Net.NetworkInformation.SystemNetworkInterface.GetNetworkInterfaces(AddressFamily family)
at System.Net.NetworkInformation.SystemNetworkInterface.InternalGetIsNetworkAvailable()
at System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()
at W.c()
at W.b()
at RedGate.Licensing.Client.Licence.a(String , Int32 , String , Int32 , Int32 , String , Int32 )
at RedGate.Licensing.Client.Licence.GetLicence(Int32 productCode, String productName, Int32 majorVersion, Int32 minorVersion, String location)
at RedGate.SQLPrompt.CommonUI.Options.SqlPromptApplication.?()
at RedGate.SQLPrompt.CommonUI.Options.SqlPromptApplication..cctor()
--- End of inner exception stack trace ---
at RedGate.SQLPrompt.CommonUI.Options.SqlPromptApplication.add_LicenseChanged(EventHandler value)
at RedGate.SQLPrompt.CommonUI.Options.UIOptions..ctor()
at OptionsClassd06a65c0195a4dbfbf64473d1a83c6b1..ctor()
--- End of inner exception stack trace ---
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)
at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at RedGate.Shared.Utils.IO.Serialization.XMLSerializeFormatter.a(XmlReader , String , String )
at RedGate.Shared.Utils.IO.Serialization.XMLSerializeFormatter.DeserializeRootObject(TextReader reader, String name, String typeName)
at RedGate.SqlPrompt.Engine.Options.OptionsBase.?(Type optionsType, TextReader reader)
at RedGate.SqlPrompt.Engine.Options.OptionsBase.?(Type optionsType)
at RedGate.SqlPrompt.Engine.Options.OptionsBase.LoadOptions[T]()


  • Options
    According to the reply to a similar problem posted in the MSDN forums, this can be caused by uninstalling previous versions of Microsoft Visual Studio - apparently it corrupts the .NET framework v2 machine.config file. The original response is at the bottom of the thread here, but to make life easier for you I'll reproduce it:
    ...If you open up your machine.config file (in %windir%\Microsoft.NET\Framework\v2.0.50727\CONFIG – and in both Framework and Framework64 if you have a 64-bit machine), you’ll probably see an element that looks like this:
    If you do see exactly that (probably at the end of the file), then I think we have figured out your problem.
    What you need to do is remove this element. So first back-up the machine.config file (save a copy of it to your Desktop or wherever) and then using Notepad, delete that entire <system.serviceModel> element, up to and including </system.serviceModel>. Then save machine.config...
    Once you've updated machine.config, you'll definitely need to restart SSMS to see whether that fixes the problem. You may need to restart your machine to persuade the .NET framework to reload the machine.config, although that probably won't be necessary.

    Please let us know whether this fixes your problem or not. If it doesn't, we can try to investigate further.

    Kind Regards,
    Mike Upton
    Development Lead
    Redgate Software
  • Options
    It did work fine by updating machine.config as specified above. Thanks!
  • Options
    I'm getting the same error message, "Configuration system failed to initialize", but I do not have the XML content quoted below in my machine.config file (the node contains information).

    I just installed SmartAssembly trial version and built my first obfuscated project. The obfuscated version throws this error at startup (but the unobfuscated version is working normally). After the error, the application mostly works, although a web browser control on the main form does not. Interestingly, a web browser control on a modal dialog displayed later does work.

    When I close the application it tries to report the error and fails with a red X next to the message, "Connecting to server. (ERR 2001: Configuration system failed to initialize)

    I was able to save the error log to a file and view it that way. The top line of the Stack Trace says:
    Unrecognized configuration section userSettings.
    (C:\Users\ianc\AppData\Local\icVisions_Corporation\Soteria.exe_<bunch of characters>\user.config line 3)
  • Options
    I narrowed the problem down to the strong key certificate. I could toggle the issue on and off by toggling the option to sign the assembly. Then, much to my surprise, I picked a different pfx file and the issue went away.

    I purchased a code signing certificate from Verisign and am awaiting delivery. Is the code signing certificate in any way related to strong key signing? I noticed that one of the settings in SmartAssembly said that I can not process my assembly with another tool or it would quit working. Is that something I have to turn off in order to use a code signing certificate? Are there any good help topics on code signing? I didn't see any when I searched.
  • Options
    Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    There is an option in SA that says "I want to sign my assembly with a strong-naming key". Effectively SA completely rebuilds the assembly, so it is capable of signing it. You would normally not do any post-processing to sign an assembly as it's done by the linker.
Sign In or Register to comment.