469,609 Members | 2,239 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,609 developers. It's quick & easy.

System.Threading.Timer and Crystal Reports

I've got a background service running that needs to check a database
periodically and print reports whenever it finds that the data has changed.

I've built a class library that scans the database for the changes, and then
generates a report using the VS.NET 2003 version of Crystal Reports, and
prints the report. It works just fine when I use it in a single threaded
environment.

However, when I build an application that uses a System.Threading.Timer
object to run this method on a set schedule, anytime I try to work with the
report objects, the thread just hangs and never comes back

Is there some threading issue in Crystal Reports that anyone knows about, or
better yet, is there some way in C# to get back on the main execution thread
so that I can work with the reports there, avoiding this problem? Remember,
this is all running in a service or a console app, so I don't have a windows
form I can call Invoke or BeginInvoke on.

Thanks!

Ryan Gregg
Nov 16 '05 #1
4 2745
Two things to check:

1. Make sure you have the [STAThread] attribute above your main. Crystal
ultimately calls into COM objects, and they may require single-threaded
apartment model.

2. If you're running as a service when the crashes happen, try allowing the
service to interact with the desktop. (it's possible it needs graphic dc's)

"Ryan Gregg" <rg****@wheatlandsystems.com> wrote in message
news:ez**************@TK2MSFTNGP10.phx.gbl...
I've got a background service running that needs to check a database
periodically and print reports whenever it finds that the data has changed.
I've built a class library that scans the database for the changes, and then generates a report using the VS.NET 2003 version of Crystal Reports, and
prints the report. It works just fine when I use it in a single threaded
environment.

However, when I build an application that uses a System.Threading.Timer
object to run this method on a set schedule, anytime I try to work with the report objects, the thread just hangs and never comes back

Is there some threading issue in Crystal Reports that anyone knows about, or better yet, is there some way in C# to get back on the main execution thread so that I can work with the reports there, avoiding this problem? Remember, this is all running in a service or a console app, so I don't have a windows form I can call Invoke or BeginInvoke on.

Thanks!

Ryan Gregg

Nov 16 '05 #2
Thanks for your reply Philip. However, I've got the STAThread attribute on
my main method. I'm actually running the service right now (in order to
debug it) through a console application. I wrote a class library that does
all the service actions, and then I have two other projects that I can use
to run it, either as a console window or as a Win32 service. It behaves the
same way regardless of how I run it.

I created a 3 test cases using a Console program and different threading
aspects, and it never has any problems there. However, it always dies in my
real application.

Any other ideas?

Thanks again.

Ryan Gregg
"Philip Rieck" <st***@mckraken.com> wrote in message
news:e3**************@TK2MSFTNGP09.phx.gbl...
Two things to check:

1. Make sure you have the [STAThread] attribute above your main. Crystal
ultimately calls into COM objects, and they may require single-threaded
apartment model.

2. If you're running as a service when the crashes happen, try allowing the service to interact with the desktop. (it's possible it needs graphic dc's)
"Ryan Gregg" <rg****@wheatlandsystems.com> wrote in message
news:ez**************@TK2MSFTNGP10.phx.gbl...
I've got a background service running that needs to check a database
periodically and print reports whenever it finds that the data has changed.

I've built a class library that scans the database for the changes, and

then
generates a report using the VS.NET 2003 version of Crystal Reports, and
prints the report. It works just fine when I use it in a single threaded environment.

However, when I build an application that uses a System.Threading.Timer
object to run this method on a set schedule, anytime I try to work with

the
report objects, the thread just hangs and never comes back

Is there some threading issue in Crystal Reports that anyone knows

about, or
better yet, is there some way in C# to get back on the main execution

thread
so that I can work with the reports there, avoiding this problem?

Remember,
this is all running in a service or a console app, so I don't have a

windows
form I can call Invoke or BeginInvoke on.

Thanks!

Ryan Gregg


Nov 16 '05 #3
I wish I had more ideas for you. If you have a simple repro case, feel free
to email it to me and I'll take a look. Otherwise, I'm of no help to you at
the moment -- Crystal is just not my forte. (in fact, I avoid it if I can).
Good luck!
"Ryan Gregg" <rg****@wheatlandsystems.com> wrote in message
news:OZ**************@TK2MSFTNGP12.phx.gbl...
Thanks for your reply Philip. However, I've got the STAThread attribute on my main method. I'm actually running the service right now (in order to
debug it) through a console application. I wrote a class library that does all the service actions, and then I have two other projects that I can use
to run it, either as a console window or as a Win32 service. It behaves the same way regardless of how I run it.

