locked
Not Able to Debug the Unit Tests Properly in VS 2013. RRS feed

  • Question

  • Hi,

    We are facing an issue with VS 2013 wherein we are not able to debug the main project from the unit test project in our main solution. We have tried lot of different approaches like cleaning up the solution, restarting the system and changing debug properties, but nothing is helping us.

    The symbols in the main project are not loaded during run time, So finding the exact issue become cumbersome and difficult.

    We are using the following configuration. :-

    Microsoft Visual Studio Premium 2013
    Version 12.0.21005.1 REL
    Microsoft .NET Framework
    Version 4.5.51641

    OS : Window Server 2012 R2

    Please let us know, how to resolve this issue as soon as possible.

    Thanks

    Aditya

    Friday, December 12, 2014 6:23 AM

Answers

  • Hi Aditya,

    Do you get any error/warning messages when you debug your project?

    You could view the Output or Error list windows, if you get any messages, please share me the detailed messages.

    If you could debug it with the WCF project, but not from the unit test project, one possible reason is that the un-sign unit test project doesn't have the enough trust with the strongly-named assemblies, so it couldn't load these assemblies from your unit test project.

    Maybe you could check the following document/thread, maybe it could help you.

    http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute(v=vs.110).aspx

    http://stackoverflow.com/questions/7191373/how-can-i-make-internalsvisibleto-attribute-work-by-signing-a-public-token-key-s

    Based on this document:

    http://msdn.microsoft.com/en-us/library/wd40t7ad(v=vs.110).aspx 

    Strong-named assemblies are useful in the following scenarios:

    • You want to enable your assemblies to be referenced by strong-named assemblies, or you want to give friend access to your assemblies from other strong-named assemblies.

    • An app needs access to different versions of the same assembly. This means  you need different versions of an assembly to load side by side in the same app domain without conflict. For example, if different extensions of an API exist in assemblies that have the same simple name, strong-naming provides a unique identity for each version of the assembly.

    • You do not want to negatively affect performance of apps using your assembly, so you want the assembly to be domain neutral. This requires strong-naming because a domain-neutral assembly must be installed in the global assembly cache.

    • When you want to centralize servicing for your app by applying publisher policy, which means the assembly must be installed in the  global assembly cache.

    Maybe you could make your unit test project still have the strong name, test the result.

    Not the real strong name expert, but as our previous discussions, I doubt that it would be related to the this issue "How un-signed assemblies referenced a signed assembly".

    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.


    Wednesday, January 7, 2015 2:31 AM
  • Update:

    @Aditya,

    Like this document here "How to: Reference a Strong-Named Assembly":

    http://msdn.microsoft.com/en-us/library/s1sx4kfb(v=vs.110).aspx

    A strong-named assembly can only use types from other strong-named assemblies. Otherwise, the security of the strong-named assembly would be compromised. I doubt that it would be related to this issue.

    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.

    Wednesday, January 7, 2015 2:40 AM

