Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Intraweb - Internal Server Error: Cannot change thread mode after it is set


This question is answered. Helpful answers available: 1. Correct answers available: 1.


Permlink Replies: 11 - Last Post: May 2, 2017 10:35 AM Last Post By: Chad Hower
Joke van den Br...

Posts: 7
Registered: 7/21/08
Intraweb - Internal Server Error: Cannot change thread mode after it is set  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 2, 2016 3:39 AM
We use Intraweb in combination with CGDevtools. In our main web application we frequently get an Internal Server Error.
The error logfile specifies "Cannot change thread mode after it is set".
Has anyone any idea what causes this and how this can be resolved?
Regards, Albert Mulder. Loyaltygroup Netherlands
Daniel Fields

Posts: 622
Registered: 11/29/04
Re: Intraweb - Internal Server Error: Cannot change thread mode after it is set  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 2, 2016 10:38 AM   in response to: Joke van den Br... in response to: Joke van den Br...
Did you set ServerController.ComInitialization to ciMultiThreaded? You have to do that for any project using CGDev.
Joke van den Br...

Posts: 7
Registered: 7/21/08
Re: Intraweb - Internal Server Error: Cannot change thread mode after it is set  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 3, 2016 12:25 AM   in response to: Daniel Fields in response to: Daniel Fields
Daniel Fields wrote:
Did you set ServerController.ComInitialization to ciMultiThreaded? You have to do that for any project using CGDev.

For sure we did, this is the dfm of the ServerController:

object IWServerController: TIWServerController
OldCreateOrder = False
OnCreate = IWServerControllerBaseCreate
AppName = 'MyApp'
ComInitialization = ciMultiThreaded
Compression.Enabled = False
Compression.Level = 6
Description = 'LoyaltyManager 2016'
DebugHTML = True
DisplayName = 'IntraWeb (VCL for the Web) Application'
Port = 8888
RedirectMsgDelay = 0
ServerResizeTimeout = 0
ShowLoadingAnimation = False
SessionTimeout = 10
SSLOptions.NonSSLRequest = nsAccept
SSLOptions.Port = 0
SSLOptions.SSLVersion = SSLv3
SSLOptions.SSLVersions = []
Version = '14.0.50'
AllowMultipleSessionsPerUser = True
ExceptionLogger.ReportInfos = [riAppInfo, riExceptionInfo, riIWAppInfo, riStackTrace]
ExceptionLogger.Enabled = True
CookieOptions.SessionCookies = False
HttpKeepAlive = True
OnBeforeDispatch = IWServerControllerBaseBeforeDispatch
OnCloseSession = IWServerControllerBaseCloseSession
OnNewSession = IWServerControllerBaseNewSession
OnBrowserCheck = IWServerControllerBaseBrowserCheck
Height = 345
Width = 452
end
Eitan Arbel

Posts: 508
Registered: 2/24/13
Re: Intraweb - Internal Server Error: Cannot change thread mode after it is set  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 1, 2017 10:05 AM   in response to: Daniel Fields in response to: Daniel Fields
You have to do that for any project using CGDev.
really?
why?

my project is running for a long time, is big and heavily use CG, and it was set to ciNone (the default i think?).
ciMultiThreaded will make everything (CG) work better?
Chad Hower

Posts: 613
Registered: 3/2/07
Re: Intraweb - Internal Server Error: Cannot change thread mode after it is set  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 1, 2017 10:42 AM   in response to: Eitan Arbel in response to: Eitan Arbel
On 4/1/2017 1:05 PM, Eitan Arbel wrote:
You have to do that for any project using CGDev.
really?
why?

my project is running for a long time, is big and heavily use CG, and it was set to ciNone (the default i think?).
ciMultiThreaded will make everything (CG) work better?

If ciNone works, changing it away will have no beneficial effect
whatsoever and can have some drawbacks.

If something needs a setting other than ciNone, an exception will occur
when it tries do to something COM related.

There is a difference in this setting between ISAPI and SA as well as to
when it is needed.
Alexandre Machado

Posts: 1,754
Registered: 8/10/13
Re: Intraweb - Internal Server Error: Cannot change thread mode after it is set
Helpful
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 7, 2016 12:50 AM   in response to: Joke van den Br... in response to: Joke van den Br...
Joke van den Broek wrote:
We use Intraweb in combination with CGDevtools. In our main web application we frequently get an Internal Server Error.
The error logfile specifies "Cannot change thread mode after it is set".
Has anyone any idea what causes this and how this can be resolved?
Regards, Albert Mulder. Loyaltygroup Netherlands

Hi Albert,

This looks like a COM issue to me, probably a call to CoInitialize after COM initialization can generate that...

A few questions:

1) How do you deploy your application (ISAPI, SA, ASPX?).

2) Which IW version are you using?

3) Do you use any DB access component set (ADO, FireDAC, etc)?

4) Any other COM related stuff that you are aware of?
Joke van den Br...

Posts: 7
Registered: 7/21/08
Re: Intraweb - Internal Server Error: Cannot change thread mode after it is set  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 20, 2016 9:29 PM   in response to: Alexandre Machado in response to: Alexandre Machado
Hi Alexandre,

We did not get the error for about 5 days, but yesterday the "Cannot change thread mode after it is set" error occured in many sessions.
This is our main problem. We migrated our existing online backoffice system to our new Intraweb-CGDevTools application.
So far about ten of our customers are using the new web application, but we have 1.500 companies more to come!
In answer to your questions:
1. ISAPI
2, Version 14.0.63
3. IBX (Interbase)
4. Not really

We want to resolve the problem as soon as possible. Any ideas how you could help us further?

