none
Unable to access ServicePointManager class in Visual Studio Express 2012 for Windows 8 to validate Certificate TLS1.2 RRS feed

  • Question

  • Dear Developers,



    I am using Visual Studio 2012 Express with 4.5 framework in which I need to write the Code to validate the TLS1.2 

    Certificate for Secure Connection for Windows 8 Apps. Whenever I tried to use ServicePointManager Class its throwing error 

    : "The Type or Namespace name could not be found(are you missing using directive)". But After Searching in google I found 

    it is available in System.Net namespace but whenever I used it in my class I am not able to access it.

    But at run time I am able to access it in Add Watch window. Please provide me the solution that How can I access the 

    ServicePointManager class with supporting SecurityProtocol.Tls12 in Visual Studio Express 2012 4.5 framework



    Please provide any help upon it. 

    Regards

    Nishant Patni
    Friday, December 1, 2017 1:41 PM

All replies

  • Hi Nishant Patni,

    Thank you for posting here.

    According to your description, I do some test. On my side, every thins is ok.

    Per my understanding, please try to remove the reference and add again first.

    And then check you features. Do you use the new security feature that blocks insecure cipher and hashing algorithms for connections in your code? Applications using TLS/SSL through APIs such as HttpClient, HttpWebRequest, FTPClient, SmtpClient, SslStream, etc. and targeting .NET Framework 4.6 get the more-secure behavior by default. If you use the new feature, please set the .NET Framework version to 4.6.

    If the suggestion below could solve your exception, please a simple code which could reproduce the error for us to test.

    Best Regards,

    Wendy

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Tuesday, December 5, 2017 5:47 AM
    Moderator
  • using System.Collections.Generic;
    using System.IO;
    using System.Net;
    using System.Reflection;
    using System.Runtime.CompilerServices;
    using System.Threading.Tasks;
    using Windows.Storage;
    using Windows.UI.Popups;

    namespace FrontEnd.Helper
    {
        public static class JsonServiceHelper
        {
            static CookieContainer cookieContainer = new CookieContainer();
            /// <summary>
            /// JSON functionality to get data from API
            /// </summary>
            public async static Task<string> JsonPost(string url, string jsonContent)
            {

                ServicePointManager SPM = new ServicePointManager();

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                request.Method = "POST";
                request.CookieContainer = cookieContainer;

              }

         }

    }

    /*******************************************************************************/

    In Above code we are unable to access ServicePointManager. We want to write the code for TLS1.2 Certificate check as

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

    But unable to write it in Visual Studio 2012 Express for Windows.

    The references which we are using in our project are:

    1.  .NET For Windows Store App 

    2.   Windows

    Please help to provide alternate solution for it.

    Moreover we are unable to change current framework 4.5 to 4.6 framework in Visual Studio 2012 Express.


    Tuesday, December 5, 2017 8:02 AM
  • Hi nISHANT pATNI,

    Thank you for feedback.

    According to your code, I could not run that. But JsonPost missing await in this async method.

    The code below is not in right format.

     ServicePointManager SPM = new ServicePointManager();

    For the use of ServicePointManager, you would like to check the MSDN article.

    https://msdn.microsoft.com/en-us/library/system.net.servicepointmanager(v=vs.110).aspx

    https://msdn.microsoft.com/en-us/library/system.net.servicepoint(v=vs.110).aspx

    >>The references which we are using in our project are:

    1.  .NET For Windows Store App 

    2.   Windows

    What does this mean? For ServicePointManager, you could add reference directly. Right the project>Add>Reference, choose System.Net.

    >>Moreover we are unable to change current framework 4.5 to 4.6 framework in Visual Studio 2012 Express.

    Why you could not change the current framewrok 4.5 to 4.6?

    Please right click the project> Properties, and then choose .net framework 4.6 in Target framework.

    If you do not install .net framework 4.6, you could download in link below.

    https://www.microsoft.com/net/download/visual-studio-sdks

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, December 11, 2017 2:45 AM
    Moderator
  • Thanks Wendy Zang for your response .

    But as we are working upon Express Version of Visual Studio 2012 and I tried to Change the Framework but, we are unable to do that as this option is disabled in Express version.

    Moreover we are able to access System.Net in our project but unable to access ServicePointManager.SecurityProtocol as its throwing exception that "Are you missing assembly....".
    Monday, December 11, 2017 9:32 AM