Groups | Blog | Home
all groups > inetserver asp components > november 2003 >

inetserver asp components : no neutral threading in win 2003?


TechChief NO[at]SPAM vinetglobal.com
11/25/2003 6:57:02 AM
Hi All,
I have a COM component written in C++ which is inteneded
to be stored in the Application object.
This means of course that I had to write it as
threadingModel = Neutral.
Alas in Win 2003 server this somehow doesn't work and I
get the following annoying error message:
Application object, ASP 0197 (0x80004005)

Cannot add object with apartment model behavior to the
application intrinsic object.

Of course the object is registered as neutral and not
apartment. It works fine in win 2000 server too.

Just to be sure I compiled an empty COM object straight
out of the wizard with the only change being that I
defined ThreadingModel = "Neutral" in my RGS, and sure
enough win2003 will not put it in the Application object.

So what's going on?
Egbert Nierop (MVP for IIS)
11/25/2003 9:57:31 PM
"TechChief@vinetglobal.com" <anonymous@discussions.microsoft.com> wrote in
message news:12cf01c3b364$62525410$a101280a@phx.gbl...
[quoted text, click to view]

Hi,

What does your stdafx.h look like? Mines look like this... note the
_ATL_FREE_THREADED macro that is needed to get 'no thread-affinity' support.

// Modify the following defines if you have to target a platform prior to
the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different
platforms.

#define WINVER 0x0500 // Change this to the appropriate value to target
Windows 98 and Windows 2000 or later.
#define _WIN32_WINNT 0x0500 // Change this to the appropriate value to
target Windows 2000 or later.
#define _WIN32_WINDOWS 0x0490 // Change this to the appropriate value to
target Windows Me or later.
#define _WIN32_IE 0x0501 // Change this to the appropriate value to target
IE 5.0 or later.


#define WIN32_MEAN_AND_LEAN
#define VC_EXTRALEAN
#define _ATL_FREE_THREADED
#define _ATL_NO_AUTOMATIC_NAMESPACE
// turn on to get full tracing in the Debug window
//#define _ATL_DEBUG_INTERFACES
//#define _ATL_DEBUG_QI

#include <atlbase.h>
#include <atlcom.h>
#include <windows.h>

using namespace ATL;



the class header looks like this
// CVariantDictionary
[
coclass,
noncreatable,
threading("Neutral"), // changed for your sample...
aggregatable("never"),
vi_progid("NWCTools.VariantDictionary"),
progid("NWCTools.VariantDictionary.1"),
version(1.1),
uuid("94764678-7F98-4CD8-88E9-FA83D776135C"),
helpstring("dictionary which stores key/value pairs. Also persists its data
easily")
]
....

etc
[quoted text, click to view]
anonymous NO[at]SPAM discussions.microsoft.com
11/26/2003 4:16:49 AM
Thanks Egbert,

But As before I have tried creating an empty COM object
straight out of the wizard, and made sure all headers are
as you suggested (exept the noncreatable - why would you
need that in a variable dictionary - BTW that's exactly
what I'm trying to create), but the win server 2003 still
keeps on claiming its an apartment model.

Could it be something in the server setting like a new
security setting required?

Can you suggest a way for me to check if it is a server
configuration issue or I'm doing something wrong in my COM.


Thanks Again.



[quoted text, click to view]
TechChief NO[at]SPAM vinetglobal.com
11/26/2003 8:23:49 AM
I'm afraid I did all that:
removed the _ATL_APARTMENT_THREADED
added _ATL_FREE_THREADED
and used the ATL wizard
I also tried originaly on my VC6.0, but after that I tried
on the my .NET 2003 IDE ver 7.1.
Of course I usually compile on my 2000 machine and then
take the DLL to the 2003 server.
I also made sure I'm working with SDK includes from about
a months ago.

[quoted text, click to view]
Egbert Nierop (MVP for IIS)
11/26/2003 3:14:29 PM
[quoted text, click to view]

There you go, the wizard is not smart enough to fix stdafx.h
Just again to be explicit, did you append the _ATL_FREE_THREADED macro and
did you remove the _ATL_APARTMENT_THREADED macro?

did you use the ATL wizard or the C++ wizard? The C++ wizard does not create
free threaded components, it is possible, but the C++ runtime needs thread
affinity for COM components...

Which C++ IDE version did you use?

[quoted text, click to view]

Right, ignore the noncreatable attribute

[quoted text, click to view]

It's your COM sourcecode.

[quoted text, click to view]
AddThis Social Bookmark Button