none
Data does not exist in 'MyNameSpace.System RRS feed

  • Question

  • I am learning how to use LINQ-to-SQL.

    I create a new project and and a DBML file.  I drag tables from my database to the designer, and build the project...

    I get 180 errors- e.g. (a few examples)

    The type name Data does not exist in the Type 'myNameSpace.System' in file DataClasses1.designer

    The type name 'Collections' does not exist in the Type 'myNameSpace.System'

    The type name 'Reflection' does not exist...

    etc.

    Help!

    This is all auto generated: It's a fresh project I have added no custom code, nothing... Why the errors?

    regards,

    John.

    Tuesday, September 7, 2010 3:06 PM

Answers

  • Hey, I thought this was resolved, you named a table System and when generated, well errors would come out because the compiler was confused between your and its System, it will always give preference to yours so: 180 errors in autogenerated code.

    So, is there something new?

    You need anything else?

    LitEnders advice about fully qualifying naming is sound but a bad, bad idea because as is autogenerated code, every time a change is made, bum 180 errors, so you will need to manually change that every time and if you work with a team it will be worse.

    So, rename the table if possible to something Microsoft doesn't use.  In the msdn there a list of reserved keywords.  As an alternative change plurarization rules or don't use linq

    Regards

    • Marked as answer by ltheONEl Tuesday, September 7, 2010 5:37 PM
    Tuesday, September 7, 2010 5:27 PM
  • Yes, I am fortunate to own the database: So I renamed the table as resolution.

    I would never interfere with AutoGen code: thats just a nightmare.

    It's weird I had posted the table rename as a resolution to my own question but that magically has dissapeared!

    Thanks

    john.

    • Marked as answer by ltheONEl Tuesday, September 7, 2010 5:37 PM
    Tuesday, September 7, 2010 5:36 PM

All replies

  • Keanu, that is not supposed to happen.

    More info would be helpful, such as VS version, etc.

    Thanks

    So it is resolved...

    For future references avoid naming stuff similar to reserved keywords, even when it doesn't give errors upfront it will be a headache on the road ahead.

    Regards

    • Edited by Serguey123 Tuesday, September 7, 2010 4:23 PM saw the other thread
    Tuesday, September 7, 2010 4:20 PM
  • Hi Thanks,

    I am using Visual C# express:

    Microsoft Visual Studio 2010
    Version 10.0.30319.1 RTMRel
    Microsoft .NET Framework
    Version 4.0.30319 RTMRel

    Installed Version: C# Express

    Microsoft Visual C# 2010   01014-169-2560017-70198
    Microsoft Visual C# 2010

    Tuesday, September 7, 2010 4:52 PM
  • I have seen problems like this before.   I believe you cannot have the your working final namespace name the same as a classname or namespace from the using statement.  I don't know all the conflicts, but there are probably a few different types of naming conflicts.

    using A.B;
    using A.C;
    
    namespace B
    {
    	class Program
    	{
    		static void Main(string[] args)
    		{
    			//'A' is a namespace but used like a 'type' error; 
    			A a = new A();
    
    			//Works
    			A2 A = new A2();
    			A.ToString();
    		}
    	}
    
    	public class A2
    	{
    		public A2()
    		{
    			//Works
    			D d = new D();
    		}
    	}
    }
    
    namespace A.C
    {
    	public class D
    	{
    	}
    }
    
    namespace A.B
    {
    	public class A
    	{
    	}
    }
    

     

    Since it is auto generated code, it probably is having problems.

    You can fully quailify System like this "global::System".  Additionally you can rename System in the using statement like this  "using GlobalSystem = global::System;", but you will have to append to the begining to all the System types, "GlobalSystem.".  

    I recommend just not using the name System.

     

     

    Tuesday, September 7, 2010 5:15 PM
  • Hey, I thought this was resolved, you named a table System and when generated, well errors would come out because the compiler was confused between your and its System, it will always give preference to yours so: 180 errors in autogenerated code.

    So, is there something new?

    You need anything else?

    LitEnders advice about fully qualifying naming is sound but a bad, bad idea because as is autogenerated code, every time a change is made, bum 180 errors, so you will need to manually change that every time and if you work with a team it will be worse.

    So, rename the table if possible to something Microsoft doesn't use.  In the msdn there a list of reserved keywords.  As an alternative change plurarization rules or don't use linq

    Regards

    • Marked as answer by ltheONEl Tuesday, September 7, 2010 5:37 PM
    Tuesday, September 7, 2010 5:27 PM
  • Yes, I am fortunate to own the database: So I renamed the table as resolution.

    I would never interfere with AutoGen code: thats just a nightmare.

    It's weird I had posted the table rename as a resolution to my own question but that magically has dissapeared!

    Thanks

    john.

    • Marked as answer by ltheONEl Tuesday, September 7, 2010 5:37 PM
    Tuesday, September 7, 2010 5:36 PM