I am trying to use the WCF in my Unity project, therefore I need to reference dll System.ServiceModel
. Also, these are some more info on my environment:
- Unity 2018.1.5f1 Personal (64bit)
- Windows 10 (64bit)
Using msc.rsp
Following the Unity doc on loading external assemblies, I have created the msc.rsp
file inside my Assets/
directory:
-r:System.ServiceModel.dll
In my Assets/
folder I also have a C# file which needs the WCF:
using System;
using System.ServiceModel;
using System.ServiceModel.Description;
public class CommunicationEndpoint {
private const short Port = 8000;
private ServiceHost host;
public void Start() {
this.EnsureInitilized();
host.Open();
}
public void Stop() {
if (this.host != null) return;
host.Close();
}
private void EnsureInitilized() {
if (this.host != null) return;
this.host = new ServiceHost(typeof(CommunicationService));
host.AddServiceEndpoint(typeof(ICommunicationService), new BasicHttpBinding(), Address);
host.Open();
}
private string Address {
get { return "http://localhost:" + Port; }
}
}
There is another file where interface ICommunicationService
is defined, still part of the assets inside Assets/
. Did not report here as it is not that useful.
Still compile errors
Basically, nothing happens in Unity: I still get errors at compile time where clearly the assembly was not loaded at all.
Note I have also re-imported all by right-clicking on the Assets
pane in Unity and clicking on Reimport All
to make sure the C# project gets regenerated. I can see it is regenerated, but still nothing changes: same issues.
What am I doing wrong?