Last post Apr 24, 2017 01:39 PM by bh0526
Apr 19, 2017 02:30 PM|bh0526|LINK
I have a web forms project. Everything works. But now I created a class library using C# that contains several class files I use often. I right clicked on the references and then browsed to the bin folder of the class library project named SIS. I selected
the dll and clicked OK. Now in my web forms project, I can click on references and I see SIS. Now how can I create an object from one of my class files? I thought I just had to add a using pointing to my new reference. But when I try this, it's not found.
So what am I doing wrong?
Apr 19, 2017 04:56 PM|debendra0256|LINK
Please add the dll in you project referances by Right Click add Referances and select your dll.
Once you add that use the namespace and after using namespace i think you will access all the things.
Apr 19, 2017 06:31 PM|bh0526|LINK
I did add the reference. I right-clicked on References and then clicked Add Reference. I then browsed to the class library project and got the dll from the obj/debug folder. Is this correct? The reason I ask is that when I type "using SSI", nothing displays
in intellisense. Normally when I add a reference, I can type using and the first letter and I will see the reference. So something is still wrong.
Apr 20, 2017 03:30 AM|Cathy Zou|LINK
I create a class library named SSL as below:
Then, I add this class library to my CaseTest solution using the following steps:
1.Right click References
2.Click Add Reference>Click Browser> browsed to the SSL class library project and got the dll from the obj/debug folder.
3. You will see the SSL class library be added to reference:
4. The you could use the class file in SSl class library as below:
5. Correct code as below:
public partial class How_to_add_a_reference_to_a_class_library : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
Class1 class1 = new Class1();
string class1return= class1.GetHello(); Class2 class2 = new Class2(); string class2return = class2.GetHello();
Note: If you change class file in your SSL class library, you could try to rebuild SSL. Then re-add SSL reference to you application.
Apr 20, 2017 11:15 AM|bh0526|LINK
Thanks for your reply. I followed your steps but it still does not work. I added my reference like you said. And if I click on references, I clearly see my class library. Then I go to the code behind in a web form. At the top of the code, I add a new
line and type "using SSI_Class_Library" and hit Enter. But the entire line is underlined in red. The error message is:
Error CS0246 The type or namespace name 'SIS_Class_Library' could not be found (are you missing a using directive or an assembly reference?) PowerSchool_Integration C:\Users\bph\documents\visual studio 2015\Projects\PowerSchool_Integration\PowerSchool_Integration\Default.aspx.cs
I'm totally confused at this point. I have no idea what I'm doing wrong.
Apr 20, 2017 11:51 AM|bh0526|LINK
I used your example and it worked. I am able to use the reference. So I have something wrong in my class library that is causing it to fail. I will be able to fix this on my own. Thanks for your help!
Apr 24, 2017 01:39 PM|bh0526|LINK
Somehow I changed the namespace in my class file. Once I changed it back to the correct value, it worked.