把以前写的VC代码,在VS2005中,将编译选项改为/clr , 编译成托管代码。然后在C#中调用,发生错误:error CS0117: Old.Adoes not contain a definition for 'x'VC 代码:
namespace Old
{
   public Class A
   {
       public:
         A();
         float x;
   }
}C#中调用:
using Old;
   A a = new A();  
   a.x = 0;  // !!!这里发生错误如下:error CS0117: Old.Adoes not contain a definition for 'x'   同时发现,所有的A类里面的函数以及变量都无法调用,都出现同样的error CS0117错误。
   请问各位这个问题该怎么解决?谢谢!

解决方案 »

  1.   

     float x; 
    默认的是私有的吧?
      

  2.   

     前面加了一个public了,我也试过直接在变量和函数前面再加一个public,但仍然还是出一样的错误。
     
      

  3.   

    http://msdn.microsoft.com/en-us/library/c4aad8at(VS.71).aspxA call was made to a method that does not exist for the data type. This can also happen when a class name and its enclosing namespace name are the same and when a qualified method is called.