?
Solved

Accessing methods in different C# solutions

Posted on 2014-09-29
5
Medium Priority
?
143 Views
Last Modified: 2014-10-03
We have a situation were we are developing an NT Service application in C# that will need to run various methods contained in a separate MVC 4.0 application.   These methods can be in a controller or simply in a C# class.

What is the best way for the separate C# program to call other C# program's methods but are not in the same solution?

We are looking at having the methods in their own .DLL or maybe adding a web service to the MVC application.

Any ideas on what would work best?
0
Comment
Question by:jkanisut
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 34

Expert Comment

by:it_saige
ID: 40351035
You hit it right on the head.

Having multiple projects simply requires a reference from Project B into Project A.

I.E. (Untested)
ProjectA
using System;
using ProjectB;

namespace ProjectA
{
	public class ProjectAClass
	{
		public void ShowProjectB()
		{
			ProjectBClass bClass = new ProjectBClass();
			Console.WriteLine(bClass.ShowProjectB());
		}
	}
}

Open in new window

ProjectB
using System;

namespace ProjectB
{
	public class ProjectBClass
	{
		public string ShowProjectB()
		{
			return "Saying hello from Project B";
		}
	}
}

Open in new window


-saige-
0
 
LVL 1

Author Comment

by:jkanisut
ID: 40351043
But these will be different / separate solutions...
0
 
LVL 34

Expert Comment

by:it_saige
ID: 40351051
Yes.  Here is a more complete example:

stackoverflow.com/questions/3554658/how-to-use-a-class-from-one-c-sharp-project-with-another-c-sharp-project

A solution is nothing more than a group of one or more projects.  Using multiple solutions does not prevent you from accessing members cross solution or even cross solution; cross project.

-saige-
0
 
LVL 34

Accepted Solution

by:
it_saige earned 2000 total points
ID: 40351063
More information regarding referencing projects from other solutions:

stackoverflow.com/questions/9568094/how-should-i-reference-assemblies-from-another-solution

Quite simply, once you build one projects output.  You add a reference to the project output via browsing for the output file.  The rules with regards to assembly resolution apply:

http://msdn.microsoft.com/en-us/library/yx7xezcf(v=vs.110).aspx

-saige-
0
 
LVL 1

Author Closing Comment

by:jkanisut
ID: 40360779
Thanks for pointing me in the right direction.
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show, step by step, how to integrate R code into a R Sweave document
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question