Reputation: 1616
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?
Upvotes: 1
Views: 105
Reputation: 22945
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).
Upvotes: 1
Reputation: 7591
are these classes in a different assembly? if so you need to reference on project to the other.
are these classes in a different namespace?
if you need to add a using
statement at the top of the file, or declare the fully qualified name when declaring the variable.
using my.name.space;
...
var receipt = new RequestReceipt();
or
var receipt = new my.name.space.RequestReceipt();
Upvotes: 0