Reputation: 79
My problem is the references won't add automatically to my code in visual studio 2005. It works fine in vs 2013. But in 2005, there is no reference to the class that I use this methods. It generates an error says "reallandtest.Entity.DeviceCommEty.Device.set' must declare a body because it is not marked abstract or extern"
using System;
using System.Collections.Generic;
using System.Text;
using Riss.Devices;
namespace reallandtest.Entity
{
public class DeviceCommEty
{
public DeviceCommEty() { }
public DeviceConnection DeviceConnection { get; set; }
public Device Device { get; set; }
}
}
Upvotes: 1
Views: 105
Reputation: 3541
It is a VS2005 compiler limitation...
"Automatic properties are a function of the compiler, not of the framework you're targeting. VS2013 will still work with automatic properties when targeting the .Net 2.0 runtime. However VS2005 will not give you automatic properties."
Source: https://forums.asp.net/post/3021629.aspx
This code (modified due of the missing classes), targetting in both VS for framework 2.0 raises an error only in VS2005
using System;
namespace reallandtest.Entity
{
public class DeviceCommEty
{
public DeviceCommEty() { }
public DeviceConnection DeviceConnection { get; set; }
public Device Device { get; set; }
}
public class DeviceConnection
{
}
public class Device
{
}
}
To make it work, you should get rid off the automatic (bodyless) properties.
public class DeviceCommEty
{
public DeviceCommEty() { }
private DeviceConnection _deviceConnection;
public DeviceConnection DeviceConnection
{
get
{
return _deviceConnection;
}
set
{
_deviceConnection = value;
}
}
Upvotes: 1
Reputation: 79
//Finally got it. This worked for me.
namespace reallandtest.Entity
{
public class DeviceCommEty
{
public DeviceCommEty() { }
public DeviceConnection deviceConnection
{
get { return deviceConnection; }
set { deviceConnection= value; }
}
public Device device
{
get { return device; }
set { device= value; }
}
}
}
Upvotes: 0