我在我的C#winform应用程序中使用下面的行,这很好用,但偶尔如果程序是从命令行运行的,我会收到一个config.xml无法找到文件的错误.这是因为'工作目录'是不同的(我认为),我需要说"从当前目录加载config.xml",我该怎么做?
docXML.Load("config.xml");
Run Code Online (Sandbox Code Playgroud)
谢谢乔纳森
我创建了一个非常简单的 WCF 服务,托管在 Windows 服务上,严格遵循 MSDN 上的示例:http ://msdn.microsoft.com/en-us/library/ff649818.aspx
如果我在第一次调用后 10 分钟内第二次调用我的服务,我将收到不活动超时错误。据我所知,这是WCF客户端的默认设置。
但是,当我更改我的 app.config 时
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
Run Code Online (Sandbox Code Playgroud)
到
<reliableSession ordered="true" inactivityTimeout="infinite"
enabled="true" />
Run Code Online (Sandbox Code Playgroud)
当我尝试拨打电话时出现此错误:
由于 EndpointDispatcher 上的 ContractFilter 不匹配,无法在接收方处处理操作为“http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequence”的消息。这可能是因为合同不匹配(发送者和接收者之间的操作不匹配)或发送者和接收者之间的绑定/安全不匹配。检查发送方和接收方是否具有相同的合同和相同的绑定(包括安全要求,例如消息、传输、无)。
这就是我的 WCF 配置文件在 Windows 服务上的样子。
<system.serviceModel>
<services>
<service name="Asis.IBSS.Milestone.WCFService.ServiceImplementation.VideoService">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="" contract="Asis.IBSS.Milestone.WCFService.ServiceContract.IVideoService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8555/MilestoneService"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="false"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
Run Code Online (Sandbox Code Playgroud)
我的问题是,如何将 inactivityTimeout 设置为 inifinte,并避免出现错误?
我有一个KendoUI下拉列表如下:
@(Html.Kendo().DropDownList()
.Name("DeviceInterfaces")
.OptionLabel("Select interface...")
.DataTextField("Name")
.DataValueField("Id")
.DataSource(source => source.Read(read => read.Action("GetCascadeDeviceInterfaces", "EventTriggers")))
)
Run Code Online (Sandbox Code Playgroud)
这是一个级联下拉列表,如何设置用户选择的模型属性?
c# asp.net-mvc cascadingdropdown html.dropdownlistfor kendo-ui
我正在尝试创建一个客户端信号器应用程序.目前,我能够让我的MVC客户端向Hub发送消息,但是,我的.NET客户端应用程序遇到了一些困难
服务器中心代码:
namespace ServerHub
{
public class ChatterBox : Hub
{
public void Send(string message)
{
Clients.All.addMessage(message);
}
}
}
Run Code Online (Sandbox Code Playgroud)
控制台应用程序代码(几乎直接从github解除)
using Microsoft.AspNet.SignalR.Client.Hubs;
using ServerHub;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Say("hello from console");
}
public static void Say(string message)
{
//var connection = new HubConnection("http://localhost/");
//IHubProxy myHub = connection.CreateHubProxy("ChatterBox");
var connection = new HubConnection("http://localhost/");
//Make proxy to hub based on hub name on server
var myHub = connection.CreateHubProxy("ChatterBox");
//Start connection
connection.Start().ContinueWith(task =>
{
if …Run Code Online (Sandbox Code Playgroud) 我的web api中有以下方法
public class AccessPanelController : ApiController
{
public HttpResponseMessage PostGrantAccess([FromUri]GrantAccessRequest grantAccessRequest)
{
var deviceId = grantAccessRequest.DeviceId;
var grantAccessResponse = new GrantAccessResponse()
{
Status = "OK"
};
var response = Request.CreateResponse<GrantAccessResponse>(HttpStatusCode.OK, grantAccessResponse);
return response;
}
}
Run Code Online (Sandbox Code Playgroud)
GrantAccessRequest类:
public class GrantAccessRequest
{
public string DeviceId { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
客户:
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("http://localhost:55208/");
// Add an Accept header for JSON format.
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
Uri uri = null;
var request = new GrantAccessRequest { …Run Code Online (Sandbox Code Playgroud) 为什么我能够这样做:
var _channel = new ChannelFactory<T>("bindingname").CreateChannel();
Run Code Online (Sandbox Code Playgroud)
但不是这个
var _channelFactory = new ChannelFactory<T>("bindingname");
var _channel = _channelFactory.CreateChannel();
Run Code Online (Sandbox Code Playgroud)
第二个片段抱怨我需要传入EndPointAddressin CreateChannel()而第一个没有传入.
这两个片段基本上不一样吗?
我想知道,在使用实体框架时,哪一个会产生更好的性能?
我已经读过,如果你的entites之间有外来关系,那么最好使用include over join.
如果我只是从2个不同的entites(具有外键关系)检索1行,那么如果我使用include over join会有什么不同吗?
我正在取回的记录数量是否会影响join和include之间的性能?
我已经看过很多例子,展示了如何通过计时器使用RX框架运行任务,例如,
var timer = Observable
.Timer(TimeSpan.FromSeconds(3), TimeSpan.FromSeconds(3))
.Subscribe(q =>
{
Console.WriteLine("do something here " + q);
});
Run Code Online (Sandbox Code Playgroud)
我想知道是否可能,如果是的话,我如何使用RX框架按计划运行任务,例如,每天午夜12点.
我可以使用此搜索电子表格的A列中的文本
With WB.Sheets("MySheet")
Set FindRow = .Range("A:A").Find(What:="ProjTemp1", LookIn:=xlValues)
End With
Run Code Online (Sandbox Code Playgroud)
之后我可以通过这样做得到行号 FindRow.Row
然后我如何取回行号 Column A == "ProjTemp1" && Column B == "ProjTemp2" && Column C == "ProjTemp3"
我的服务层中有以下方法
public ModuleResponse GetModules(ModuleRequest request)
{
var response = new ModuleResponse(request.RequestId);
try
{
response.Modules = Mapper.ToDataTransferObjects(ModuleDao.GetModules());
return response;
}
catch (Exception ex)
{
Log.Error(ex);
response.Acknowledge = AcknowledgeType.Failure;
response.Message = "An error occured.";
return response;
}
}
Run Code Online (Sandbox Code Playgroud)
我有一个用xUnit编写的单元测试,如下所示:
[Fact]
public void GetModulesTest()
{
//Arrange
var mockModuleDao = Mock.Create<IModuleDao>();
var mockLog = Mock.Create<ILog>();
var mockAuditDao = Mock.Create<IAuditDao>();
var moduleList = new List<ModuleItem>
{
new ModuleItem {Id = 100, Category = "User Accounts", Feature = "Users"},
new ModuleItem {Id = 101, Category = …Run Code Online (Sandbox Code Playgroud) c# ×7
.net ×5
asp.net-mvc ×3
wcf ×2
app-config ×1
entity ×1
excel ×1
excel-vba ×1
join ×1
json ×1
kendo-ui ×1
mocking ×1
signalr ×1
timer ×1
unit-testing ×1
vba ×1
web-services ×1
xml ×1
xunit.net ×1