.NET Framework Developer Center > .NET Development Forums > Windows Communication Foundation > VS2008 crashes every time when InstanceContextMode:=InstanceContextMode.Single
Ask a questionAsk a question
 

AnswerVS2008 crashes every time when InstanceContextMode:=InstanceContextMode.Single

  • Friday, October 30, 2009 12:44 PMpbrasseur Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I have written a WCF Service and it was working fine, but recently when I was trying to run the application it keept crashing my VS2008.
    It crashes before getting into any code...
    After troubleshoot for all morning I wasn't able to resolve it.
     
    Until I have noticed that in my "Service Class"
     
    I had : <ServiceBehaviorAttribute(InstanceContextMode:=InstanceContextMode.Single)> _
     
    So by changing to : <ServiceBehaviorAttribute(InstanceContextMode:=InstanceContextMode.PerCall)

    It no longer crashes.

    Any suggestions, I really need the Single mode

Answers

  • Wednesday, November 11, 2009 1:32 PMpbrasseur Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Thank you Riquel,

    Actually thet won't be necessary, I found the problem.

    In my projet I'm using the Log4Net (open source from Apache) library. In my service class destructor there was a line (Util.Log...) which uses it:

        [ServiceBehavior(InstanceContextMode = System.ServiceModel.InstanceContextMode.Single,
                         ConcurrencyMode=System.ServiceModel.ConcurrencyMode.Multiple,
                         AutomaticSessionShutdown = true,
                         IncludeExceptionDetailInFaults=true)]

       public class ServiceData : IServiceData
        {
           public ServiceData()
            {
                Console.WriteLine("Instanciating ServiceData ");
            }

            ~ServiceData()
            {
                Console.WriteLine("Disposing ServiceData ...");
                Util.log.Info("Test");
            }

    Just removing that one line fixed the issue. I suppose when you run in debug the debugger somehow looks at the destructor (which I don.t need anyways), apparently that caused a VS2008 crash every time . I was able to reproduce the problem in a different project, I'm sure you (or anyone from MSFT) could if you tried.

    Again, thanks for looking at the issue.
    Best,
    Pierre.
    • Marked As Answer bypbrasseur Wednesday, November 11, 2009 1:50 PM
    •  

All Replies

  • Monday, November 02, 2009 6:05 AMPiyush - MSFTMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,
    You can turn on tracing to figure out what could be going wrong - http://msdn.microsoft.com/en-us/library/ms733025.aspx. Thanks.
    - Piyush
  • Wednesday, November 04, 2009 3:31 AMRiquel_DongModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Pbrasseur,

    Whether you can reproduce this situation at other computer with VS2008. Commonly I think that this is one issue related to specific computer. There are some methods you can try to troubleshoot this issue:

    1. Have you applied the latest service pack SP1? If not, please apply the service pack.
    2. If we reboot the operating system to safe mode, do we have the problem? This can help to isolate whether any other applications are interfering with Visual Studio.
    3. If we create a new user account, do we have the problem? This can help to isolate user profile corruption related causes.
    4. If we disable Add-ns (e.g. “Tools” | “Add-in Manager”) and run “devenv.exe /safemode”, do we still have the problem? This can eliminate the possibility that third party Add-ins are causing problems.
    5. If we create a new project, do we have the problem? Sometimes corrupted project settings can cause problems. These are project specific.

    Best regards,
    Riquel
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • Thursday, November 05, 2009 6:14 PMpbrasseur Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Visual-Studio 2008 crashes (with a null exception) when running my WCF host project with this line:

        [ServiceBehavior(InstanceContextMode = System.ServiceModel.InstanceContextMode.Single , AutomaticSessionShutdown = true)]

    Does not crash when using PerCall

        [ServiceBehavior(InstanceContextMode = System.ServiceModel.InstanceContextMode.PerCall , AutomaticSessionShutdown = true)]

    Either way (Single or PerCall) runs ok outside Visual-Studio!!!!!

    What gives?

  • Tuesday, November 10, 2009 5:56 AMRiquel_DongModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Whether you can reproduce this situation at other computer with VS2008. Commonly I think that this is one issue related to specific computer. Please give more information for your question.


    Best regards,
    Riquel
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • Tuesday, November 10, 2009 4:20 PMpbrasseur Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Tried tracing but crashes occurs before the log file gets created.

    Also just tried it and I can reproduce this problem on an other computer.

    Within VS2008 I can run the WCF server ot client without debugging, but crash VS2008 every time when debugging.

    The problem disappears when I use System.ServiceModel.InstanceContextMode.PerCall instead of System.ServiceModel.InstanceContextMode.Single

    I'm using netTcpBinding.

    Running  VS2008 Version 9.0.30729.1 SP and Framework 3.5 SP1

  • Wednesday, November 11, 2009 6:01 AMRiquel_DongModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Pbrasseur,

    Could you send your project to me via email so that I can see your project to reproduce this situation? If you can, please give me detailed information step by step to reproduce it. You can see my email address in my profile. Really thanks for your help to let us investigate this question.
    Best regards,
    Riquel
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • Wednesday, November 11, 2009 1:32 PMpbrasseur Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Thank you Riquel,

    Actually thet won't be necessary, I found the problem.

    In my projet I'm using the Log4Net (open source from Apache) library. In my service class destructor there was a line (Util.Log...) which uses it:

        [ServiceBehavior(InstanceContextMode = System.ServiceModel.InstanceContextMode.Single,
                         ConcurrencyMode=System.ServiceModel.ConcurrencyMode.Multiple,
                         AutomaticSessionShutdown = true,
                         IncludeExceptionDetailInFaults=true)]

       public class ServiceData : IServiceData
        {
           public ServiceData()
            {
                Console.WriteLine("Instanciating ServiceData ");
            }

            ~ServiceData()
            {
                Console.WriteLine("Disposing ServiceData ...");
                Util.log.Info("Test");
            }

    Just removing that one line fixed the issue. I suppose when you run in debug the debugger somehow looks at the destructor (which I don.t need anyways), apparently that caused a VS2008 crash every time . I was able to reproduce the problem in a different project, I'm sure you (or anyone from MSFT) could if you tried.

    Again, thanks for looking at the issue.
    Best,
    Pierre.
    • Marked As Answer bypbrasseur Wednesday, November 11, 2009 1:50 PM
    •