Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
It is interesting to say it works for one project but for another it doesn't work! I use Visual Studio 2008 for the both projects.
if (str.Substring(0, "@variable".Length) != "@variable" && str.Substring(0, "@composite".Length) != "@composite")

                s = str.Split('.')[0];




        List<string> distinctItem = tablesList.Distinct().ToList();

        List<string> globalTablesList = GetTableNames(dt);

        List<string> commonTableList = (from item in distinctItem
                                        where globalTablesList.Contains(item)
                                        select item).ToList();

The errors shown:

  1. ) Expected D:\BIPORTAL-Dev\App_Code\Service.cs 162 46 D:\BIPORTAL-Dev\
  2. Invalid expression term 'in' D:\BIPORTAL-Dev\App_Code\Service.cs 162 51 D:\BIPORTAL-Dev\
  3. ; expected D:\BIPORTAL-Dev\App_Code\Service.cs 162 51 D:\BIPORTAL-Dev\
Updated 1-Mar-14 21:02pm
Vedat Ozan Oner 28-Feb-14 6:18am    
possibly, you have forgotten a ';' above it.
Rob Grainger 28-Feb-14 6:47am    
Sorry, there isn't enough context to solve this.

1. Add line numbers to example - we cannot correlate the error messages with the lines.
2. Is this file "Service.cs" in the path listed?
3. Where is distinctItem defined?
4. Where is globalTablesList defined?

It looks to be like "distinctItem" is not a valid collection type - as such it cannot be enumerated for items (which is what the 'in' operator does.
V5709 1-Mar-14 0:00am    
can you explain about elements distinctItem & globalTablesList?
sachi Dash 2-Mar-14 3:01am    
I have improved my question ...... please keep in mind that same code works in one project. But when I put it into SourceSafe some error shown. Probably it can not take any LING expression. But why? please help if possible.

1 solution

Check the two project properties.
At a guess, you will find that the project where it works is set as .NET version V3.5, and the one where it doesn't is set as .NET V3.0 or below.

Linq syntax was introduced at V3.5, so versions earlier than that do not support it.

BTW: your if code is a bit weird: you do realize that the string class has a StartsWith [^]method?
if (!str.StartsWith("@variable") && !str.Startswith("@composite"))
   s = str.Split('.')[0];
Share this answer
sachi Dash 3-Mar-14 4:05am    
You are right. Thanks a lot, lot and lot ! How I can change its version to 3.5 ? I mean i am running this on less than version 3.5. Then how can i select 3.5 for this project from version 2.0 ?

This error is shown in webpage if i run this project. Can you help me after seen this problem.
Is it for version another.

C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE> "C:\Windows\Microsoft.NET\Framework\v2.0.50727\csc.exe" /t:library /utf8output /R:"C:\Windows\assembly\GAC_MSIL\System\\System.dll" /R:"C:\Windows\assembly\GAC_32\System.Web\\System.Web.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.Web.Mobile\\System.Web.Mobile.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.WorkflowServices\\System.WorkflowServices.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.Configuration\\System.Configuration.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.Core\\System.Core.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.Drawing\\System.Drawing.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.ServiceModel\\System.ServiceModel.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.Data.DataSetExtensions\\System.Data.DataSetExtensions.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.Runtime.Serialization\\System.Runtime.Serialization.dll" /R:"C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.Xml.Linq\\System.Xml.Linq.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.Web.Services\\System.Web.Services.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.IdentityModel\\System.IdentityModel.dll" /R:"C:\Windows\assembly\GAC_32\System.EnterpriseServices\\System.EnterpriseServices.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.ServiceModel.Web\\System.ServiceModel.Web.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.Xml\\System.Xml.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.Web.Extensions\\System.Web.Extensions.dll" /R:"C:\Windows\assembly\GAC_32\System.Data\\System.Data.dll" /out:"C:\Users\suman.SSD-TECH\AppData\Local\Temp\Temporary ASP.NET Files\biportal-dev\947cac42\73de6232\App_Code.xl0pv-9w.dll" /D:DEBUG /debug+ /optimize- /w:4 /nowarn:1659;1699;1701 "C:\Users\suman.SSD-TECH\AppData\Local\Temp\Temporary ASP.NET Files\biportal-dev\947cac42\73de6232\App_Code.xl0pv-9w.0.cs" "C:\Users\suman.SSD-TECH\AppData\Local\Temp\Temporary ASP.NET Files\biportal-dev\947cac42\73de6232\App_Code.xl0pv-9w.1.cs" "C:\Users\suman.SSD-TECH\AppData\Local\Temp\Temporary ASP.NET Files\biportal-dev\947cac42\73de6232\App_Code.xl0pv-9w.2.cs" "C:\Users\suman.SSD-TECH\AppData\Local\Temp\Temporary ASP.NET Files\biportal-dev\947cac42\73de6232\App_Code.xl0pv-9w.3.cs" "C:\Users\suman.SSD-TECH\AppData\Local\Temp\Temporary ASP.NET Files\biportal-dev\947cac42\73de6232\App_Code.xl0pv-9w.4.cs" "C:\Users\suman.SSD-TECH\AppData\Local\Temp\Temporary ASP.NET Files\biportal-dev\947cac42\73de6232\App_Code.xl0pv-9w.5.cs"
OriginalGriff 3-Mar-14 4:53am    
You're welcome!
It's pretty easy: open the project properties, and look at the "Application" tab.
"Target framework" has a drop down, which allows you to select the version of .NET you want to compile to.
You shouldn't get any problems changing up (though you may get some extra "outdated method" warnings, depending on what your code uses), but you will do going down versions!

You will probably need to add the
using System.Linq;
line to each file manually.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900