Hosting .net remoting object in IIS10 on windows10RSS

5 replies

Last post Apr 18, 2018 04:39 PM by krishna Dev

  • Hosting .net remoting object in IIS10 on windows10

    Apr 15, 2018 03:42 AM|krishna Dev|LINK

    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 able to 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";

            }

        }

    }

    1. Created virtual directory in IIS10 with name “ACD_BusinessLogic” and pointed to directory “C:\myRemoteObject\bin” where my TestingRemoting.dll and ClassLibrary1.dll resides
    2. 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 browserSystem.Runtime.Remoting.RemotingException: Requested Service not found“ for the URLhttp://localhost/ACD_BusinessLogic/myObj.rem”.Even add web reference couldn't able to resolve.

    • "Test" Client project

         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.

  • Re: Hosting .net remoting object in IIS10 on windows10

    Apr 15, 2018 12:58 PM|lextm|LINK

    If you review the official sample,

    https://msdn.microsoft.com/en-us/library/c2swb8ah(v=vs.100).aspx

    Then your IIS 10 site should not point to the bin folder, but its parent.

    You probably should get that Microsoft sample working first, before moving to your own project, so as to make sure .NET Remoting does work on IIS 10.

    Lex Li
    IIS Consulting Services at https://support.lextudio.com/services/consulting.html
    ---------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Hosting .net remoting object in IIS10 on windows10

    Apr 16, 2018 08:55 AM|Yuk Ding|LINK

    Hi krishna,

    I just notice that the remoting require to set TypeFilterLevel to full on both server side and client side. Otherwise, it will return the error:

    An unhandled exception of type 'System.Runtime.Remoting.RemotingException' occurred in mscorlib.dll.

    Best Regards,

    Yuk Ding

    Yuk Ding

    MSDN Community Support
    Please remember to "Mark as Answer" the responses that resolved your issue.
  • Re: Hosting .net remoting object in IIS10 on windows10

    Apr 16, 2018 05:47 PM|krishna Dev|LINK

    Hi Yuk,

    I did this,

    <channels>
         <channel ref="http" ></channel>

    <formatter ref="soap" typeFilterLevel=Low />
    </channels>

    but still the same issue.

    Thanks,

    Krishna

  • Re: Hosting .net remoting object in IIS10 on windows10

    Apr 18, 2018 10:41 AM|Yuk Ding|LINK

    Hi krishna,

    I think it is not an IIS configuration issue but a remoting object configuration issue. Maybe you could check if asp.net forum could help you fix this.

    Best Regards,

    Yuk Ding

    Yuk Ding

    MSDN Community Support
    Please remember to "Mark as Answer" the responses that resolved your issue.
  • Re: Hosting .net remoting object in IIS10 on windows10

    Apr 18, 2018 04:39 PM|krishna Dev|LINK

    Thanks Yuk.

    I will do that.