I have a class library called (service.cs).
I have WCF service both are in the same solution. Here what am trying to do, am trying to call the service class upload.uploading() method from my service contract in wcf and pass the value .
namespace MyService
{
class MyService : IServiceContract
{
public void Insert(string Name)
{
if (core == true)
{
Upload(XmlFile);
}
else
{
}
}
here is the sample class library file
namespace Service
{
class upload
{
public void Uploading(string file)
{
console.writeline(file)
}
}
}
Your example isn’t very clear, but I’m guessing you want to call the
Upload.Uploading()method that’s in a class library.The best way to do that is to create an interface, like this:
and have the external class library implement it:
Now, use this code in your main program:
What you’re doing is dynamically loading the class library (line 1), dynamically getting the type of the class in it via reflection (line 2) and creating an instance of it (line 3).
It’s important to have it implement an interface, like IUploader, which is known to the main program so it knows how to handle it, how to call its Upload() method, etc.