locked
Debugging transparent proxy objects not working anymore in Visual Studio 2015 RRS feed

  • Question

  • Suppose we have an object obtained from System.Runtime.Remoting.Proxies.RealProxy.GetTransparentProxy(). In Visual Studio 2013 and older, it was possible to debug this object in the Watch Window or the Immediate Window (navigate the properties, call methods, etc).

    In Visual Studio 2015, both Watch Window and Immediate Window only show the following error message for the object:

    "Obtaining the runtime type of a transparent proxy is not supported in this context".

    We use transparent proxy objects (for method-intercepting aspect-oriented programming) a lot, and it's a pain that we can't debug these properly anymore. Please help! Thank you.

    Thursday, March 3, 2016 8:19 PM

Answers

All replies

  • Hi mywyb2,

    My understanding is that you debug the same app using difference VS version, am I right?

    (1)One issue is that we have to make sure that whether it has the compatibility issue

    https://msdn.microsoft.com/en-us/library/hh266747.aspx?f=255&MSPPError=-2147217396

    For example, after you open it in your VS2015, clean and rebuild the whole project, do you get any compiled error in the Error list or the output window?We have to make sure that no compiled error.

    (2) Please make sure that it is not the settings issue, for example, compare the settings under TOOLS->Options->Debugging.

    Please use the same .NET Framework version and platform target(x86/x64/ANY CPU) under the project property, clean and build the project, debug it again.

    (3) Please make sure that no Exception in debugging mode.

    https://msdn.microsoft.com/en-us/library/x85tt0dd.aspx

    If still no help, maybe you could share us a simple sample, I will debug it in my side using the same Environment as yours.

    Best Regards,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, March 4, 2016 9:09 AM
  • Dear Jack,

    Thank you for your quick reply. I checked, and there are no compilation errors, no exceptions, and the debugging settings are identical. I am quite sure it's a bug in the VS2015 expression evaluator, because if I enable the option

    Options->Debugging->General->Use the legacy C# and VB expression evaluators, 

    then the error does not occur. Below is a small sample that highlights the error (see the comments in Main()):

    using System;
    using System.Runtime.Remoting.Messaging;
    using System.Runtime.Remoting.Proxies;

    namespace Test
    {
        public class CustomProxy : RealProxy
        {
            public CustomProxy(object subject)
                : base(subject.GetType())
            {
                AttachServer((MarshalByRefObject) subject);
            }

            public override IMessage Invoke(IMessage msg)
            {
                return new ReturnMessage("bla", new object[0], 0, null, (IMethodCallMessage) msg);
            }
        }

        public class Service : MarshalByRefObject
        {
            public string DoNothing(string s)
            {
                return s;
            }
        }

        public static class Program
        {
            public static void Main(string[] args)
            {
                var service = new Service();
                var proxy = (Service) new CustomProxy(service).GetTransparentProxy();
                // Set a breakpoint after this line, and when the point is hit, type 'proxy.DoNothing("hello")' into the watch/immediate window.
                // In VS2015, you'll get an error unless you turn on the option 
                // Options->Debugging->General->Use the legacy C# and VB expression evaluators.
                var x = proxy.DoNothing("hello");
            }
        }
    }

    Wednesday, March 16, 2016 7:57 PM
  • Hi mywyb2,

    Thanks for your friendly response.

    Maybe you could share me the detailed steps about how you really debug this app in your side.

    For example, I test it in my VS2015 Enterprise version with update 1, I add a breakpoint, and then I could add the proxy to the Watch windows without error messages like yours "Obtaining the runtime type of a transparent proxy is not supported in this context" even if I have disabled the option "Options->Debugging->General->Use the legacy C# and VB expression evaluators."

    If I have misunderstood this issue, please feel free to let me know.

    Best Regards,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, March 17, 2016 10:55 AM
  • Dear Jack,

    to reproduce the error, you need to follow the instructions in the comments in the code:

    1. Set the breakpoint *below* the comment, not above.

    2. Type in 'proxy.DoNothing("hello")' into the watch window, not simply "proxy".

    3. Make sure the legacy expression evaluator mode is disabled.

    Thanks,

    Mo

    Monday, March 21, 2016 9:12 AM
  • P.S.: I just noticed I had wrongly configured the email alerts for this thread. I will hopefully receive email notifications now and be able to respond more quickly to your posts.
    • Edited by mywyb2 Monday, March 21, 2016 9:16 AM
    Monday, March 21, 2016 9:16 AM
  • Hi mywyb2,

    I think I could repro this issue in my side.

    Since I could repro this issue, to get the issue confirmed and diagnose by product team, would you please create connect report for it? You will get email notification for update.http://connect.microsoft.com/VisualStudio/feedback/CreateFeedback.aspx

    If you submit it, please share me the link here, I will help you vote it.

    Best Regards,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, March 22, 2016 4:07 AM
  • Tuesday, March 22, 2016 7:07 PM
  • Vote it, Mo:)

    As you already submit one feedback on the Microsoft Connect site, let's focus on the case on that channel, may the senior members can provide more professional support.

    Have a nice day,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, March 23, 2016 9:06 AM
  • Why can't I see this report? 

    I get "The content that you requested cannot be found or you do not have permission to view it. 

    I'm logged in my MS account.

    Thank you

    Friday, April 21, 2017 4:37 PM