-2

I am currently working on a big asp.net page, created by a lot of other developers, used by a lot of people internally. I got a rather simple task to modify the page, for that I had to create a class and added the DLL to the bin folder.

VoiceChecker vr = new VoiceChecker();

throws the following exception:

Asynchronous operations are not allowed in this context. Page starting an asynchronous operation has to have the Async attribute set to true and an asynchronous operation can only be started on a page prior to PreRenderComplete event.

Why is this an asynchronous operation? I don't want it to be asynchronous, I actually want the page to wait for that operation to finish. I've tried to set the @Page to Async=true, but for some reason it just blocks the page endlessly, even though my code should be done in <1s.

How can I make my class synchronous?

Core_F
  • 3,372
  • 3
  • 30
  • 53
  • 2
    Are you sure that's the line that's causing the error? Can you post the code for that class? – woz Dec 11 '13 at 15:58
  • @woz Yes, I've debugged it line by line. Your comment actually already helped me. The constructor of the class had some unused code (init of some voice recognition). It worked after I removed it. – Core_F Dec 11 '13 at 16:03
  • So problem solved? I'll post an answer. – woz Dec 11 '13 at 16:09
  • Have you read thru this? http://stackoverflow.com/questions/672237/running-an-asynchronous-operation-triggered-by-an-asp-net-web-page-request – Allan Elder Dec 11 '13 at 16:14

1 Answers1

0

Declaring a new object will not trigger this error unless the constructor contains asynchronous code.

woz
  • 10,888
  • 3
  • 34
  • 64