Click here to Skip to main content
15,891,136 members
Home / Discussions / C#
   

C#

 
AnswerRe: Saving a reference to an assembly Pin
Rei Miyasaka19-May-06 14:39
Rei Miyasaka19-May-06 14:39 
Questionnoob array question [modifed] Pin
likefood19-May-06 10:45
likefood19-May-06 10:45 
AnswerRe: noob array question Pin
Josh Smith19-May-06 10:49
Josh Smith19-May-06 10:49 
GeneralRe: noob array question Pin
likefood19-May-06 10:50
likefood19-May-06 10:50 
QuestionChecking to see if object is char or int Pin
jrcook19-May-06 9:40
jrcook19-May-06 9:40 
AnswerRe: Checking to see if object is char or int Pin
likefood19-May-06 10:34
likefood19-May-06 10:34 
GeneralRe: Checking to see if object is char or int [modifed] Pin
vineas19-May-06 11:01
vineas19-May-06 11:01 
QuestionWebBrowser throws exception in Web Service Pin
dpietro19-May-06 8:13
dpietro19-May-06 8:13 
The simplest form of the code.
public class Service : System.Web.Services.WebService
{


public Service () {
//Uncomment the following line if using designed components
//InitializeComponent();
}

[WebMethod]
public string HelloWorld() {
return "Hello World";
}


[WebMethod]
public string PrintXML()
{
// Create a WebBrowser instance.
WebBrowser webBrowserForPrinting = new WebBrowser();
return "Success";
}

}

Hello world works ok.
PrintXML fails with an exception of the form:
System.Threading.ThreadStateException: ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment.
at System.Windows.Forms.WebBrowserBase..ctor(String clsidString)
at System.Windows.Forms.WebBrowser..ctor()
at Service.PrintXML()

Can anyone give me hints on what to do with this?
I've tried using attribute [STAThread] to make the method single threaded but it seems to be getting ignored.
I'm at a loss as to how to instantiate a browser control in a web service. I need to do this so I can send HTML to a printer on the same box as the web service that runs.
thanks!

AnswerRe: WebBrowser throws exception in Web Service Pin
Dustin Metzgar19-May-06 10:24
Dustin Metzgar19-May-06 10:24 
GeneralRe: WebBrowser throws exception in Web Service Pin
dpietro22-May-06 1:50
dpietro22-May-06 1:50 
AnswerRe: WebBrowser throws exception in Web Service Pin
Dustin Metzgar22-May-06 1:58
Dustin Metzgar22-May-06 1:58 
Questionbreak report - recommendations?? Pin
MarFarMa19-May-06 7:36
MarFarMa19-May-06 7:36 
AnswerRe: break report - recommendations?? Pin
MarFarMa19-May-06 9:31
MarFarMa19-May-06 9:31 
Questionform/control sizing Pin
reshsilk19-May-06 7:02
reshsilk19-May-06 7:02 
AnswerRe: form/control sizing Pin
leppie19-May-06 7:12
leppie19-May-06 7:12 
QuestionCreating an array from data in a file Pin
jrcook19-May-06 6:53
jrcook19-May-06 6:53 
AnswerRe: Creating an array from data in a file Pin
leppie19-May-06 7:04
leppie19-May-06 7:04 
GeneralRe: Creating an array from data in a file [modifed] Pin
jrcook19-May-06 7:16
jrcook19-May-06 7:16 
AnswerRe: Creating an array from data in a file Pin
Scott Serl19-May-06 11:26
Scott Serl19-May-06 11:26 
QuestionFlickering-free!! Pin
Sirinao19-May-06 6:00
Sirinao19-May-06 6:00 
AnswerRe: Flickering-free!! Pin
leppie19-May-06 7:06
leppie19-May-06 7:06 
AnswerRe: Flickering-free!! Pin
Josh Smith19-May-06 7:13
Josh Smith19-May-06 7:13 
AnswerRe: Flickering-free!! Pin
Sirinao19-May-06 9:08
Sirinao19-May-06 9:08 
QuestionCreating a Vitual Drive Pin
Gonzalo Brusella19-May-06 5:26
Gonzalo Brusella19-May-06 5:26 
AnswerRe: Creating a Vitual Drive Pin
leppie19-May-06 7:14
leppie19-May-06 7:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.