Click here to Skip to main content
15,560,542 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I have two project folders under the same solution. One is ChatServer and other is ChatClient. In ChatServer project in have two .cs file one generated automatically along with form and other .cs file is added by me called ChatServerClass.cs. Now how to add reference to this ChatServerClss.cs from my ChatClient project. If right click go to add reference i get ChatServer reference but not chatserverclass. How can i do this pls help
Posted

You all need to add a reference to the dll.
Once that is done, include the name space for the class and it should be available for use (the access of the type should have been public though).
 
Share this answer
 
You can't directly reference code files through Add Reference.... However you can solve your problem by :-
1)Create new project select class library template option
2)Paste code of ChatServer.cs file into this file
3)now Build the project It will give you the .dll file
4)Now back to your main project Add Reference....
Select Browse tab and get the .dll file
now you need to use the namespace in the dll file
using <namespace_in_dll_file>
Now you can use the class's functionality in the project

Best of Luck.............
 
Share this answer
 
Add the reference if ChatServer
on top of file import the ChatServer as
C#
using ChatServer;

and now you can access the class in the function or method

C#
MyClass cls = new MyClass();
cls.propertyName


make sure the class has access modifier as public
 
Share this answer
 
v2

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