C# Visual Studio unknown build error

Asked

Viewed 415 times

0

I went to refactor my code in C# that was working perfectly, but it was gigantic, and it stopped working and the visual studio does not describe the error in any corner. Below is my code and Visual Studio.

Visual Studio Console Printscreen inserir a descrição da imagem aqui

Ticketcontroller - My handler

using sgtalk.api.Helpers;
using sgtalk.api.Models;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.Cors;

namespace sgtalk.api.Controllers
{
    [EnableCors(origins: "*", headers: "*", methods: "*")]
    public class TicketController : ApiController
    {
        public HttpResponseMessage Get()
        {
            //TicketRepository.GetAll(lg)
            HttpResponseMessage resp = new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.BadRequest
            };

            if (LoginHelper.isLogged(Request, out LoginTransmit lg))
            {
                //    resp = new HttpResponseMessage()
                //    {
                //        StatusCode = HttpStatusCode.OK,
                //        Content = new StringContent(JsonConvert.SerializeObject(new { }))
                //    };
            }
            else
            {
                resp = new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.Unauthorized
                };
            }

            return resp;
        }
    }
}

Analyzing the code a little, I found that the error is on the line

LoginHelper.isLogged(Request, out LoginTransmit lg)

Removing this line the program compiles.

Loginhelper -- The prorietary of the line above

using sgtalk.api.Models;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;

namespace sgtalk.api.Helpers
{
    public static class LoginHelper
    {
        public static bool isLogged(HttpRequestMessage r, out LoginTransmit l)
        {
            l = null;
            var ret = false;
            if (r.Headers.TryGetValues("X-Access-Token", out IEnumerable<string> headerValues))
            {
                var s = headerValues.FirstOrDefault();
                l = TokenHelper.Decode(s);
                ret = true;
            }
            else
            {
                ret = false;
            }
            return ret;
        }
    }
}

What is going on? I’m more than 1 hour trying to solve, but I can’t find where exactly is the error.

Update: by "stopped working" I mean no more compiling.

Update 2: In the console it lists the following errors:

C: Users Inc.Icolau Documents visual studio 2017 Projects sgtalk sgtalk.api Controllers Ticketcontroller.Cs(51,61,51,63): error CS1003: Syntax error, ',' expected

On these lines, there are these codes:

public HttpResponseMessage Get()
        {
            //TicketRepository.GetAll(lg)
            HttpResponseMessage resp = new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.BadRequest
            };
//linha 51
            if (LoginHelper.isLogged(Request, out LoginTransmit lg))
            {
                //    resp = new HttpResponseMessage()
                //    {
                //        StatusCode = HttpStatusCode.OK,
                //        Content = new StringContent(JsonConvert.SerializeObject(new { }))
                //    };
            }
            else
            {
                resp = new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.Unauthorized
                };
            }

            return resp;
        }

C: Users Marcio.Nicolau Documents visual studio 2017 Projects sgtalk sgtalk.api Helpers Loginhelper.Cs(14,74,14,80): CS1525 error: Invalid Expression term 'string'

public static bool isLogged(HttpRequestMessage r, out LoginTransmit l)
        {
            l = null;
            var ret = false;
            if (r.Headers.TryGetValues("X-Access-Token", out IEnumerable<string> headerValues)) //Linha 14
            {
                var s = headerValues.FirstOrDefault();
                l = TokenHelper.Decode(s);
                ret = true;
            }
            else
            {
                ret = false;
            }
            return ret;
        }

Update 3: I’m using . NET Framework 4.6

  • 1

    If I’m not mistaken, in the console (log), describes the error when it is so. Put to compile and keep paying attention there, maybe you find something.

  • 1

    Elaborate: "stopped working".

  • @LINQ Gave an update to the post

1 answer

2


What version of c# are you using? If it’s previous versions or 6.0, test this:

LoginTransmit lg;
LoginHelper.isLogged(Request, out lg);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.