[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

ActiveX control cannot be instantiated because the current thread is not in a single-threaded apartment

Posted on 2010-03-25
7
Medium Priority
?
1,962 Views
Last Modified: 2013-11-15
I get the error shown in the title of this question if I try to print a report with parameters.  I can preview the report without a problem.  I have found with searching the web:
You can work around this by creating a thread yourself and specifying the STA apartment state on the thread.
var t = new Thread(MyThreadStartMethod);
t.SetApartmentState(ApartmentState.MTA);
t.Start();
My question is - does this code need to be in Crystal Reports (where)?  Or does this code need to be in the form in the application?  The application uses business objects, methods...
0
Comment
Question by:KEDIS
  • 4
  • 3
7 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 28603841
How are you previewing the report?

WHen do you get the error?

mlmcc
0
 

Author Comment

by:KEDIS
ID: 28626910
I am previewing the report in our ERP system - uses Crystal runtime

The error comes up if I try print instead of preview
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 28811741
Can you print from the preview?

The code you found would go on the form in the code for printing the report.

mlmcc
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 

Author Comment

by:KEDIS
ID: 28903778
Yes, I can print from preview.  Tomorrow, I can try to put the code in the form to print the report...
0
 

Author Comment

by:KEDIS
ID: 29381028
I tried to put the code in teh form for printing, but I get errors about declaration expected...
Usually that is a Dim statement Dim ...As
So I tried, but then did not know what to put after As (tried thread).
The form in the application shows it uses VB.NET code
Or, do you mean I need to put it in the Crystal Report design?
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 1500 total points
ID: 29482723
The code you list would go in the VB application not in the report.

WHere it goes, I dont know.

mlmcc
0
 

Author Closing Comment

by:KEDIS
ID: 31772897
I still don't know where exactly to put the code or how
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1. Set up your parameter at the report level as usual, check the box Multi-value, and set the Data Type to String 2. Set the Stored Procedure Parameter to varchar(max)  --<---- This part here is the key to it's success Example:    @cst_key var…
Hello, In my precious Article  (http://www.experts-exchange.com/Database/Reporting/A_15280-Create-Project-in-Microstrategy-Part-I.html)we saw the Configuration part for Microstrategy which included Metadata Creation and DataSource Preparation as …
Is your organization moving toward a cloud and mobile-first environment? In this transition, your IT department will encounter many challenges, such as navigating how to: Deploy new applications and services to a growing team Accommodate employee…
The video provides a quick and easy steps to migrate MBOX file to well known Outlook PST and Office 365. Besides this, it also supports and migrates more than 20 email clients of MBOX which include AppleMail, Opera, Thunderbird and SeaMonkey effortl…
Suggested Courses

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question