User1015846809 posted
I am working on an old .net application.
Which implemented with .net remoting and hosted in IIS.
URL of .net remote object is like "http://serverName:12345/ClassNameOFRemoteObject.rem"
I am trying to replicate it in my local system for debugging purpose but not succeeded.
Therefore, I have created three projects here
- Interface library (ClassLibrary1)
namespace ClassLibrary1
{ public interface IMyObj
{ string returnSomething();
}
}
- "TestingRemoting" project has remote object which implemented above interface.
namespace TestingRemoting
{ public class myObj : MarshalByRefObject, IMyObj
{ public string returnSomething()
{
RemotingConfiguration.Configure("web.config",false);
return "HI";
}
}
}
- Created virtual directory in IIS10 with name “ACD_BusinessLogic” and pointed to directory “C:\myRemoteObject\bin” where my TestingRemoting.dll and ClassLibrary1.dll resides
- Added web.config file in “C:\myRemoteObject”
<system.runtime.remoting>
<application>
<channels>
<channel ref="http" ></channel>
</channels>
<service>
<wellknown mode="Singleton" type="TestingRemoting.myObj,
TestingRemoting"
objectUri="myObj.rem" />
</service>
</application>
</system.runtime.remoting>
After this if I tried to browse it, the message on the browser“System.Runtime.Remoting.RemotingException: Requested Service not found“ for the URL“http://localhost/ACD_BusinessLogic/myObj.rem”.Even
add web reference couldn't able to resolve.
static void Main(string[] args)
{
String filename =
AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
RemotingConfiguration.Configure(filename,false);
IMyObj mgr = (IMyObj)RemotingHelper.CreateProxy(typeof(IMyObj));
string sd = mgr.returnSomething();
}
RemotingHelper.cs
private static IDictionary _wellKnownTypes;
public static Object CreateProxy(Type type)
{
if (_wellKnownTypes == null) InitTypeCache();
WellKnownClientTypeEntry entr =
(WellKnownClientTypeEntry)_wellKnownTypes[type];
if (entr == null)
{
throw new RemotingException("Type not found!");
}
return Activator.GetObject(entr.ObjectType, entr.ObjectUrl);
}
public static void InitTypeCache()
{
Hashtable types = new Hashtable();
foreach (WellKnownClientTypeEntry entr in
RemotingConfiguration.GetRegisteredWellKnownClientTypes())
{
if (entr.ObjectType == null)
{
throw new RemotingException("A configured type could not " +
"be found. Please check spelling in your configuration file.");
}
types.Add(entr.ObjectType, entr);
}
_wellKnownTypes = types;
}
Client App.config
<system.runtime.remoting>
<application>
<client>
<!-- This entry only works with the RemotingHelper class -->
<wellknown type="ClassLibrary1.IMyObj, ClassLibrary1"
url="http://localhost/ACD_BusinessLogic/myObj.rem" />
</client>
</application>
</system.runtime.remoting>
Then I tried to run client app, I am getting runtime exception “An unhandled exception of type 'System.Runtime.Remoting.RemotingException' occurred in mscorlib.dll. Additional information: System.Runtime.Remoting.RemotingException: Requested
Service not found” at string sd = mgr.returnSomething();
Please help me.