我有一个使用netTcpBinding和回调方法的主机/客户端WCF服务和客户端.
<bindings>
<netTcpBinding>
<binding name="tcp_Unsecured" receiveTimeout="00:01:00" sendTimeout="00:01:00">
<security mode="None" />
<reliableSession enabled="true" ordered="true" inactivityTimeout="00:10:00"/>
</binding>
</netTcpBinding>
</bindings>
Run Code Online (Sandbox Code Playgroud)
代理
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(Namespace="http://dotnetaddict.dotnetdevelopersjournal.com/wcf.samples", ConfigurationName="AlarmServer", CallbackContract=typeof(AlarmServerCallback), SessionMode=System.ServiceModel.SessionMode.Required)]
public interface AlarmServer
{
[System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://dotnetaddict.dotnetdevelopersjournal.com/wcf.samples/AlarmServer/RegisterAlarm")]
void RegisterAlarm(System.DateTime alarmTime, string clientName, string reminderMessage);
[System.ServiceModel.OperationContractAttribute(IsOneWay = true, Action = "http://dotnetaddict.dotnetdevelopersjournal.com/wcf.samples/AlarmServer/unRegisterAlarm")]
void unRegisterAlarm(string clientName);
[System.ServiceModel.OperationContractAttribute(IsOneWay = true, Action = "http://dotnetaddict.dotnetdevelopersjournal.com/wcf.samples/AlarmServer/broadcastMessage")]
void broadcastMessage(string msg);
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
public interface AlarmServerCallback
{
[System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://dotnetaddict.dotnetdevelopersjournal.com/wcf.samples/AlarmServer/SignalAlarm")]
void SignalAlarm(string reminderMessage);
[System.ServiceModel.OperationContractAttribute(IsOneWay = true, Action = "http://dotnetaddict.dotnetdevelopersjournal.com/wcf.samples/AlarmServer/displayMessage")]
void displayMessage(string msg);
}
Run Code Online (Sandbox Code Playgroud)
带回调的客户端实例
public MainForm() …Run Code Online (Sandbox Code Playgroud) 我有数据库存档C:\Users\Pawel\Documents\DB.sdf.我该如何连接它?
下面的简单代码不起作用并生成异常.
码:
[WebMethod]
public String TestCon()
{
SqlConnection sql = new System.Data.SqlClient.SqlConnection(
@"Data Source=C:\Users\Pawel\Documents\DB.sdf");
string str = "OK";
try
{
sql.Open();
sql.Close();
}
catch (Exception ex)
{
str = ex.Message;
}
return str;
}
Run Code Online (Sandbox Code Playgroud)
结果:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network …
我正在为最新版本的 WordPress 设置多站点。当我更新它时,我有两三个插件都搞砸了,我必须手动删除文件和数据库信息,因为 WordPress 中的删除功能不起作用。在 SQL 数据库中哪里可以找到插件数据,其中一个插件有自己的表,我已删除了该表,但其他插件没有。
我遇到的问题是面板的大小为 200x200 像素。对于我正在编写的程序,在任何给定的时间我都需要知道这个面板有多大,但是随着 AutoScroll 开启并且当插入大量内容时面板会展开(并获得滚动条),这变得很困难。
我看过一些 AutoScrollPosition 和 AutoScrollOffset,甚至尝试在我的解决方案中实现它 - 但它似乎只在滚动条处于某个位置时告诉你关于面板的信息 - 而在任何给定的时间我需要知道面板的总大小。
所以基本上,假设一些内容进入面板并考虑到滚动距离,它真的变成了一个 600x750 像素的面板。有谁知道我可以实际获得这些信息的任何方式?
谢谢
我有一个树视图,我需要将所选节点的字体设置为粗体..如果节点没有任何子节点,它可以正常工作.但是如果选择了具有子节点的节点,则子节点也显示为粗体.
使用以下XAML:
<TreeView.ItemContainerStyle>
<Style TargetType="TreeViewItem">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="FontWeight" Value="Bold"></Setter>
</Trigger>
</Style.Triggers>
</Style>
</TreeView.ItemContainerStyle>
Run Code Online (Sandbox Code Playgroud) 我正在使用Visual Studio 2010和WPF.
我正在创建一个继承自ContentControl的新Control,我想隐藏Content属性,以便在设计时它在Properties窗口中不可见.
我试过了
[Browsable(false)]
Run Code Online (Sandbox Code Playgroud)
就像我们在WinForms中所做的一样,但它不起作用.
有关如何解决这个问题的任何想法?
谢谢.
我使用此源代码生成随机密码:
public string GetRandomPasswordUsingGUID(int length)
{
// Get the GUID
string guidResult = System.Guid.NewGuid().ToString();
// Remove the hyphens
guidResult = guidResult.Replace("-", string.Empty);
// Make sure length is valid
if (length <= 0 || length > guidResult.Length)
throw new ArgumentException("Length must be between 1 and " + guidResult.Length);
// Return the first length bytes
return guidResult.Substring(0, length).ToUpper();
}
Run Code Online (Sandbox Code Playgroud)
它在调用方法时工作正常,但不在"for"循环语句中.
在这种情况下,它会生成一些错误的重复密码.
例如像这样:
A4MNB597D7
AMGJCCC902
AWJ80CF6HX
A78EDJECIW
A78EDJECIW
A78EDJECIW
A78EDJECIW
A78EDJECIW
A2LYJCH23N
A2LYJCH23N
Run Code Online (Sandbox Code Playgroud)
如何在"For"循环语句中创建随机密码?
尝试这样做时:
setTimeout(function(){alert("Boo");}, 500);
Run Code Online (Sandbox Code Playgroud)
我不小心写了这个:
setTimeout(new function(){alert("Boo");}, 500);
Run Code Online (Sandbox Code Playgroud)
前版本等待500毫秒,然后发出警报.后者立即发出警报.
为什么new在函数前面添加会导致此行为?
请查看以下代码段.我在"this.directories.Add(new directory(s));"中遇到了nullreferenceexception.递归似乎一直有效,直到它"解开",此时"新目录"似乎是空的.我不确定它为什么会这样表现,我想也许有特殊的规则,因为递归是在构造函数中.请帮忙.
namespace AnalyzeDir
{
class directory
{
public string[] files;
public ArrayList directories;
public string mypath;
public string myname;
public directory(string mp)
{
mypath = mp;
myname = mypath.Substring(mypath.LastIndexOf("\\"));
files = Directory.GetFiles(mypath);
fillDirectoriesRescursive();
}
public void fillDirectoriesRescursive()
{
string[] dirpaths = Directory.GetDirectories(mypath);
if (dirpaths != null && (dirpaths.Length > 0))
{
foreach(string s in dirpaths)
{
this.directories.Add(new directory(s));
}
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个问题:
SELECT * FROM msc_calendar WHERE calendar_userId = 1 AND end < UNIX_TIMESTAMP()
Run Code Online (Sandbox Code Playgroud)
有没有办法从时间戳中减去一周,即查看是否end超过一周前?