I’m calling a simple method that receives an instance of one of my classes and returns another class instance. For some reason it doesn’t recognise them in the method declaration but is fine with them within the method and before the method is called. Can’t figure out a reason for this. Here is my code;
public ReceiptResponse DownloadReceipt(ReceiptRequest request)
{
ReceiptResponse call = null;
...
}
ReceiptResponse and ReceiptRequest both throw errors in the public line, but the creation of call is fine for some reason. Here is one the classes (both are nearly identical);
public class ReceiptRequest
{
public String ClientID;
public String PolNum;
public String RecNum;
}
MY ERROR
Error 16 The type or namespace name ‘ReceiptRequest’ could not be
found (are you missing a using directive or an assembly reference?)
UPDATE
I definitely have the required using statement because if I hover over ReceiptResponse on the creation of call line then it displays the using statment in the tooltip.
Why is this?
If your RequestReceipt class is in another project, check the Target framework of both projects. Are the the same? If not, check if the target framework of the project which has the ReceiptRequest class is .NET Framework 4, and the other is .NET Framework 4 Client profile.
A project with Target Framework 4 Client profile cannot reference another project with Target Framework 4 (=full).