FileNotFound exception when remoting

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Roman Muntyanu

    #1

    FileNotFound exception when remoting

    Hi All,

    I got exception when call Activator.GetOb ject( ... )

    When I start my application I register Channel to communicate between
    two computers and register type ReceiverLocator for remoting in
    Bind()
    Then when I need to get reference to this object on remote computer I
    call Lookup and get proxy from remote computer.
    Lookup() works fine when I start MyApplication.e xe from current
    folder where MyApplication.e xe exists.
    But when I start MyApplication from another folder using path to it
    (so there is no MyApplication.e xe in current folder)
    Activator.GetOb ject() gives me an FileNotFound exception
    "File or assembly name MyApplication, or one of its dependencies, was
    not found". Copying MyApplication.e xe in the folder where I start
    MyApplication.e xe from does not help.

    private bool StartDistribute dObjectRegistry (AInt port)
    {
    ChannelServices .RegisterChanne l( new TcpChannel(nPor t) );
    }

    public void Bind()
    {
    Type t = Type.GetType("C ommunicator.Rec eiverLocator,My Application");
    RemotingConfigu ration.Register WellKnownServic eType(t,
    "ReceiverLocato r",WellKnownObj ectMode.Singlet on);
    }

    public static Object Lookup(String name)
    {
    Object obj = Activator.GetOb ject(typeof(Rec eiverLocator)," tcp:\\RemoteCom puter\ReceiverL ocator");
    return obj;
    }


    Any hints on this issue would be greatly appreciated. Need to fix it
    quickly.

    Thank you in advance
    Roman
  • Dmitry Baibakov

    #2
    Re: FileNotFound exception when remoting

    Roman Muntyanu wrote:
    [color=blue]
    > Hi All,
    >
    > I got exception when call Activator.GetOb ject( ... )
    >
    > When I start my application I register Channel to communicate between
    > two computers and register type ReceiverLocator for remoting in
    > Bind()
    > Then when I need to get reference to this object on remote computer I
    > call Lookup and get proxy from remote computer.
    > Lookup() works fine when I start MyApplication.e xe from current
    > folder where MyApplication.e xe exists.
    > But when I start MyApplication from another folder using path to it
    > (so there is no MyApplication.e xe in current folder)
    > Activator.GetOb ject() gives me an FileNotFound exception
    > "File or assembly name MyApplication, or one of its dependencies, was
    > not found". Copying MyApplication.e xe in the folder where I start
    > MyApplication.e xe from does not help.
    >
    > private bool StartDistribute dObjectRegistry (AInt port)
    > {
    > ChannelServices .RegisterChanne l( new TcpChannel(nPor t) );
    > }
    >
    > public void Bind()
    > {
    > Type t = Type.GetType("C ommunicator.Rec eiverLocator,My Application");
    > RemotingConfigu ration.Register WellKnownServic eType(t,
    > "ReceiverLocato r",WellKnownObj ectMode.Singlet on);
    > }
    >
    > public static Object Lookup(String name)
    > {
    > Object obj = Activator.GetOb ject(typeof(Rec eiverLocator)," tcp:\\RemoteCom puter\ReceiverL ocator");
    > return obj;
    > }
    >
    >
    > Any hints on this issue would be greatly appreciated. Need to fix it
    > quickly.
    >
    > Thank you in advance
    > Roman[/color]

    My thoughts are as follows. What is typeof(Receiver Locator)? More
    precise, what assembly contains the type ReceiverLocator ? I think you
    have some assembly containing the type and just it is not found by CLR.
    MSDN says: "Applicatio n base, which is the root location where the
    application is being executed" Maybe the "base" is assumed as the
    current folder, which is not the one where your MyApplication.e xe is
    located.
    Maybe you should change the current folder to your application's one.
    Check variants of using CMD or link to start it.
    If you know where your application will be deployed, you may use
    privatePath key in web.config

    Dmitry.

    Comment

    • Roman Muntyanu

      #3
      Re: FileNotFound exception when remoting

      Thanks Dmitry for quick response

      Actually ReceiverLocator class is in MyApplication.e xe assembly.
      And I need to start MyApplication from different places:first where it
      is located and second using specific path

      MyApplication is desktop application. And you pointed me to right point.
      I need to use AppendPrivatePa th for the domain. Will try, should work

      Thank you very much
      Roman



      *** Sent via Developersdex http://www.developersdex.com ***
      Don't just participate in USENET...get rewarded for it!

      Comment

      Working...