I created a 3 test cases using a Console program and different threading
aspects, and it never has any problems there. However, it always dies in my real application.

Any other ideas?

Thanks again.

Ryan Gregg
"Philip Rieck" <st***@mckraken.com> wrote in message
news:e3**************@TK2MSFTNGP09.phx.gbl...
Two things to check:

1. Make sure you have the [STAThread] attribute above your main. Crystal
ultimately calls into COM objects, and they may require single-threaded
apartment model.

2. If you're running as a service when the crashes happen, try allowing

the
service to interact with the desktop. (it's possible it needs graphic

dc's)

"Ryan Gregg" <rg****@wheatlandsystems.com> wrote in message
news:ez**************@TK2MSFTNGP10.phx.gbl...
I've got a background service running that needs to check a database
periodically and print reports whenever it finds that the data has

changed.

I've built a class library that scans the database for the changes, and
then
generates a report using the VS.NET 2003 version of Crystal Reports,
and prints the report. It works just fine when I use it in a single

threaded environment.

However, when I build an application that uses a System.Threading.Timer object to run this method on a set schedule, anytime I try to work

with the
report objects, the thread just hangs and never comes back

Is there some threading issue in Crystal Reports that anyone knows

about,
or
better yet, is there some way in C# to get back on the main execution

thread
so that I can work with the reports there, avoiding this problem?

Remember,
this is all running in a service or a console app, so I don't have a

windows
form I can call Invoke or BeginInvoke on.

Thanks!

Ryan Gregg



Nov 16 '05 #4
I know what you mean :-) Unforutnately I haven't been able to reproduce the
problem in a simple fashion. In fact, the project I've been working with
appears to work just fine on another development machine I have. I'm now
wondering if it is some sort of side effect of having CrystalReports 8.5
installed.

Thanks again Philip!

Ryan Gregg

"Philip Rieck" <st***@mckraken.com> wrote in message
news:eM**************@TK2MSFTNGP09.phx.gbl...
I wish I had more ideas for you. If you have a simple repro case, feel free to email it to me and I'll take a look. Otherwise, I'm of no help to you at the moment -- Crystal is just not my forte. (in fact, I avoid it if I can). Good luck!
"Ryan Gregg" <rg****@wheatlandsystems.com> wrote in message
news:OZ**************@TK2MSFTNGP12.phx.gbl...
Thanks for your reply Philip. However, I've got the STAThread attribute on
my main method. I'm actually running the service right now (in order to
debug it) through a console application. I wrote a class library that

does
all the service actions, and then I have two other projects that I can use
to run it, either as a console window or as a Win32 service. It behaves

the
same way regardless of how I run it.

I created a 3 test cases using a Console program and different threading
aspects, and it never has any problems there. However, it always dies in my
real application.

Any other ideas?

Thanks again.

Ryan Gregg
"Philip Rieck" <st***@mckraken.com> wrote in message
news:e3**************@TK2MSFTNGP09.phx.gbl...
Two things to check:

1. Make sure you have the [STAThread] attribute above your main.

Crystal ultimately calls into COM objects, and they may require single-threaded apartment model.

2. If you're running as a service when the crashes happen, try allowing the
service to interact with the desktop. (it's possible it needs graphic

dc's)

"Ryan Gregg" <rg****@wheatlandsystems.com> wrote in message
news:ez**************@TK2MSFTNGP10.phx.gbl...
> I've got a background service running that needs to check a database
> periodically and print reports whenever it finds that the data has
changed.
>
> I've built a class library that scans the database for the changes, and then
> generates a report using the VS.NET 2003 version of Crystal Reports, and > prints the report. It works just fine when I use it in a single

threaded
> environment.
>
> However, when I build an application that uses a System.Threading.Timer > object to run this method on a set schedule, anytime I try to work with the
> report objects, the thread just hangs and never comes back
>
> Is there some threading issue in Crystal Reports that anyone knows

about,
or
> better yet, is there some way in C# to get back on the main

execution thread
> so that I can work with the reports there, avoiding this problem?
Remember,
> this is all running in a service or a console app, so I don't have a
windows
> form I can call Invoke or BeginInvoke on.
>
> Thanks!
>
> Ryan Gregg
>
>



Nov 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by K Karthik | last post: by
1 post views Thread by Can Balioglu | last post: by
2 posts views Thread by linesh.gajera | last post: by
4 posts views Thread by Lauren Quantrell | last post: by
4 posts views Thread by =?iso-8859-1?B?S2VyZW0gR/xtcvxrY/w=?= | last post: by
reply views Thread by Solution2021 | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.