Yep, you do get that.
You need to aggregate the com free threaded marshaller to get around this
issue - the following code does this. You might want to read up on MSDN what
this is all about also.

procedure TMyComObject.AfterConstruction;
begin
  inherited;
  OleCheck( CoCreateFreeThreadedMarshaler( Self,  FFreeThreadedMarshaler ));
end;

function TMyComObject.ObjQueryInterface(const IID: TGUID; out Obj): HResult;
begin
  if GetInterface(IID, Obj) then Result := S_OK
  else Result := FFreeThreadedMarshaler.QueryInterface( IID, Obj );
end;

> -----Original Message-----
> From: Neil Anderson [SMTP:[EMAIL PROTECTED]]
> Sent: Tuesday, June 06, 2000 12:45 PM
> To:   Multiple recipients of list delphi
> Subject:      [DUG]:  Saving COM in Application Object
> 
> I have been experimenting with saving a both threaded com object in the
> Application object.
> ( Want to have a common pool of connections (not DB))
> 
> However I get the following error even though the object has been set to
> use
> the both threading model.
> 
> I get this error on a win98 personal web server and a NT4 based IIS4
> system.
> 
> Neil (Confused)
> 
> ASP Error Message
> -----------------
> 
> Application object error 'ASP 0197 : 80004005' 
> 
> Disallowed object use 
> 
> /Pool/AppPoolCreate.asp, line 6 
> 
> Cannot add object with apartment model behavior to the application
> intrinsic
> object. 
> 
> 
> My unit
> -------
> unit impTBoth;
> 
> interface
> 
> uses
>   ComObj, ActiveX, TestBoth_TLB, StdVcl;
> 
> type
>   TTIBoth = class(TAutoObject, ITIBoth)
>   private
>     FTime : string;
>   protected
>     function Get_TTime: WideString; safecall;
>     procedure Set_TTime(const Value: WideString); safecall;
>     procedure SetTime; safecall;
>     { Protected declarations }
>   end;
> 
> implementation
> 
> uses ComServ, SysUtils;
> 
> function TTIBoth.Get_TTime: WideString;
> begin
>   Get_TTime := FTime;
> end;
> 
> procedure TTIBoth.Set_TTime(const Value: WideString);
> begin
>   FTime := Value;
> end;
> 
> procedure TTIBoth.SetTime;
> begin
>     FTime := DateTimeToStr(Now);
> end;
> 
> initialization
>   TAutoObjectFactory.Create(ComServer, TTIBoth, Class_TIBoth,
>     ciMultiInstance, tmBoth);
> 
> end.
> --------------------------------------------------------------------------
> -
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to