473,324 Members | 2,567 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Weird behavior, Program bombs out unless Application.DoEvents() or GC.Collect is called.

I'm creating a .net db provider and I came across a weird problem w/ my data
reader.
The .net provider was created in managed c++ becuase the db api is also c++.
I'm calling the code from a c# project. It shouldn't make a difference but I
did have to do
http://support.microsoft.com/default.aspx?scid=kb;[LN];814472&product=vcNET
to get my c++ project to compile properly. Anyways, as test i did 'select *
from items' using both an ole db dataadapter and my custom db provider, but
targeting the same database. The items table has about 220 fields and 3,222
records. The oledb adapter filled a dataset with no problem. My data adapter
bombed out when retrieving field 10 of record 563.

The problem occurs in my custom data adpater which is used by the customer
data adapter. Everytime MyCustomDataReader.Read() is called, (in this case)
it initializes an Array of type Object with a length of 220. It then does a
foreach and fills in each cell with the data stored in the record.

Now here's where it gets funky. If I call GC.Collect and/or
System.Windows.Forms.Application.DoEvents() w/ each iteration, it will
retrieve all the records w/ no problems. Doing neither causes the
application to exit and no exception is thrown either. The debug output
shows the exit code as 0. Does anyone have any clues as to why?

The fact that it doesn't throw an exeption is what bothers me the most.
Nov 16 '05 #1
3 1844
Other times I've seen the app just terminate without message is when there
was a (complicated) stack overflow in a routine that allocates a lot of
memory on the stack... not sure why exactly, but I guess the CLR doesn't
have enough stack space to even run the code that shows the exception error.

--
John Wood
EMail: first name, dot, second name at priorganize.com
"Hasani" <HJ****@hotmail.c0m> wrote in message
news:kN********************@comcast.com...
I'm creating a .net db provider and I came across a weird problem w/ my data reader.
The .net provider was created in managed c++ becuase the db api is also c++. I'm calling the code from a c# project. It shouldn't make a difference but I did have to do
http://support.microsoft.com/default.aspx?scid=kb;[LN];814472&product=vcNET to get my c++ project to compile properly. Anyways, as test i did 'select * from items' using both an ole db dataadapter and my custom db provider, but targeting the same database. The items table has about 220 fields and 3,222 records. The oledb adapter filled a dataset with no problem. My data adapter bombed out when retrieving field 10 of record 563.

The problem occurs in my custom data adpater which is used by the customer
data adapter. Everytime MyCustomDataReader.Read() is called, (in this case) it initializes an Array of type Object with a length of 220. It then does a foreach and fills in each cell with the data stored in the record.

Now here's where it gets funky. If I call GC.Collect and/or
System.Windows.Forms.Application.DoEvents() w/ each iteration, it will
retrieve all the records w/ no problems. Doing neither causes the
application to exit and no exception is thrown either. The debug output
shows the exit code as 0. Does anyone have any clues as to why?

The fact that it doesn't throw an exeption is what bothers me the most.

Nov 16 '05 #2
I believe this is happening in debug mode only, I made some code changes to
reduce memory usage. I didn't try it in release mode then. But in release
mode, it runs properly. The same problem still occurs in debug mode though,
I'll try to find a larger database table to do further testing.

"Hasani" <HJ****@hotmail.c0m> wrote in message
news:kN********************@comcast.com...
I'm creating a .net db provider and I came across a weird problem w/ my data reader.
The .net provider was created in managed c++ becuase the db api is also c++. I'm calling the code from a c# project. It shouldn't make a difference but I did have to do
http://support.microsoft.com/default.aspx?scid=kb;[LN];814472&product=vcNET to get my c++ project to compile properly. Anyways, as test i did 'select * from items' using both an ole db dataadapter and my custom db provider, but targeting the same database. The items table has about 220 fields and 3,222 records. The oledb adapter filled a dataset with no problem. My data adapter bombed out when retrieving field 10 of record 563.

