0

I'm facing a weird problem for 5 days. Tried many thing starting of Googling and with no luck.

I think it's about my pc configuration but I couldn't found where it could be what's fixing.

The error message is: CS1525: Invalid expression term '.'

Source:

at line 17.

Line 15:     <meta name="viewport" content="width=device-width, user-scalable=no, maximum-scale=1.0, minimum-scale=1.0" />
Line 16:     <title><%=notifies.Count > 0 ? "("+notifies.Count+")" : "" %>
> Line 17:         <%:Core.memberInfo?.Username %>[<%:Core.memberInfo?.ID %>] /
Line 18:         <asp:ContentPlaceHolder runat="server" ID="titleAddons"></asp:ContentPlaceHolder>
Line 19:         :: <%:Core.siteOptions.SiteTitle %></title>

I'm using Visual Studio 2017. Project coding by .net 4.7.2. There is no build errors.

How can it be fixed?

Thank you for now..

ferhatozkanun
  • 129
  • 1
  • 5
  • 1
    I guess the compiler version is too low. Will this error still be reported after deleting the question mark? – shingo May 18 '23 at 06:51
  • @shingo I faced some more errors about compiler. So I used max version of it. This didn't solve my problem. – ferhatozkanun May 18 '23 at 08:03
  • @rene Why can't I use null coalesce? It was work as a charm for a while ago. I don't know what did I change within my pc to face that. And, this is a huge project which has about 450k rows. – ferhatozkanun May 18 '23 at 08:03
  • @rene no! It's not the same with that link which you shared since I'm using c# 7.3. – ferhatozkanun May 18 '23 at 08:04
  • @shingo The compiler is "Microsoft.Net.Compilers.4.2.0". – ferhatozkanun May 18 '23 at 08:20
  • does using `<%=` instead of `<%:` resolve the issue? What does the compilation element in your web.config says? – rene May 18 '23 at 08:31
  • @rene no. `<%=` not solved the issue. There is no line for compilation in web.config according to solve some other issues. – ferhatozkanun May 18 '23 at 08:49
  • Maybe your machine config is off, try adding this: https://stackoverflow.com/a/40171685 to your web.config to have more fine grained control. – rene May 18 '23 at 09:13
  • @rene, Sorry! I misunderstood your previous question. The compilation line is `` – ferhatozkanun May 18 '23 at 09:35
  • Would it work without the `? `, so just `Core.memberInfo.Username`? Of course it will then crash on null – Hans Kesting May 18 '23 at 15:33
  • Do you need (update) this: https://www.nuget.org/packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform ? – Hans Kesting May 18 '23 at 15:36
  • Yes, @HansKesting. It's working without `?`. But also it was working with it for a while ago. And, I can't remove those question marks since there are too many of them in my project. – ferhatozkanun May 18 '23 at 18:54
  • Since I was using "Microsoft.Net.Compilers.4.2.0", there is no need to use "DotNetCompilerPlatform", as I know. @HansKesting – ferhatozkanun May 18 '23 at 18:55
  • About that ? was not a suggestion to remove it, but a check about the compiler version. The version you are using is apparently too old to understand the null-conditional operator – Hans Kesting May 18 '23 at 19:40
  • @HansKesting, please direct me to change compiler from "Microsoft.Net.Compilers.4.2.0" to "DotNetCompilerPlatform". NuGet is jamming when install "DotNetCompilerPlatform" to the project. When I install it, I have errors about 12k. For example "Element 'page' is not a known element" vs. While googling, I found the solution by removing compilers declarations. So, I stucked at there. – ferhatozkanun May 19 '23 at 02:15
  • Would this help? https://stackoverflow.com/questions/32012051/where-to-configure-razor-page-language-version-to-c-sharp-6 – Hans Kesting May 19 '23 at 09:54
  • Thank you @HansKesting. I solved my problem with your previous recognizing. – ferhatozkanun May 20 '23 at 03:31

1 Answers1

1

Thank you all to your efforts.

I removed from "Microsoft.Net.Compilers.4.2.0" to "Microsoft.CodeDom.Providers.DotNetCompilerPlatform.4.1.0".

I made sure there is no rows in web.config for those two and there is no row for Microsoft.Net.Compiler.4.2.0 because of previous experiments.

This is strange because I tried it before with no luck. But, after some restarting and cleaning some folders could be worked.

ferhatozkanun
  • 129
  • 1
  • 5