System.InvalidOperationException in Output Window

Posts   
 
    
Sam avatar
Sam
User
Posts: 95
Joined: 30-Jun-2004
# Posted on: 10-Feb-2006 22:16:27   

I constantly get the following message in my output/debug windows. The app doesn't crash but I was wondering what the deal with it is:

A first chance exception of type 'System.InvalidOperationException' occurred in System.dll

       using (DataAccessAdapter adapter = new DataAccessAdapter()) //after this line executes
        {
            //Some dataCode
        }

Just wondering if I may be doing something wrong somewhere or something.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39625
Joined: 17-Aug-2003
# Posted on: 10-Feb-2006 22:32:10   

connection string in config not available?

Frans Bouma | Lead developer LLBLGen Pro
Sam avatar
Sam
User
Posts: 95
Joined: 30-Jun-2004
# Posted on: 11-Feb-2006 00:32:06   

it is loading data so...Unless llblgen is clairvoyant (which wouldn't surprise me)simple_smile ...it must be seeing the connection string.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39625
Joined: 17-Aug-2003
# Posted on: 11-Feb-2006 10:30:28   

Ok when do you receive the message, when you start a debug session and you get an exception there? Because if it's a runtime exception, the execution stops, and should give you a stacktrace

Frans Bouma | Lead developer LLBLGen Pro
Sam avatar
Sam
User
Posts: 95
Joined: 30-Jun-2004
# Posted on: 11-Feb-2006 18:54:10   

No the app does not break on the exception. I just see it pass by in the output window (Debug.WriteLine()) type of deal.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39625
Joined: 17-Aug-2003
# Posted on: 11-Feb-2006 19:54:57   

Sam wrote:

No the app does not break on the exception. I just see it pass by in the output window (Debug.WriteLine()) type of deal.

So you debug the app and you see that output? If so, I'll try to reproduce it.

Frans Bouma | Lead developer LLBLGen Pro
Sam avatar
Sam
User
Posts: 95
Joined: 30-Jun-2004
# Posted on: 13-Feb-2006 16:46:30   

Exactly. And it is not just one project. I have seen it will all my Adapter LLBLGen projects.

JimHugh
User
Posts: 191
Joined: 16-Nov-2005
# Posted on: 13-Feb-2006 17:03:43   

This occurs if the following two keys are not present in the App.Config file.

Values don't matter.

Add the two keys to the appSettings section and the problem goes away.

Change the value to 1 and specify a specific catalog if you like.


    <add key="CatalogNameUsageSetting" value="0"/>
    <add key="CatalogNameToUse" value="NorthWind"/>

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39625
Joined: 17-Aug-2003
# Posted on: 13-Feb-2006 17:35:59   

Hmm, that shouldn't be happening, as the code checks if the sections are there or not. Will see what the cause of this is... Thanks Jim simple_smile

Frans Bouma | Lead developer LLBLGen Pro
Sam avatar
Sam
User
Posts: 95
Joined: 30-Jun-2004
# Posted on: 13-Feb-2006 22:06:43   

Thanks Jim that fixed it!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39625
Joined: 17-Aug-2003
# Posted on: 14-Feb-2006 11:47:58   

I can't reproduce it with a normal .config file. Sam, did you by any change have a line like: <section name="sqlServerCatalogNameOverwrites" type="System.Configuration.NameValueSectionHandler" />

in your config file? Because THEN you need to add more lines, though I can't reproduce the exception... (at least not on .NET 1.x)

Frans Bouma | Lead developer LLBLGen Pro
JimHugh
User
Posts: 191
Joined: 16-Nov-2005
# Posted on: 14-Feb-2006 14:06:03   

I can reproduce it at will on 2.0 with 1.2005.1 Feb 9 2006

I do not have the sqlServerCatalogNameOverwrites section.

I initially got into this because of the delay in startup time due to the exception while debugging.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39625
Joined: 17-Aug-2003
# Posted on: 14-Feb-2006 14:19:25   

Thanks, will look into it.

Frans Bouma | Lead developer LLBLGen Pro
Sam avatar
Sam
User
Posts: 95
Joined: 30-Jun-2004
# Posted on: 14-Feb-2006 16:20:51   

I have not modified the connection string but I am using 2.0 as well.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39625
Joined: 17-Aug-2003
# Posted on: 16-Feb-2006 14:14:04   

Ok, the exception is occuring in DataAccessAdapter.ReadHandleCatalogNameSettingFromConfig(). (is in the generated code)

It's occuring when this line is executed:


CatalogNameUsage catalogNameUsageSetting = (CatalogNameUsage)(int)configReader.GetValue("CatalogNameUsageSetting", typeof(int));

there's no way to test if a section is there, you just have to try and if it's not there you'll end up with an exception, which says: "The key 'CatalogNameUsageSetting' does not exist in the appSettings configuration section.". This exception is caught and never propagated upwards, but used as a signal that the setting isn't there and the code therefore reverts to the default.

So that's the reason for this exception. I.o.w.: harmless.

Frans Bouma | Lead developer LLBLGen Pro
DerMohr
User
Posts: 3
Joined: 26-Feb-2006
# Posted on: 03-Mar-2006 17:47:11   

I also get this Exception but I pass a custom connection string to the Adapter so the exception is not necessary because there is no need to look up the config file.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39625
Joined: 17-Aug-2003
# Posted on: 03-Mar-2006 19:49:41   

DerMohr wrote:

I also get this Exception but I pass a custom connection string to the Adapter so the exception is not necessary because there is no need to look up the config file.

The lookup is for the name overwrites, not for the connection string. simple_smile

Frans Bouma | Lead developer LLBLGen Pro
mikeg22
User
Posts: 411
Joined: 30-Jun-2005
# Posted on: 28-Mar-2006 01:32:38   

Do you know how to disable this exception from scrolling in the debug window for VS2005?

Walaa avatar
Walaa
Support Team
Posts: 14954
Joined: 21-Aug-2005
# Posted on: 28-Mar-2006 09:08:37   

Do you know how to disable this exception from scrolling in the debug window for VS2005?

I found the following thread, which might be helpful in this case http://www.codecomments.com/archive370-2005-10-659423.html