Tag: service

当类在Service Project中时,Moq会在不可覆盖的成员上抛出无效设置

我正在尝试对这个类ServizioController进行unit testing: public class ServizioController : IServizioController { public virtual void PerformAction(Super.Core.Servizio servizio) { } public virtual bool Start() { throw new NotImplementedException(); } public virtual bool Stop() { throw new NotImplementedException(); } public virtual bool Continue() { throw new NotImplementedException(); } } 如果这个类是测试或库项目的一部分,那就没问题了。 但是当它在服务项目中时,Moq正在向我抛出这个错误: Invalid setup on a non-overridable member: x => x.Start() 我的测试看起来像这样: […]

Windows服务在启动期间失败的正确方法是什么

我需要我的服务来检查某些文件在启动期间的存在和结构,如果不满足某些条件则退出/失败/停止。 我读了这个post: Windows服务失败的正确方法是什么? 但它没有帮助。 我将ServiceBase.ExitCode属性设置为非零,然后调用ServiceBase.Stop。 但我得到5个事件日志条目。 见下文: Starting service. (I log this event via code) Config.xml file not found. (I log this ERROR event via code) Service stopped successfully. (SCM logs this message) Service started successfully. (SCM logs this message) Service cannot be started. The handle is invalid (SCM logs this message) 正如你所看到的,除了最后两个条目外一切正常。 他们为什么在那里? 如何在启动期间正确关闭服务? […]

将.NET类库(主要定义CRUD操作)公开为服务

将现有(类)库 (主要定义CRUD操作)作为服务 ( WCF服务或WCF数据服务 )公开的最佳,有效和最快的方法是什么,以便它可以与Silverlight或Ajax一起使用。 是否有工具 (代码生成器,RAD工具)可以支持这个? 在此先感谢您的帮助和提示。

如何使WCF接口使用服务中声明的变量

