-
July 5th, 2012, 05:43 AM
#1
Referencing Classes
I have been trying to referenceClass library I have in a windows form application I am currently working on but it's not working! I created the DLL file by going to Projects > Build Solution and even tried using the Clean build and other misc options to create the DLL but nothing is working.After I add the DLL file as a reference in my Windows application, intellisense still won't recognise the statement.I even made sure both programs target the same .NET 4.0 network.Does anyone have any idea of what could I be doing wrong?
-
July 5th, 2012, 07:57 AM
#2
Re: Referencing Classes
Is "ClassX" the name of a public class in the .DLL?
If so, what is the "NameSpace" of the .dll?
In your "Using", it needs to be the NameSpace. Then you will need to initialize your class.
-
July 5th, 2012, 12:05 PM
#3
Re: Referencing Classes
Originally Posted by sotoasty
Is "ClassX" the name of a public class in the .DLL?
If so, what is the "NameSpace" of the .dll?
In your "Using", it needs to be the NameSpace. Then you will need to initialize your class.
"ClassX" is the name of the namespace of the library.I've just tried putting
Code:
Using ClassX.ClassY
, where ClassY is the actual class i'm interested in using and it's still failing.
-
July 5th, 2012, 12:27 PM
#4
Re: Referencing Classes
Could you post the top several lines of your "ClassY" code. Including the namespace and the Class declaration?
-
July 5th, 2012, 12:45 PM
#5
Re: Referencing Classes
Originally Posted by sotoasty
Could you post the top several lines of your "ClassY" code. Including the namespace and the Class declaration?
ClassY
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Complex_Numbers
{
class Complex : IEquatable<Complex>
ClassX
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Deployment;
using Complex_Numbers;
namespace Control_System
{
-
July 5th, 2012, 02:27 PM
#6
Re: Referencing Classes
Have you tried
"public class Complex"
-
July 5th, 2012, 04:25 PM
#7
Re: Referencing Classes
Originally Posted by sotoasty
Have you tried
"public class Complex"
It worked!!! Thank you very much!!! I can't believe it was just an easy fix.
-
July 5th, 2012, 08:41 PM
#8
Re: Referencing Classes
Originally Posted by KillaKem
It worked!!! Thank you very much!!! I can't believe it was just an easy fix.
It worked because a class needs to be marked as public in order to be accessed outside its assembly.
If you use that class inside an assembly, you can do so with it marked as public, private, or internal. Btw, declaring "class Complex" is the same as declaring "private class Complex".
If you need to access a class or other entity from a different assembly, then you need to mark it as public.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|