This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I'm getting some weird issues with Lightspeed when i'm deploying it. I was under the impression that i didn't need to install light speed on the server however I'm getting an error that sugests otherwise. System.TypeInitializationException: The type initializer for 'Mindscape.LightSpeed.LightSpeedContext' threw an exception. ---> System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.Configuration.ConfigurationErrorsException: Unrecognized configuration section database. |
|
|
Hi Josh, Could you please paste your config? You do not need to have LightSpeed installed on the server, you just need the Mindscape.LightSpeed.dll (and possibly the Mindscape.LightSpeed.Linq.dll + provider DLL's) in your application bin's directory. It sounds like you have something called "Database" in the LightSpeedContext config section that it's not expecting. John-Daniel Trask |
|
|
aplication config <configuration> ...
other config ... <database key="xxx"> ...
|
|
|
Hi Josh, That database element is unrelated to LightSpeed since we don't use that with our configuration. Could you please ensure it doesn't live inside the <LightSpeedContexts> section? I hope that helps, John-Daniel Trask |
|
|
Hi Daniel, Thanks for your help, I have just confirmed that I’m reading out of my configuration file fine and dandy and I’m planning on injecting the connection string as follows: public class InvokeContext<T> where T : IUnitOfWork, new() … I have the Mindscape.LightSpeed.ddl and Mindscape.LightSpeed.Linq.ddl in the bin directory, a valid connection strings with all the correct DB permissions set up, yet when I try to create the Context I get the above error. I quote a classing developer catch phrase 'it works on my machine' yet when i deploy it to another region it breaks. Thanks for your help, Josh. |
|
|
sorry about the word formatting at the top of that response. |
|
|
Hi Josh, No worries about the formatting - I tidied it up. Your method to get the connection string is what's using your <database> section correct? I'm guessing that you have accidentally structured your config like: <LightSpeedContexts> <Database> </LightSpeedContexts> Because the error you are seeing is saying the Database block is not a valid part of LightSpeedContext - which it isn't. My guess is when you've changed the database block on the other machine you've accidentally placed it in the wrong place? I hope that helps, John-Daniel Trask |
|
|
Yes that is correct we have other appliactions that are connecting to the database through the these configurations files. The use of the LightSpeedContexts tag is not being used anywhere hence we are getting the connection string from the config and passing it directly into the context. It seems odd that this works on one machine and not another,
Can we delve deeper into lightspeed to debug the issue ? |
|
|
Hi Josh, Could you email me your configs (jd@mindscape.co.nz). As I mentioned, Database does not belong in the LightSpeedContext section. It's not an issue with LightSpeed but a malformed config file so if you can send through the config, I will rearrange it so it works for you. I hope that helps, John-Daniel Trask |
|
|
Hi John, I don't think it is the config files at all, I have just hard coded the connection string, light speed should not be using the config files at all and i'm getting the same error. Josh
|
|
|
Are you getting a different error? The original error is simply stating that your configuration is not valid. Could you try commenting out the database section (or removing it)? If the exception your still getting from System.Configuration then it's still a configuration issue. John-Daniel Trask |
|
|
Just to add to JD's comment, the reason a bad config file causes a problem even if you hardcode the config string is that LightSpeed checks the config file to see if it needs to create a default context as part of initialisation. The mere act of looking in the config file triggers System.Configuration.dll to load the entire file, and an unknown or uninterpretable element (in this case, <database>) is enough to break that load. (Yeah, .NET config can be kinda brittle.) |
|
|
Ok i'm about to go through hunderds of lines of config, what exactly denotes bad config?? Syntax or anything else? |
|
|
Hi Josh, You'll find there is a <Database> configuration inside your <LightSpeedContexts> section given what the exception is saying. I'd look to ensure you're not doing that. Alternatively, the offer is still open for you to email me your config and I can tell you exactly where to make the change. I hope that helps, John-Daniel Trask |
|
|
I can't give you my configs, too much of a security risk but thanks for the offer :-) As I said I am not using <LightSpeedContexts> tag at all but i will review the datbase connections. |
|
|
Not a problem Josh. As Ivan rightly points out - it's likely that the LightSpeedContext is causing your config to be loaded but the actual error is that it cannot parse the <database> section properly. You will likely want to check that your handler for that custom section is available and that your config matches the schema it expects. Also ensure you actually have the handler for the database section in your configSections area. Best of luck, John-Daniel Trask |
|
|
This is proving to very painful!! I have removed my base config file and deleted all <database> entries in the config file stil to get the following error:
|
|
|
|
If I put the lightspeed config section in at the top of my config file then is LightSpeed going to read the whole file??
|
|
|
System.Configuration.dll will read the whole file, and pass the lightSpeedContexts section to LightSpeed. The location of the lightSpeedContexts section doesn't matter to LightSpeed. If System.Configuration.dll has a problem anywhere in your config file (which is what the inner exception is telling us), it won't pass the lightSpeedContexts section to LightSpeed, because it will throw an exception instead. So moving the lightSpeedContexts section around won't help. The only ordering issue I can think of is if System.Configuration.dll is sensitive to the ordering of the <include> (which brings in the <database> element) and the <configSections>, but I haven't tested to see whether this really does make a difference. |
|
|
I have found that apparently MindScape dll requires System.Data.SqlServerCe.dll... |
|
|
Hmm, we'll look into that. It shouldn't require the DLL unless of course you are using SQL Server Compact as your engine. Thanks for reporting this. |
|
|
so is that to say the when deploying to windows server 2003 Microsoft SQL Server 2005 Compact Edition is required if VS is not installed. |
|
|
Guys,
I have been on this for 2 days now, very close to giving up and ditching LightSpeed all together,
you have my class here is my config: <?xml version="1.0" encoding="utf-8" ?> |
|
|
To be fair, I'm still fairly sure LightSpeed has nothing to do with the issue - it's simply that LightSpeed is the first thing to load your config to even check if it has something in the application configuration and then causes it to throw the exception you noted earlier: System.TypeInitializationException: The type initializer for 'Mindscape.LightSpeed.LightSpeedContext' threw an exception. ---> System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.Configuration.ConfigurationErrorsException: Unrecognized configuration section include Notice the text in bold - this is the actual exception, the LightSpeed mention is only because it's the first thing to load your config. I could be wrong but I've not seen <include path=""> used before in a config file. It looks as though your application is now blowing up because the .NET framework cannot work out what that include tag is for. Do you have a custom extension to the configuration sections for providing support for an "include" tag? You could drop LightSpeed and your issue would not go away - as soon as you load anything that checks the config you'll see the same exception. I hope that helps, John-Daniel Trask |
|
|
Just too add, my guess is that as soon as you remove <include> you will also get errors on <Application> and <Logging> as they are not standard. Somewhere you need a whole bunch of <configSection> references that tell .NET how to understand your config file. Please check that you do not have a .config file in a parent directory on your system which includes the necessarily configSection loading references. Unfortunately, without seeing your actual config there's not much we can do but feel around in the dark and hope we help you find the answer. John-Daniel Trask |
|
|
You guys are right, Lightspeed is expecting a properly formatted Config file which is not what i was providing, as i'm stuck witht he config files due to legacy systems I got aroud the problem by creating a seperate config file that is empty just for lightspeed. Thanks again for all your help. |
|