How to access a namespace that is part of another project?

I have two C # .net 1 project projects and project 2 (names changed) in one solution. I am using Visual Studio 2005. I added the project 2 link to project 1 by right-clicking and selecting “Add Link”. Both projects have a project type of Application, not a class library type. I have some classes in project 2, which I want to access in project 1. After adding the link, I tried to use the import namespace of project 2 in project 1, but I think it is not available. Intelisense Visual Studio does not show me the desired namespace. Can anyone suggest how to access the namespace and classes in multiple projects?

EDIT: - Is it because there are different assemblies for both projects?

thank

+3
source share
2 answers

Make sure the classes you want to access are publicly available. Suppose you have the following class in Project 2:

namespace Project2
{
    public class Foo { }
}

In Project 1, after referencing Project 2, you can use this class:

namespace Project1
{
    using Project2;

    public class Bar
    {
        public Bar()
        {
            Foo foo = new Foo();
        }
    }
}
+1
source

Importis the term Visual Basic.NET. In C # you have to use using.

0
source

Source: https://habr.com/ru/post/1756885/


All Articles