I have a simple business manager facade that should just persist some inventory information. However I keep getting the error that “Home.Services.InventorySvc” is a type being used as a variable.
My facade code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Home.Domain;
using Home.Services;
namespace Home.Business
{
public class InventoryMngr
{
public void Create(CreateInventory inv)
{
Factory factory = Factory.GetInstance();
InventorySvc invSvc =
(InventorySvc)factory.GetService(
(InventorySvc).Name);
invSvc.CreateInventory(inv);
}
}
}
The InventorySvc code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Home;
using Home.Domain;
namespace Home.Services
{
public interface InventorySvc : IService
{
void CreateInventory(CreateInventory createinventory);
}
}
You are using
(InventorySvc).Namewhich is the same asInventorySvc.Name, so that would be accessing a static member of theInventorySvcclass. As it’s not a class but an interface, it can’t have static members.