-2

Okay I have a class clsA in project A. I want to use static methods of clsA in project B.

I have tried to call these static functions by using the classname i.e clsA.function() in project B. But it's throwing error "The name clsA does not exists in the current context"

how do I solve this? Do I need to reference the class in project or something? If so then how to do it?

riser101
  • 610
  • 6
  • 23
  • 1
    Yes, you need a reference from project B to project A, then you will probably need a `using` directive to import the namespace containing `clasA`. – Jon Skeet Oct 30 '15 at 16:14

1 Answers1

1

You need to compile projectA and then add that dll as a reference to project B. You also need to add the namespace to the top of clsB.

John Paul
  • 827
  • 2
  • 6
  • 16
  • One: there is no namespace defined in clsA. Two:How do I find out the dll name that corresponds to clsA?. – riser101 Oct 30 '15 at 16:19
  • @user3452275: If you'd provided a short but complete example of all of this, we wouldn't have to guess... but if `clsA` isn't declared in a namespace (which it should be for any production code) then you won't need a using directive. – Jon Skeet Oct 30 '15 at 16:22
  • Dll goes in the bin directory after you compile it. Bin directory is located under project dir. Right click the project in vs and then click open folder in file explorer. Bin should be there which will have your dll. – John Paul Oct 30 '15 at 16:23
  • @john Paul Yes, but how can I figure out which dll to use? – riser101 Oct 30 '15 at 16:28
  • Project A assembly name is located in the application portion of the project properties. – John Paul Oct 30 '15 at 16:30
  • Would you please elaborate a lilttle bit? – riser101 Oct 30 '15 at 16:47