Click here to Skip to main content
16,012,223 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have two projects under same solution. Project A is of type Windows Application and Project B is of type Class Library.
I need to access the member of Project A via Project B.
Please let me know how can I achieve this?
and I don't want to pass the parameter from one project to another.
Posted

1 solution

You really should start with learning .NET and development basics. First of all, you need to understand that the concept of "project" is only related to development and build; during runtime, projects are not involved and do not exist. Even if you reference one project by another, after you do the build, the referenced are the resulting assemblies, not "projects".

You need to learn one of the central concepts of .NET, CLR and CLI: assembly:
http://en.wikipedia.org/wiki/Assembly_%28CLI%29[^],
http://en.wikipedia.org/wiki/Common_Language_Infrastructure[^],
http://en.wikipedia.org/wiki/Common_Language_Runtime[^],
http://msdn.microsoft.com/en-us/library/aa367757%28v=vs.85%29.aspx[^],
http://msdn.microsoft.com/en-us/library/hk5f40ct%28v=vs.90%29.aspx[^],
http://msdn.microsoft.com/en-us/library/ms173099.aspx[^],
http://msdn.microsoft.com/en-us/library/ms973231.aspx[^].

Practically, it's the best to create two projects and put the in the same solution. You can reference and assembly by the name of its main executable module ("Browse" tab in the "Add Reference" windows) but this is not the best for maintenance. The best way is to use "Projects" tab and reference one project by another. This way, the assemblies built will remain referenced even if you move/rename one or more projects, sign them, change versions, and so on.

When objects are reference, you can access all the public members of the referenced assemblies, and all their public members. There is another way, loading and using the assemblies during runtime, via reflection, and using even the non-public types and members, but this topic is way more advanced.

[EDIT #1]

And your last statement "I don't want to pass the parameter from one project to another" simply makes no sense. You will understand it if you read my answer thoroughly, especially if you read the referenced material.

[EDIT #2]

It is absolutely irrelevant, which of the referenced or referencing assemblies is "DLL" or "EXE". Assemblies are assemblies, and those PE files are just the modules of assemblies. Even though EXEs are usually not referenced because they are the main executable modules of some applications, there are some techniques where it is useful.

However, it's important not to create circular references. If you only use references and not reflection, I could not understand why would you want to reference the application assembly. If you explain that, you would probably get a change for further advice.

—SA
 
Share this answer
 
v5
Comments
Member 10102675 17-Mar-14 2:36am    
Thank you, I am a beginner .
I shall do it.
Member 10102675 17-Mar-14 2:45am    
Actually I need to access certain members of exe in dll. I have heard about Reflection but I have never used it. So thought will be there any other techniques to deal this issue.
I am not used to Assemblies or Reflection. I am learning now.
Sergey Alexandrovich Kryukov 17-Mar-14 10:02am    
Please first explain why. What do you want to achieve? Why accessing EXE types/members? Why other techniques?
—SA

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