The problem occurs in my custom data adpater which is used by the customer
data adapter. Everytime MyCustomDataReader.Read() is called, (in this case) it initializes an Array of type Object with a length of 220. It then does a foreach and fills in each cell with the data stored in the record.

Now here's where it gets funky. If I call GC.Collect and/or
System.Windows.Forms.Application.DoEvents() w/ each iteration, it will
retrieve all the records w/ no problems. Doing neither causes the
application to exit and no exception is thrown either. The debug output
shows the exit code as 0. Does anyone have any clues as to why?

The fact that it doesn't throw an exeption is what bothers me the most.

Nov 16 '05 #3
Ok, I think I fixed the problem. It had something to do with the Linker
settings in the c++ project. I get a warning when I compile now, but it
works!
"John Wood" <sp**@isannoying.com> wrote in message
news:eQ**************@TK2MSFTNGP09.phx.gbl...
Other times I've seen the app just terminate without message is when there
was a (complicated) stack overflow in a routine that allocates a lot of
memory on the stack... not sure why exactly, but I guess the CLR doesn't
have enough stack space to even run the code that shows the exception error.
--
John Wood
EMail: first name, dot, second name at priorganize.com
"Hasani" <HJ****@hotmail.c0m> wrote in message
news:kN********************@comcast.com...
I'm creating a .net db provider and I came across a weird problem w/ my data
reader.
The .net provider was created in managed c++ becuase the db api is also

c++.
I'm calling the code from a c# project. It shouldn't make a difference but I
did have to do

http://support.microsoft.com/default.aspx?scid=kb;[LN];814472&product=vcNET to get my c++ project to compile properly. Anyways, as test i did 'select *
from items' using both an ole db dataadapter and my custom db provider, but
targeting the same database. The items table has about 220 fields and

3,222
records. The oledb adapter filled a dataset with no problem. My data

adapter
bombed out when retrieving field 10 of record 563.

The problem occurs in my custom data adpater which is used by the

customer data adapter. Everytime MyCustomDataReader.Read() is called, (in this

case)
it initializes an Array of type Object with a length of 220. It then

does a
foreach and fills in each cell with the data stored in the record.

Now here's where it gets funky. If I call GC.Collect and/or
System.Windows.Forms.Application.DoEvents() w/ each iteration, it will
retrieve all the records w/ no problems. Doing neither causes the
application to exit and no exception is thrown either. The debug output
shows the exit code as 0. Does anyone have any clues as to why?

The fact that it doesn't throw an exeption is what bothers me the most.


Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

24
by: bazad | last post by:
Hi, I'd like to understand consequences of Application.DoEvents call. Does it create a new thread? Thank you
6
by: foldface | last post by:
Hi I am doing drag and drop between controls (listview and treeview) using mouse_event. What I am after is a book/resource to explain the behaviour below. If I do the various Win32 api calls...
6
by: Ollie Riches | last post by:
I understand the use of Application.DoEvents() to process all outstanding messages on the message queue in a winforms application if you have long running process on the UI thread. But can anyone...
8
by: TrtnJohn | last post by:
I have an application where I would like to block waiting on an asynchronous event and still process messages. I can implement a hard loop to block such as: Do While StillWaiting...
13
by: Amjad | last post by:
Hi, Is there an equivalent to the "Application.Doevents" method in modules or Windows services? I want to make a Windows service that calls a DLL. The DLL would have all my functions and it...
2
by: joeforbroke | last post by:
Background: I am helping someone debug a problem with their form that I have traced to a strange interaction between a click event handler and Application.DoEvents(). I'm trying to talk him into...
5
by: james.jdunne | last post by:
System.ArgumentException: Item has already been added. Key in dictionary: "-1" Key being added: "-1" at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add) at...
8
by: Jeremy S. | last post by:
Application.DoEvents(); Why would I ever want to do that? When is it (1) required, or (2) a "good idea" or (3) a "bad idea" Thanks.
0
by: Kristijan Marin | last post by:
Hi, I have experianced same wierd behavior by one of my customers ..... Here is the thing .... We have the application for newspaper article management. so adding end editing etc .... After...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.