以编程方式创建WCF服务应用程序

时间:2013-06-07 07:42:18

标签: .net wcf

如何使用控制台应用程序以编程方式创建空(示例)WCF应用程序。

我知道我们可以使用以下方法来做到这一点:

System.Type t = System.Type.GetTypeFromProgID("VisualStudio.DTE.9.0");
object obj    = Activator.CreateInstance(t, true);

但是,我需要更多细节。

1 个答案:

答案 0 :(得分:0)

改编自我的一个UnitTests

            var binding = new HttpBinding();
            var serviceAddress = new Uri("http://localhost/someservicepath")
            var host = new ServiceHost(typeof(TestService), serviceAddress));
            host.AddServiceEndpoint(typeof(ITestService), binding, serviceAddress);
            host.Open();
            //do stuff
            host.Close();
            host.Dispose();
相关问题