Re: q: QueryInterface failed ?

From: Guy Anthuenis (Guy.Anthuenis_at_pandora.be)
Date: 05/09/03

  • Next message: Mike Mattix: "Re: Windows Authentication & SQL 2000"
    Date: Thu, 08 May 2003 23:20:13 GMT
    
    

    Hi,

    I am experiencing the same problem right now. I have a Serviced Component that is managing my Shared Properties. Initializing and refreshing SPM starting from a Windows Application is not a problem,
    but doing exactly the same from an ASP.NET application causes QueryInterface error messages.

    The problem here is the identity of the caller. There has to happen some impersonation of the client's identity, something that happens inside COM+ itself. ASP.NET doesn't impersonate by default,
    meaning COM+ won't be aware of any identity. You can solve this by adding the line:

    <identity impersonate="true" />

    to the web.config file just as a child of the <system> element. Use Windows Authentication on IIS on your virtual directory, and your problem will be partially solved. Partially, because this works
    fine when running all on the same machine. When a remote client connects to your web app, he will still have this problem.

    I guess that you have to call CoImpersonateClient() in your Serviced Component, but I'm not sure of that yet.

    If you already have found the solution, please post it here, or mail it to me, it would save me time as well.

    This error message you are receiving doesn't mean anything actually. What is happening is some kind of security check. And that is the real problem here. Impersonation solves this problem.

    Guy

    On Thu, 8 May 2003 12:11:47 +0300, "Yury Zenkevich" <yury@altiris.ee> wrote:

    >Hi All !
    >
    >Got some problem, which appears not allways, but sometimes after
    >compilation/reinstall or some other sequence which ruins it all.
    >Here is an idea: I wrote my own COM+ component to have access to some
    >external data from my asp.net application. And here is the problem I've got
    >after trying to get some property from IStream interface:
    >
    >
    > QueryInterface for interface YZComPlusLibrary.IStream failed.
    >[System.InvalidCastException]
    >
    >--------------------------------------------------------------------------
    >
    > Server stack trace:
    > at YZComPlusLibrary.IStream.get_Length()
    > at
    >System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(Met
    >hodBase mb, Object[] args, Object server, Int32 methodPtr, Boolean
    >fExecuteInContext, Object[]& outArgs)
    > at
    >System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessa
    >ge msg, Int32 methodPtr, Boolean fExecuteInContext)
    >
    > Exception rethrown at [0]:
    > at
    >System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
    >reqMsg, IMessage retMsg)
    > at
    >System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
    >msgData, Int32 type)
    > at YZComPlusLibrary.ExternalFile.get_Length()
    > at YZLib.NET.TaskPage.DownloadFile(String sPathName, String
    >sContentType) in c:\inetpub\wwwroot\yzlib.net\task.aspx.cs:line 733
    > at YZLib.NET.TaskPage.doDownload() in
    >c:\inetpub\wwwroot\yzlib.net\task.aspx.cs:line 823
    > at YZLib.NET.TaskPage.Page_Load(Object sender, EventArgs e) in
    >c:\inetpub\wwwroot\yzlib.net\task.aspx.cs:line 141
    >
    >
    >
    >What is wrong here ?! The source code for that object is VERY simple:
    >
    >public interface IStream
    >{
    > long Length { get; }
    >}
    >
    >public class ExternalFile : ServicedComponent, IStream
    >{
    > // some initialization code here
    >...
    > FileInfo oInfo;
    >
    > // implementation of IStream
    > public Length { get { return oInfo.Length; } }
    >}
    >
    >
    >Thank you,
    >
    >Yury.
    >


  • Next message: Mike Mattix: "Re: Windows Authentication & SQL 2000"

    Relevant Pages

    • Interop & role-based security
      ... I've written a serviced component in C# that interacts with some COM ... the standard IConnectionPointContainer interface. ... based security enabled, the calls always fail with E_ACCESSDENIED. ...
      (microsoft.public.dotnet.framework.interop)
    • Re: Creating COM server with C#
      ... What you *can* do is write a "serviced component" (i.e. a COM+ dll that you can host as a COM+ application in "Component Services". ... You just need to decorate the interface and or its methods with following is an example interface. ... Once you have the assembly built you can use the regasm tool to register it. ...
      (microsoft.public.dotnet.languages.csharp)
    • Re: ASP.NET and COM+
      ... You should create a new assembly, which contains the IProvider interface. ... the call to the Serviced Component is remoted, ... This component is registered under COM+ 1.5 as a Server application, it has an strong name, fixed assembly version, fixed applicationid, fixed progid and is installed on the GAC. ...
      (microsoft.public.dotnet.framework.component_services)
    • Serviced Components & Role-Based Security
      ... I've written a serviced component in C# that interacts with some COM ... IConnectionPointContainer interface. ... based security enabled, the calls always fail with E_ACCESSDENIED. ...
      (microsoft.public.dotnet.framework.component_services)