FileNotFound exception when remoting

R

Roman Muntyanu

Hi All,

I got exception when call Activator.GetObject( ... )

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.exe from current
folder where MyApplication.exe exists.
But when I start MyApplication from another folder using path to it
(so there is no MyApplication.exe in current folder)
Activator.GetObject() gives me an FileNotFound exception
"File or assembly name MyApplication, or one of its dependencies, was
not found". Copying MyApplication.exe in the folder where I start
MyApplication.exe from does not help.

private bool StartDistributedObjectRegistry(AInt port)
{
ChannelServices.RegisterChannel( new TcpChannel(nPort) );
}

public void Bind()
{
Type t = Type.GetType("Communicator.ReceiverLocator,MyApplication");
RemotingConfiguration.RegisterWellKnownServiceType(t,
"ReceiverLocator",WellKnownObjectMode.Singleton);
}

public static Object Lookup(String name)
{
Object obj = Activator.GetObject(typeof(ReceiverLocator),"tcp:\\RemoteComputer\ReceiverLocator");
return obj;
}


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

Thank you in advance
Roman
 
D

Dmitry Baibakov

Roman said:
Hi All,

I got exception when call Activator.GetObject( ... )

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.exe from current
folder where MyApplication.exe exists.
But when I start MyApplication from another folder using path to it
(so there is no MyApplication.exe in current folder)
Activator.GetObject() gives me an FileNotFound exception
"File or assembly name MyApplication, or one of its dependencies, was
not found". Copying MyApplication.exe in the folder where I start
MyApplication.exe from does not help.

private bool StartDistributedObjectRegistry(AInt port)
{
ChannelServices.RegisterChannel( new TcpChannel(nPort) );
}

public void Bind()
{
Type t = Type.GetType("Communicator.ReceiverLocator,MyApplication");
RemotingConfiguration.RegisterWellKnownServiceType(t,
"ReceiverLocator",WellKnownObjectMode.Singleton);
}

public static Object Lookup(String name)
{
Object obj = Activator.GetObject(typeof(ReceiverLocator),"tcp:\\RemoteComputer\ReceiverLocator");
return obj;
}


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

Thank you in advance
Roman

My thoughts are as follows. What is typeof(ReceiverLocator)? 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: "Application 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.exe 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.
 
R

Roman Muntyanu

Thanks Dmitry for quick response

Actually ReceiverLocator class is in MyApplication.exe 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 AppendPrivatePath for the domain. Will try, should work

Thank you very much
Roman
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top