一旦我的程序安装在客户端计算机上,如何强制我的程序在Windows 7上以管理员身份运行?
我是WCF的初学者,但试图改善我的经验.在第一步,我遇到了问题.我创建了最简单的WCF服务.代码清单:(所有代码都在一个文件中)
using System;
using System.ServiceModel;
namespace EssentialWCF
{
[ServiceContract]
public interface IStockService
{
[OperationContract]
double GetPrice(string ticker);
}
public class StockService : IStockService
{
public double GetPrice(string ticker)
{
return 94.85;
}
}
class Service
{
static void Main(string[] args)
{
ServiceHost serviceHost = new ServiceHost(typeof(StockService),
new Uri("http://localhost:8000/HelloWCF"));
serviceHost.AddServiceEndpoint(typeof(IStockService), new BasicHttpBinding());
serviceHost.Open();
Console.WriteLine("To continue press ENTER");
serviceHost.Close();
}
}
}
Run Code Online (Sandbox Code Playgroud)
那将是通过控制台给我一个号码的服务.但调试给我例外:(而不是数字:))
HTTP无法注册URL http:// +:8000/HelloWCF /.您的进程没有此命名空间的访问权限(有关详细信息,请参阅http://go.microsoft.com/fwlink/?LinkId=70353).
你有没有遇到过同样的情况?我很乐意看到每一条建议.
我想创建WCF Restful服务,它将Complex Type作为Json格式的参数并返回Json.我阅读了很多文章并在网上查看了很多样本.有些文章建议在Endpoint行为中添加标签并装饰Service方法,如下所示,
[WebInvoke(UriTemplate = "/PlaceOrder",
RequestFormat= WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json, Method = "POST")]
Run Code Online (Sandbox Code Playgroud)
在这种情况下,WCF返回"Endpoints using 'UriTemplate' cannot be used with 'System.ServiceModel.Description.WebScriptEnablingBehavior'."错误消息.
另一种建议的方式(如本文http://dotnetmentors.com/wcf/wcf-rest-service-to-get-or-post-json-data-and-retrieve-json-data-with-datacontract.aspx)将""标记添加到Endpoint行为而不是.但在这种情况下IIS返回("远程服务器返回错误:(400)错误请求.")错误消息.
你能帮我解决一下如何创建Restful Service,它采用json格式的复杂类型参数并返回json.