Click here to Skip to main content
15,888,330 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to access the following static class/variables in client side ui (WPF-usercontrol) through WCF service.

C#
namespace MySolution.Model
{
    public static class SysAppParam
    {
        public static string EmpCodeGenInActionForm = "EmpCodeGenInActionForm";
        public static string AutoEmpTempSeqCode = "AutoEmpTempSeqCode";
        public static string EmpEmail = "EmpEmail";
        ..........
          ..........
       ...........
       ..........
  
    }
}


How to make the above class avilable in all tiers?? i included it in Model project to get access from all tiers... Is it the way to make it?
Plz help....
Posted

Why not put it in a "Common" class library project that all your tiers reference, that way it is available at all points?
 
Share this answer
 
Comments
Pheonyx 11-Dec-13 4:30am    
Why can't you also add a reference to "Model" in the UI project? What is Model specifically? When I say a common class library. This is a project that would contain things such as static classes that all other projects need access to, maybe some generic helper functions etc.
Pheonyx 11-Dec-13 5:11am    
Okay well, correct me if I'm wrong, but you are new to programming and blindly copying that tutorial?
You need to understand the purpose of referencing dlls etc, you are not limited to those "5 projects" you can have, basically an infinate amount of projects that reference each other (as long as there are no circular references. I would create a new project called "Common" and move that static class to it. Then reference that project from the UI/Dataaccess/BusinessLayer/ServiceLayer projects. Aslong as you deploy the dll with your UI it will be fine.
What you seem to be missing here is that a service provider and a service client are two completely separate applications. Layering on the server side won't make classes available on the client side, you need to include those classes directly in the client project.

It's an understandable mistake as the 'make WCF client' process in Visual Studio auto-generates a whole bunch of proxy classes that make it look like your service classes are in the client as well, but they really aren't (if you dig into those classes in the client solution you'll see that they are just proxies) which is why you have to regenerate them when you change the service.

You can include this collection of constants in the client application either by having it in a common project which is referred to in both sides, or by including the .cs file in the model-tier project on both sides (Add Existing Item and then use the dropdown arrow in the file picker to add a link).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900