This message was discovered on microsoft.public.dotnet.framework.remoting.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
| Naeem Hassan Dad (VIP) |
Hello I am really fed up by the following simple problem. I write a interface IPlyer and produce RemotingLibrary.dll. I Implement this Interface using MyRemote class which is also a Remote Object and it produce RemoteServer.dll. I create a virtual directory named Test and copy these dlls in this directory to host remote object on IIS. And An Problem is occur when I execute client application. That is when I used configuration file for configuration. The Exception occur file not found but file is there after exception occur file deleted from its location. Second When i used to configure using RemotingConfiguration.RegisterWellKnownClientType(typeof(IPlayer), "http://localhost:80/Test/MyServer.rem"); It executed this statment but excption of logon failde occur when reomote is called.
Here is the source of this problem including configuration files. All these files in same virtual directory and this virtual directory has no Annonymous Access .Can some one copy these and compile to reproduce the behavior or tell me where I went wrong.
//RemotingLibrary.cs namespace RemotingLibrary { public interface IPlayer { string GetCurrentSong(); } } ------------------------------------------------------------------------------------------ here is Implementation of IPlyer which is also a remote object //RemotingServer.css
namespace RemotingServer { public class MyRemote: MarshalByRefObject, IPlayer { string song;
public MyRemote(string song) { this.song = song; }
public string GetCurrentSong() { return song; } } } --------------------------------------------------------------------------------------------- And Here is the client Application //RemotingClient.cs using System; using System.Runtime.Remoting; using RemotingLibrary;
namespace RemotingClient { class RemoteClient { public static void Main()
{ /*RemotingConfiguration.RegisterWellKnownClientType(typeof(IPlayer), "http://localhost:80/Test/MyServer.rem");*/
RemotingConfiguration.Configure("RemotingClient.exe.config"); IPlayer player = (IPlayer)Activator.GetObject(typeof(IPlayer), "http://localhost:80/Test");
try { string str; Console.WriteLine(player.GetCurrentSong()); } catch(Exception ex) { error = ex.Message; } } } } ---------------------------------------------------------------------------------- //Web.config <configuration> <system.runtime.remoting> <application> <service> <wellknown mode="SingleCall" type="RemotingServer.MyRemote, RemotingServer" objectUri="MyServer.rem" />
</service>
<channels> <channel ref="http"> </channel> </channels> </application> </system.runtime.remoting> </configuration>
--------------------------------------------------------------------------------------------- //RemotingClient.exe.config <configuration> <system.runtime.remoting> <application> <channels> <channel ref="http" useDefaultCredentials="true" port="0"> <clientProviders> <formatter ref="binary" /> </clientProviders> </channel> </channels> <client> <wellknown url="http://localhost:80/Test/Server.rem" type="RemotingServer.MyRemote, RemotingServer" /> </client> </application> </system.runtime.remoting> </configuration>
|
|
| |
| |
| Ken Kolda |
You have several issues you need to resolve, some of which may be just that you didn't correctly copy the code into your post. Your issues are:
1) You're mixing two means of activating your object in your client code. You should either register the well known object (either via the config file or thru code) OR you should use the Activator.GetObject() -- there's no need to do both. So, to use the activator (which is my preference), change the code to:
IPlayer player = (IPlayer)Activator.GetObject(typeof(IPlayer), "http://localhost:80/Test/MyServer.rem");
Note that you have to provide the full URL in the call to GetObject() -- you had omitted the "MyServer.rem".
2) Your MyRemote() object only has a parameterized constructor. In order to be used as a server-activated object, it must have a zero-argument constructor.
3) The DLLs should be in a subdirectory of your web app named "bin".
4) You've specified a binary formatter on the client side but not on the server side.
Ken
"Naeem Hassan Dad" <Naeem Hassan Click here to reveal e-mail address> wrote in message news:Click here to reveal e-mail address... [Original message clipped]
|
|
| |
| | |
|
| |
| Lord2702 |
Fri. Sep. 10, 2004 10:40 AM PT
I also face the same problem, while hosting on IIS. Follow these steps. 1. Create a virtual directory on IIS. In your case I think it is Test. Now physical path may be somewhere on your HD. 2. Create a Bin directory by using your Win Explorer, under this Test. 3. Copy your web.config, which is correct, in this directory, and your MBRO object in Bin dir. 4. Now also create a file, name it MyServer.rem. Because this is the URL that you are using. Type the following line in this file.
<%@ WebService class="MyNamespace.MyClass" %>
MyNamespace.MyClass ===> is your full qualified name of your MBRO. keep this file in your Test directory.
Make sure you provide channels in your web.config.
<channels> <channel ref="http"> <serverProviders> <provider ref="wsdl" /> <formatter ref="soap" typeFilterLevel="Low" /> <formatter ref="binary" typeFilterLevel="Low" /> </serverProviders> </channel> </channels>
This is your IIS settings over. Check your client side, I think this is OK. Try running it should work. In client app, when using Activator.GetObject use the complete path as follows: http://localhost:80/Test/MyServer.rem also don't forget to get the default credentials after Activator.GetObject as follows... IDictionary *props = ChannelServices::GetChannelSinkProperties(<MyObjectProxy>); props->Item[S"credentials"] = System::Net::CredentialCache::DefaultCredentials;
You are all set.
Good Luck.
"Naeem Hassan Dad" <Naeem Hassan Click here to reveal e-mail address> wrote in message news:Click here to reveal e-mail address... [Original message clipped]
|
|
| |
| |
| Naeem Hassan Dad (VIP) |
I follow all above steps but my problem is not related to a web service. Actually this is problem about Remoting. Thanks for your answer. If you again look at my problem. I am fed up. Whenever I try to call RemotingConfiguration.Configure("RemotingClient.exe.config"); It delete the RemotingClient.exe.config file from its path and I have no idea why it is happened.
"Lord2702" wrote:
[Original message clipped]
|
|
| |
|
|
| |
| Momin Khalil |
Hi
Only Client activated objects can have non default constructors. Wellknow SingleCall or Singleton class must have a default constructor (constructor that does not take any parameters). Also make sure that the web.config file is in your virtual root and the dlls are in a sub directory called bin under you root.
Hope this helps
*** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
|
|
| |
|
| | |
|
|
|
|