Kind regards, Albert

Alexandre Machado wrote:
Joke van den Broek wrote:
We use Intraweb in combination with CGDevtools. In our main web application we frequently get an Internal Server Error.
The error logfile specifies "Cannot change thread mode after it is set".
Has anyone any idea what causes this and how this can be resolved?
Regards, Albert Mulder. Loyaltygroup Netherlands

Hi Albert,

This looks like a COM issue to me, probably a call to CoInitialize after COM initialization can generate that...

A few questions:

1) How do you deploy your application (ISAPI, SA, ASPX?).


2) Which IW version are you using?

3) Do you use any DB access component set (ADO, FireDAC, etc)?

4) Any other COM related stuff that you are aware of?
Alexandre Machado

Posts: 1,754
Registered: 8/10/13
Re: Intraweb - Internal Server Error: Cannot change thread mode after it is set  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 21, 2016 1:38 AM   in response to: Joke van den Br... in response to: Joke van den Br...
Joke van den Broek wrote:
Hi Alexandre,

We did not get the error for about 5 days, but yesterday the "Cannot change thread mode after it is set" error occured in many sessions.
This is our main problem. We migrated our existing online backoffice system to our new Intraweb-CGDevTools application.
So far about ten of our customers are using the new web application, but we have 1.500 companies more to come!
In answer to your questions:
1. ISAPI
2, Version 14.0.63
3. IBX (Interbase)
4. Not really

We want to resolve the problem as soon as possible. Any ideas how you could help us further?

You should enable IntraWeb exception logger (and also enable full stack traces in your application), and then wait till it happens againg.

http://docs.atozed.com/docs.dll/development/Using%20the%20Exception%20Logger.html

This should give a more detailed information where this error is happening...
Giorgio Calzolato

Posts: 22
Registered: 7/4/02
Re: Intraweb - Internal Server Error: Cannot change thread mode after it is set  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 31, 2017 1:33 PM   in response to: Joke van den Br... in response to: Joke van den Br...
I know this is definitely a late answer, but maybe this can help someone else with my same issue.
I had just solved a similar error messaged for me.
Using ServerController.ExceptionLogger the log messages was:

Exception message  : Impossibile cambiare la modalitĂ  del thread dopo averla impostata
Exception class    : EOleSysError
Exception address  : 0476BE19
Exception Time     : 2017-03-31 22:20:14.866


So I searched for some COM components and eventually I discovered I introduced a TDropFileTarget component in a form in my IW app for testing purposes, interacting with COM framework.
I forgot to delete it after testing in SA mode (this mode doesn't complain at all),
On ISAPI it causes cryptic behavior: on production server, I got internal server error on the first launch, and then it responds fine. But after IIS recycle the internal server error appears again on first call, and then it is ok.
On developing machine IIS, it complains "Cannot change thread mode after it is set"
Chad Hower

Posts: 613
Registered: 3/2/07
Re: Intraweb - Internal Server Error: Cannot change thread mode after it is set [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 31, 2017 3:08 PM   in response to: Giorgio Calzolato in response to: Giorgio Calzolato
On 3/31/2017 4:35 PM, Giorgio Calzolato wrote:
On developing machine IIS, it complains "Cannot change thread mode after it is set"

Its trying to change the com threading model, which isn't allowed after
init.
Gerald Clancy

Posts: 7
Registered: 1/4/02
Re: Intraweb - Internal Server Error: Cannot change thread mode after it is set [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 1, 2017 8:27 PM   in response to: Chad Hower in response to: Chad Hower
Chad Hower wrote:
On 3/31/2017 4:35 PM, Giorgio Calzolato wrote:
On developing machine IIS, it complains "Cannot change thread mode after it is set"

Its trying to change the com threading model, which isn't allowed after
init.

I've been using Omnicon's old server for development for years and today successfully installed Aprelium's Abyss Web Server. All Intraweb ISAPI DLLs I've tried except one runs successfully with it. The exception project, which runs fine on Omni, throws this "Cannot change thread mode" error on Abyss on retry after first returning a 500 error (as someone earlier had noted also). What is different with this project is that it uses the TADOTable MS drivers to convert the tables in an Access .mdb database. It uses these lines for each table:

with ADOTable1 do begin
ConnectionString := 'Provider=Microsoft.ACE.OLEDB.12.0;Data Source=' + DMNJ.sNJDrive + '\dbfs217\DB2016.mdb;Persist Security Info=False';
....

I am pretty sure that this is the culprit. How do I solve it with Abyss?
Chad Hower

Posts: 613
Registered: 3/2/07
Re: Intraweb - Internal Server Error: Cannot change thread mode after it is set [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 2, 2017 10:35 AM   in response to: Gerald Clancy in response to: Gerald Clancy
On 5/1/2017 11:27 PM, Gerald Clancy wrote:
I've been using Omnicon's old server for development for years and
today successfully installed Aprelium's Abyss Web Server. All
Intraweb ISAPI DLLs I've tried except one runs successfully with it.
The exception project, which runs fine on Omni, throws this "Cannot
change thread mode" error on Abyss on retry after first returning a
500 error (as someone earlier had noted also). What is different with
this project is that it uses the TADOTable MS drivers to convert the
tables in an Access .mdb database. It uses these lines for each
table:

with ADOTable1 do begin ConnectionString :=
'Provider=Microsoft.ACE.OLEDB.12.0;Data Source=' + DMNJ.sNJDrive +
'\dbfs217\DB2016.mdb;Persist Security Info=False'; ....

Set the model yourself to match in the ServerController. COMInit is
different when deployed as ISAPI and stricter in its settings.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02