Home

CS1061 Issue

Was searching for threads to fix the CS1061 issue in Linqpad I am thinking this has something to do with my extensions still confirming this. CS1061 'string' does not contain a definition for 'G' and no extension method 'G' accepting a first argument of type 'string' could be found. Any thoughts on what I can try to resolve?

Comments

  • Is it possible you have highlighted a part of your query?

    For example, the following is valid C#

    "abbccc".GroupBy(a=>a).Dump();

    But if I happen to highlight up the G, then I get a similar error

    If it is not that, then you need to give more detail on what your query says.

  • edited July 16

    Hello Here is the script - I am thinking this has something to do with my extensions, also when I search for culture 2.0.0 in linqpad nugets I cannot find it.

    ISSUE
    prescription.StatusId = "9da0dc6d-591b-445d-b8d3-b1c5cffb4396".G();

    SCRIPT STARTS BELOW

    var numbers = new List
    {
    6644834
    };

    var prescriptions = Prescriptions.Where(p => numbers.Contains(p.Number));

    foreach (var prescription in prescriptions)
    {
    prescription.StatusId = "9da0dc6d-591b-445d-b8d3-b1c5cffb4396".G();
    prescription.ModifiedUser = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
    prescription.ModifiedDate = DateTime.UtcNow;
    foreach (var report in prescription.Reports)
    {
    report.CardiologsId = null;
    report.CardiologsError = null;
    report.ModifiedUser = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
    report.ModifiedDate = DateTime.UtcNow;
    }

    //prescription.Dump();
    //prescription.Reports.Dump();
    SubmitChanges();
    

    }

  • So what is G method?

    Either you are missing this method or it exists in another namespace that you haven't told Linqpad to use.

    I would guess this is an extension method which isn't in your My Extensions.

    If so it could be something trivial like

    internal static class StringExtensions
    {
        public static Guid G(this string sGuid)
        {
            return new Guid(sGuid);
        }
    }
    

    but you would be better not to guess. If this script came from someone else, ask them for the extension or if you have access to a machine where it works, you can highlight their G and press F12 to jump to the definition.

    As for culture nuget, I don't have enough info. Culture is a strange name for a public nuget package. Since the name has to be unique across every company that wishes to publish something on nuget, it is rare to see generic names like this. You need to ask for the full name or also check that it is not published on a private nuget source.

  • Thanks for that tip I did check " highlight their G and press F12" - extensions look correct. My linqpad is working correctly I was assisting a colleague. I copied and compared all my settings, so I am leaning more to issues with the nugets, she is missing a few. thanks

Sign In or Register to comment.