Re: COM DLL works fine in C# but not when using Remoting

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: SARA (SARA_at_discussions.microsoft.com)
Date: 08/10/04


Date: Tue, 10 Aug 2004 09:55:05 -0700

Client Code
========
public class RemoteClient
        {
                public static int Main(string [] args)
                {
                        TcpChannel chan = new TcpChannel();
                        //HttpChannel chan = new HttpChannel();
                        ChannelServices.RegisterChannel(chan);
                        CTIOSRemote obj = (CTIOSRemote)Activator.GetObject(
                                typeof(TestRemote),
                                "tcp://localhost:9999/Test");
                        if (obj == null)
                                System.Console.WriteLine("Could not locate server");
                        else
                                obj.connect();
                        return 0;
                }
        }

Server Code
========
public class RemoteServer
        {
                public static int Main(string [] args)
                {
                        TcpChannel chan = new TcpChannel(9999);
                        //HttpChannel chan = new HttpChannel(9999);
                        ChannelServices.RegisterChannel(chan);
                        RemotingConfiguration.RegisterWellKnownServiceType(
                                typeof(TestRemote),
                                "Test", WellKnownObjectMode.SingleCall);
                        System.Console.WriteLine("Hit to exit...");
                        System.Console.ReadLine();
                        return 0;
                }
        }

"Sam Santiago" wrote:

> I thought you were hosting your remote server in IIS for some reason. You
> might want to post some stub code here to see then. Most of the references
> to that error number seem to be security related though in MS KB or Google
> newsgroup search. As a test you might want to set a given Identity for you
> COM+ application to run under as a test so that you can rule out the passing
> of security credentials as a cause. To do this, in Component Services, look
> at your COM+ application properties and set the Identity to a specific user.
> Security might not be involved at all, but it's worth ruling out.
>
> Thanks,
>
> Sam
>
> --
> _______________________________
> Sam Santiago
> ssantiago@n0spam-SoftiTechture.com
> http://www.SoftiTechture.com
> _______________________________
> "SARA" <SARA@discussions.microsoft.com> wrote in message
> news:13C43879-FFA9-4EB4-9F3C-DA82A0A59EA3@microsoft.com...
> > I am not using ASP.NET or XML Web Services at this time. I have a regular
> C#
> > client trying to call the function on the remote object. My client, MBR
> > Class and server are on the same machine in the same folder. Everything
> > works fine when I call other functions on my ISession object that return
> > strings.
> >
> > "Sam Santiago" wrote:
> >
> > > Sounds like a security problem. The user your request ends up running
> as
> > > does not have rights to instantiate a COM object. Check out this link:
> > >
> > > Implementing Impersonation in ASP.NET
> > > http://support.microsoft.com/default.aspx?scid=kb;EN-US;306158
> > >
> > > And this posting to the newsgroup from last year:
> > >
> http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&selm=e28I%23B3pDHA.708%40TK2MSFTNGP10.phx.gbl
> > >
> > > Thanks,
> > >
> > > Sam
> > >
> > > --
> > > _______________________________
> > > Sam Santiago
> > > ssantiago@n0spam-SoftiTechture.com
> > > http://www.SoftiTechture.com
> > > _______________________________
> > > "SARA" <SARA@discussions.microsoft.com> wrote in message
> > > news:45EA1241-5983-4DFB-800E-4AD85B67F92B@microsoft.com...
> > > > Thanks for the quick response.
> > > >
> > > > That is how I had it set up. I had the Session objectt declared as
> > > private.
> > > > I had a public function called connect(). Inside the connect()
> function
> > > I
> > > > was calling Session.Connect(Arg). Should the Arg object also be a
> private
> > > > member? Currently, I am creating a local object and passing it to the
> > > > Session.Connect(Arg) function.
> > > >
> > > > Here's the exact exception I am getting:
> > > >
> > > > Unhandled Exception: System.Runtime.InteropServices.COMException
> > > > (0x80010105): The server threw an exception.
> > > >
> > > > Server stack trace:
> > > > at TestClientLib.ISession.Connect(Arg pConnectParam)
> > > > at TestNameSpace.TestRemote.connect() in
> > > > c:\MyWebServices\Test.NET\TestRemote.cs:line 68
> > > > 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 TestNameSpace.TestRemote.connect() in
> > > > c:\MyWebServices\Test.NET\TestRemote.cs:line 48
> > > > at TestNameSpace.RemoteClient.Main(String[] args) in
> > > > c:\MyWebServices\Test.NET\RemoteClient.cs:line 22
> > > >
> > > > "Sunny" wrote:
> > > >
> > > > > In article <F5C59F91-4C09-49A8-8FDF-7A64CA6FABE4@microsoft.com>,
> > > > > SARA@discussions.microsoft.com says...
> > > > > > Greetings All:
> > > > > >
> > > > > > I have a COM DLL that works perfectly fine in a C# program.
> However,
> > > if I
> > > > > > move the same code to a class that inherits from MarshalRefObj I
> get
> > > an
> > > > > > exception and I can not call the same function that I call
> correctly
> > > if I do
> > > > > > not use Remoting. The function in question is called Connect(Arg)
> in
> > > a class
> > > > > > called Session. I can call other functions in the Session class
> and
> > > teh Arg
> > > > > > class that return string args. However, the Connect(Arg) function
> > > fails and
> > > > > > throws System.Runtime.InteropServices.COMException.
> > > > > >
> > > > > > I am new to the .NET technology and I have tried searching the
> > > newsgroups
> > > > > > for this but have not found anything.
> > > > > >
> > > > > > I was curious to know what I am doing wrong.
> > > > > >
> > > > > > SARA
> > > > > >
> > > > > >
> > > > >
> > > > > Hi Sara,
> > > > >
> > > > > create the COM object as private in your MBR class. Then expose to
> the
> > > > > clients a wrapper methods, which in turn will call the COM object's
> > > > > methods.
> > > > >
> > > > > Sunny
> > > > >
> > >
> > >
> > >
>
>
>



Relevant Pages

  • Remoting IPCChannel security with Service
    ... I have a simple remoting sample using IPCChannel. ... If I run the server code ... as a console app my client can connect just fine. ... I'm very weak on security, My service runs under Local System and can ...
    (microsoft.public.dotnet.security)
  • Re: using Socket calls in OSdesign subproject
    ... the problem is my windows CE 6.0 Server code that i have shared is ... If it runs on winCE 6.0, ... accept and doesn't accept any client sockets. ... It comes to the level of accpeting socket and blocks there. ...
    (microsoft.public.windowsce.app.development)
  • Re: datagrid and checkbox and confirm dialog
    ... checkbox and this checkbox should relate to the field Bore_Id. ... server code to display a message to the client prior to it executing. ... trigger the server code (function DeleteBoreID). ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Law of Demeter can be supported without eliminating object coupling
    ... class....LoD is a law that applies to client classes. ... DriversLicense object inside it. ... have perfectly valid reasons to provide its wallet to some clients, ... assumption to assume that the the server code is not closed in this ...
    (comp.object)
  • Re: Distributed Programming
    ... Client gets a dataset, say a customer table ... The server code detects that a record has been deleted via rowstate, ... table via setting autoincrement to true and setting the seed to the ...
    (microsoft.public.dotnet.languages.vb)