我最近在这里遵循了MSDN教程,以便使用WCF进行服务。 我现在关心的是如何访问CalculatorWindowService从CalculatorService声明的变量,以便我可以修改它的值以供以后在CalculatorWindowService使用。例如,如果我在Add,Subtract,Divide和Multiply的方法中,如果我还想要存储结果到List DoubleList声明的List DoubleList using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ComponentModel; using System.ServiceModel; using System.ServiceProcess; using System.Configuration; using System.Configuration.Install; namespace Microsoft.ServiceModel.Samples { // Define a service contract. [ServiceContract(Namespace = “http://Microsoft.ServiceModel.Samples”)] public interface ICalculator { [OperationContract] double Add(double n1, double n2); [OperationContract] double Subtract(double n1, double n2); [OperationContract] double Multiply(double n1, double n2); […]

C#:Services访问运行sql语句的dataprovider类 – 正确的方法?

这是一种常见的和/或好的方法吗? 在我的ViewModel(Wpf)或Presenter(WinForms)中,我这样做: ICustomerService customerService = MyService.GetService(); ICustomerList customerList = customerService.GetCustomers(); CustomerService类如下所示: public class CustomerService : ICustomerService { public ICustomerList GetCustomers() { return _customerDataProvider.GetCustomers(); } } public class CustomerDataProvider() { public ICustomerList GetCustomers() { // Open SQL connection, // get back a SqlDataReader and iterate it // in the loop write all data into a ICustomer […]

当InstanceContextMode设置为PerSession时,如何为所有客户端运行一次WCF服务构造函数?

当ServiceBehaviorAttribute.InstanceContextMode设置为PerSession如何仅在WCF服务的构造函数中运行一次代码? [ServiceBehavior( InstanceContextMode = InstanceContextMode.PerSession, ConcurrencyMode = ConcurrencyMode.Single)] public class SomeService : ISomeService { public SomeService() { this.RunThisOnceForAllClients(); } private void RunThisOnceForAllClients() { } } 或者,如何在WCF服务运行后自动运行方法,但是对于所有客户端调用它只会运行一次 ? 请帮忙。 提前致谢。 我使用托管Windows服务部署我的WCF 服务 。 我的代码是在C#中。 框架在.NET 4中。项目是在Visual Stuido 2010 Professional中构建的。 该服务由Windows窗体应用程序使用。 如果你想知道为什么我需要像这样做,我需要执行一个 Uploader 方法,将服务的数据库上传到另一个服务,但它将在一定时间内执行,所以我把它放在另一个线程只要服务正在运行,它就会一直运行。

FilterGetMessage是错误的?

我正在编写Windows服务与minifilter(内核)进行通信。 在minifilter中使用FltSendMessage 在服务中使用FilterGetMessage FilterGetMessage的状态为success(status = 0)。 但缓冲区始终为空。 什么是不正确的? 这是我在minifilter中的代码:C ++代码 status = FltSendMessage( gFilterHandle, &gClientPort, (PVOID)FltObjects->FileObject->FileName.Buffer, FltObjects->FileObject->FileName.MaximumLength, NULL, NULL, NULL); p / s:上面的代码放在PreCreate回调中 这是我的服务代码:C#代码 // Constant buffer size public const int BUFFER_SIZE = 1024; // message header struct [StructLayout(LayoutKind.Sequential)] public struct FILTER_MESSAGE_HEADER { public uint replyLength; public ulong messageId; } // message receive struct public […]

使用带有Microsoft Dynamics CRM 2013联机插件的Web服务

我在连接到用于MS Dynamics 2013插件的Web服务时遇到问题(在沙箱模式下运行,因为它在MS托管的在线版本上,而不是内部版本) 我面临的问题是,我似乎无法连接到我需要用来实现我正在尝试做的事情的Web服务。 我最初在app.config中有了web服务绑定,但我很快就知道app.config在这种情况下是无关紧要的(?),所以我继续在代码中创建绑定。 这是我提出的代码: BasicHttpBinding myBinding = new BasicHttpBinding(); myBinding.Name = “BasicHttpBinding_IClientSearch”; myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None; myBinding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None; myBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName; myBinding.MaxBufferSize = 524288; myBinding.MaxBufferPoolSize = 524288; myBinding.MaxReceivedMessageSize = 524288; myBinding.ReaderQuotas.MaxDepth = 32; myBinding.ReaderQuotas.MaxArrayLength = 524288; myBinding.ReaderQuotas.MaxStringContentLength = 524288; myBinding.Security.Mode = BasicHttpSecurityMode.TransportWithMessageCredential; EndpointAddress endPointAddress = new EndpointAddress(EndPointURL); ClientSearchService.ClientSearchClient myClient = new ClientSearchService.ClientSearchClient(myBinding, endPointAddress); […]

无法从Exchange Web服务检索资源(会议室)

我很难过。 我正在使用Exchange Web服务从我公司的本地日历和其他日历中检索日历信息,但“.Resources”始终为空。 我们使用Resources来存储会议室信息。 有趣的是,即使“.RequiredAttendees”也是空的,但我可以毫无问题地从“.DisplayTo”和“.DisplayCc”中检索值。 有什么建议? 我在下方附上了一个应付片段以供参考。 CalendarView calendarView = new CalendarView(startDate, endDate); Mailbox mailbox = new Mailbox(mailboxSMTP); FolderId calendarFolder = new FolderId(WellKnownFolderName.Calendar, mailbox); FindItemsResults findResults = service.FindAppointments(calendarFolder, calendarView); foreach (Appointment appointment in findResults.Items) {// foreach 1 … 谢谢,格雷格

从服务运行msiexec(本地系统帐户)

我们正在为我们的软件开发更新系统。 更新程序应作为服务在后台运行,并且当有可用更新时,请下载并安装它。 我们需要服务来安装更新,因为MSI需要提升才能运行,但我们的一些客户端将是受限用户。 MSI是WiX MSI,运行时进行重大升级。 问题是,从我们的服务运行时,更新似乎不起作用。 我可以看到msiexec运行,并且它成功返回,但它似乎没有对系统进行任何更改。 从我的用户帐户运行时,相同的命令按预期工作。 从本地系统服务运行msiexec有一些警告吗? 我们只是在做: string arguments = “/i /quiet /lv*x ” + pathToLogFile; System.Diagnostics.Process.Start(“msiexec.exe”, arguments);