Reputation: 885
I have some strange problem. I have a solution with the following structure
http://i33.tinypic.com/10fbzbq.jpg
As you can see when i wonna import the VDB.Common.RequestAndResponses it gives an error. The namespace of dat Class Library is VDB.Common.RequestAndResponses.
I am new in c# , so it could be that i forgot something stupid.
Upvotes: 0
Views: 351
Reputation: 1499770
I strongly suspect that Base.cs
(the only C# file shown in the VDB.Common.RequestAndResponses
project) doesn't actually declare a type in the VDB.Common.RequestAndResponses
namespace - or that it only declares an internal (rather than public) type.
For example, note that the code you're creating is under the VDB.Client.Infrastructure
project, but is only declaring a class in the Agatha
namespace - not VDB.Client.Infrastructure.Agatha
, which may be what you were intending. Do you have the same kind of thing in Base.cs
, perhaps?
Without seeing the code in Base.cs, we can't see what's wrong though. If you could just post a snippet of that - just the namespace and class declaration - that would be helpful.
Note that although a class library has a default namespace, this isn't prepended to whatever the source file actually declares. In other words, in a library of Acme.Widgets
, if you had a declaration of:
namespace Web
{
public class Button {}
}
that would only declare the type Web.Button
, not Acme.Widgets.Web.Button
.
EDIT: The OP's "answer" confirms what I thought... basically it's not declaring a namespace at all. It should look like this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Agatha.Common;
namespace VDB.Common.RequestAndResponses
{
public abstract class BaseRequest :Request
{
// Code
}
public abstract class BaseResponse : Response
{
// Code
}
}
I would also strongly advise that these classes should be put in two separate files, BaseRequest.cs
and BaseResponse.cs
. I'm also pretty surprised to see a reference to Agatha.Common
- shouldn't that be VDB.Common.Agatha
or something like that?
Upvotes: 2
Reputation: 885
The Base.cs file looks like this.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Agatha.Common;
public abstract class BaseRequest :Request
{
public string UserName { get; set; }
public string UserDomainName { get; set; }
public string ClientLanguageCode { get; set; }
public DateTime ClientCreated { get; set; }
public DateTime ClientSent { get; set; }
public DateTime ServerReceived { get; set; }
public DateTime ServerProcessed { get; set; }
public void BeforeSend(IUserContext context)
{
ClientSent = DateTime.UtcNow;
UserName = context.UserName;
UserDomainName = context.UserDomainName;
ClientLanguageCode = context.LanguageCode;
}
}
public abstract class BaseResponse : Response
{
public DateTime ServerCreated { get; set; }
public DateTime ServerProcessed { get; set; }
public string[] ValidationErrors { get; set; }
public bool IsValid
{
get { return Exception == null & !ValidationErrors.Any(); }
}
}
Upvotes: 0
Reputation: 14391
Try to use the Base class in the client code and hover over it and allow the Visual Studio IDE to prompt you to add the appropriate namespace. The namespace defined in the Base class could be different to what you think.
EDIT As Jon as demonstrated in the 2nd part of his answer - the name of the code file does not automatically correspond to the namespace.
Upvotes: 0
Reputation: 47038
Right click on the "VDB.Common.RequestAndResponses" reference in solution explorer and choose "Show in object browser", make sure the namespace is found there with the exact spelling and capitalization.
Upvotes: 0