All replies

  • Could you attach a sample solution with projects that reproduces the issue?

    Try-Fail-Learn-Improve http://speakingin.net

    Friday, December 12, 2014 12:11 PM
  • Hi Aditya,

    Unit test projects are not the executable app, so we couldn't debug it with the debug menu "Start Debugging(F5)" directly.

    But we could debug it in Test Explorer window like the following screen shot, and you could also get the output error message in test explorer window.

    If you want to debug your main project with your test project, you could add breakpoints in your main project, and then debug it with your test project like the above steps, after the breakpoint is hit, you could debug it with the debug menu options like step Into or others normally.

    >>The symbols in the main project are not loaded during run time, So finding the exact issue become cumbersome and difficult.

    If you mean that you know how to debug it but the symbols didn't loaded, please load it manually from the Modules window, please enable the symbols option under TOOLS->Options->Debugging->Symbols 

    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.


    Monday, December 15, 2014 7:58 AM
  • Hi Jack,

    Thanks for your Valuable response. I am doing exactly the same thing (debugging as described in the screenshot) as you have described above. The problem is I am not able debug the Methods Which is being unit tested. The breakpoint is never hit. It is happening in Update 2 of VS 2013. I have raised a bug and the bug id is 1070060.

    Please refer to the bug for additional details and steps to reproduce.

    Thanks

    Aditya

    Tuesday, December 30, 2014 6:57 AM
  • Hi Aditya,

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

    https://connect.microsoft.com/VisualStudio/Feedback/Details/1070060If possible, you could share a simple sample in your connect report, so it would be helpful for the product team members to troubleshoot and repro this issue.

    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, December 30, 2014 9:11 AM
  • HI Jack,

    Thanks again for your interest in this matter. Just to let you know this is happening only for Projects and Assemblies which are signed with strong names.

    Does that helps you ?

    Aditya

    Tuesday, December 30, 2014 10:45 AM
  • Hi Aditya,

    Thanks for your friendly response.

    >>Just to let you know this is happening only for Projects and Assemblies which are signed with strong names.

    Actually one important issue is that if you debug your previous project directly without the unit test project, how about the result? Could you debug it?

    As far as I know, it seems that a delay-signed project won’t run, and we can’t debug it, delay signed assembly doesn't support debug feature.

    http://msdn.microsoft.com/en-us/library/ms247066.aspx

    Maybe you could share us a simple sample with one drive, I will test it in my side, if I get the same issue, I will help you vote your connect report.

    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.

    Wednesday, December 31, 2014 6:02 AM
  • Hi Jack,

    Thanks again for your response

    >> Actually one important issue is that if you debug your previous project directly without the unit test project, how about the result? Could you debug it?

    I am able to debug it from w3wp(IIS) process. The issue is only while debugging from the Unit test project.

    I am extremely sorry Jack, but due to some contractual issues I am not able to provide you with a sample.

    Regarding delay signing - AssemblyDelaySignAttribute is not set. So we do not use it. Do you want me to specifically set it to false. ?

    Please let me know, If I am being helpful here.

    Thanks

    Aditya

    Wednesday, December 31, 2014 6:20 AM
  • Hi Aditya,

    >>I am able to debug it from w3wp(IIS) process. The issue is only while debugging from the Unit test project.

    So you were debugging an ASP.net app with a unit test, am I right?

    Maybe this document would be helpful for you here:

    http://msdn.microsoft.com/en-us/library/ms243172.aspx

    In addition, if you could debug your previous app normally, but you couldn't debug it in from your unit test project, one issue is that please make sure that the code in your app was really called in your unit test project, so you could use other way to output message from your previous app.

    For example, use the Debug.Print() or others in your class method you want to test/debug, after you run/debug your unit test, check the output result like the following screen shot.

    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, January 2, 2015 2:11 AM
  • Hello Jack,

    Thanks again for your response.

    >> So you were debugging an ASP.net app with a unit test, am I right?

    Not exactly, It is a WCF project hosted on IIS with a strong key to sign it.

    So I am able to debug in following circumstance :-

    1. Directly attaching it with W3WP process (with or without the strong key).

    2. Able to debug from unit tests only if I remove the strong key from project properties.

    So, the issue is something do with the strong key. The reason we are keeping this strong key is because, If you remove the strong key it gives a Code Analysis error.

    Let me know, If my description helped you.

    Thanks

    Aditya

    Friday, January 2, 2015 5:51 AM
  • Hi Aditya,

    >>Able to debug from unit tests only if I remove the strong key from project properties.

    If so, I doubt that it would be the strong key issue.

    In addition, which project did you add the strong key, your WCF project or the unit test project?

    >>The reason we are keeping this strong key is because, If you remove the strong key it gives a Code Analysis error.

    Maybe the real issue we would think about the code analysis issue if we could remove the strong key and debug the app(As far as I know the code analysis results are not the real error, it would be the warnings).

    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, January 2, 2015 6:25 AM
  • Hello Jack,

    Thanks for your response.

    We cannot remove the code analysis warning as it is a requirement.

    Let me know, of any other suggestions.

    Aditya

    Tuesday, January 6, 2015 7:02 AM
  • Hello Jack,

    With respect to your question above

    >> In addition, which project did you add the strong key, your WCF project or the unit test project?

    It is the WCF project which contains the strong key.

    Aditya 


    Tuesday, January 6, 2015 1:01 PM
  • Hi Aditya,

    Do you get any error/warning messages when you debug your project?

    You could view the Output or Error list windows, if you get any messages, please share me the detailed messages.

    If you could debug it with the WCF project, but not from the unit test project, one possible reason is that the un-sign unit test project doesn't have the enough trust with the strongly-named assemblies, so it couldn't load these assemblies from your unit test project.

    Maybe you could check the following document/thread, maybe it could help you.

    http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute(v=vs.110).aspx

    http://stackoverflow.com/questions/7191373/how-can-i-make-internalsvisibleto-attribute-work-by-signing-a-public-token-key-s

    Based on this document:

    http://msdn.microsoft.com/en-us/library/wd40t7ad(v=vs.110).aspx 

    Strong-named assemblies are useful in the following scenarios:

    • You want to enable your assemblies to be referenced by strong-named assemblies, or you want to give friend access to your assemblies from other strong-named assemblies.

    • An app needs access to different versions of the same assembly. This means  you need different versions of an assembly to load side by side in the same app domain without conflict. For example, if different extensions of an API exist in assemblies that have the same simple name, strong-naming provides a unique identity for each version of the assembly.

    • You do not want to negatively affect performance of apps using your assembly, so you want the assembly to be domain neutral. This requires strong-naming because a domain-neutral assembly must be installed in the global assembly cache.

    • When you want to centralize servicing for your app by applying publisher policy, which means the assembly must be installed in the  global assembly cache.

    Maybe you could make your unit test project still have the strong name, test the result.

    Not the real strong name expert, but as our previous discussions, I doubt that it would be related to the this issue "How un-signed assemblies referenced a signed assembly".

    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.


    Wednesday, January 7, 2015 2:31 AM
  • Update:

    @Aditya,

    Like this document here "How to: Reference a Strong-Named Assembly":

    http://msdn.microsoft.com/en-us/library/s1sx4kfb(v=vs.110).aspx

    A strong-named assembly can only use types from other strong-named assemblies. Otherwise, the security of the strong-named assembly would be compromised. I doubt that it would be related to this issue.

    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.

    Wednesday, January 7, 2015 2:40 AM