根据这篇文章,带有命名管道的WCF是IPC的最佳选择,它比.Net Remoting快25%左右.
我有以下代码将WCF与命名管道与.Net Remoting进行比较:
[ServiceContract]
internal interface IRemote
{
[OperationContract]
string Hello(string name);
}
[ServiceBehavior]
internal class Remote : MarshalByRefObject, IRemote
{
public string Hello(string name)
{
return string.Format("Hello, {0}!", name);
}
}
class Program
{
private const int Iterations = 5000;
static void Main(string[] args)
{
TestWcf(Iterations);
TestRemoting(Iterations);
TestWcf(Iterations);
TestRemoting(Iterations);
TestWcf(Iterations);
TestRemoting(Iterations);
Console.ReadKey();
}
private static void TestRemoting(int iterations)
{
var domain = AppDomain.CreateDomain("TestDomain");
var proxy =
(IRemote)
domain.CreateInstanceFromAndUnwrap(Assembly.GetEntryAssembly().Location, "ConsoleApplication6.Remote");
Console.WriteLine("Remoting: {0} ms.", Test(proxy, iterations));
}
private …Run Code Online (Sandbox Code Playgroud) 我在IIS上运行.Net 4.0 WCF服务.我没有指定端口,所以假设它在端口80上运行.我需要在已经使用端口80的服务器上安装我的服务,并且网络人员要求我将服务更改为在端口443上运行.如何操作我这样做?我猜它可以在app.config中配置,但我找不到一篇文章告诉我如何.
这是我当前的app.config:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
Run Code Online (Sandbox Code Playgroud)
我有一个datacontact,其中有许多成员都有自定义类
如果在反序列化时属性为null,我想强制一个新实例.
有没有办法做到这一点?
假设我有一个类:
public class Foo
{
public string Title {get;set;}
}
Run Code Online (Sandbox Code Playgroud)
现在,让我们假设我有一个public List<Foo> myList我想要由Linq过滤的内容:
var x = myList.Where(f => f.Title == myValue);
Run Code Online (Sandbox Code Playgroud)
到目前为止,一切都很美好.
但是如何通过变量访问属性?就像是:
string myProperty = "Title";
var x = myList.Where(f => f.myProperty == myValue);
Run Code Online (Sandbox Code Playgroud) 我需要了解如何利用ToolTip自定义UserControl.只需在表单上创建工具提示并为特定控件分配工具提示(通过SetToolTip)显然不起作用.
为了向其分配ToolTip文本,我需要提供哪些属性来自定义UserControl?我是否需要在usercontrol表单上添加工具提示?我该怎么做呢?
请提供代码示例或其他内容供我观察.
谢谢!
我目前有一个我写的程序,分为3个独立的解决方案.
要求 -
C:\projects\myProgC:\myProg我的问题是我一直在处理与项目依赖关系有关的问题,在哪里指向我的全局变量dll.我是否指向已部署的位置或开发位置,如果是,则发布或调试?
所以我开始查找不同的解决方案类型,我想知道是否应该为我的特定情况设置分区解决方案或多解决方案.
有没有办法使用函数或LINQ 更改" ABCDEFGHIJKLMNOP"到" ABCD-EFGH-IJKL-MNOP" string.format()?
我正在使用这个声明
Out= String.Format("{0}-{1}", String.Format("{0}-{1}-{2}", In.Substring(0, 4), In.Substring(4, 4), In.Substring(8, 4)), In.Substring(12, 4));
Run Code Online (Sandbox Code Playgroud)
有没有更好更清晰的方法来实现这一目标?
我有这个代码
protected void Page_Load(object sender, EventArgs e)
{
TblPrikaz.BorderWidth = 1;
XmlDocument baza = new XmlDocument();
XmlTextReader reader = new XmlTextReader(Server.MapPath("baza.xml"));
baza.Load(reader);
TableRow line = new TableRow();
TableCell id = new TableCell();
TableCell ime = new TableCell();
TableCell prezime = new TableCell();
TableCell godiste = new TableCell();
id.Text = "ID";
ime.Text = "Ime";
prezime.Text = "Prezime";
godiste.Text = "Godiste";
line.BackColor = Color.Green;
line.Cells.Add(id);
line.Cells.Add(ime);
line.Cells.Add(prezime);
line.Cells.Add(godiste);
TblPrikaz.Rows.Add(line);
XmlNodeList popis = baza.GetElementsByTagName("element");
for (int i = 0; i < popis.Count; i++) …Run Code Online (Sandbox Code Playgroud) 我有一个DetailsView约束,EntityDataSource并试图从我的TextBoxes中获取值EditItemTemplates.
这是我的代码:
<asp:DetailsView ID="DetailsView1" DataKeyNames="Name" runat="server" AutoGenerateRows="False"
OnDataBound="DetailsView_DataBound" DataSourceID="eds2" BorderWidth="0"
OnModeChanging="OnModeChanging" AutoGenerateEditButton="true"
OnItemUpdated="DetailsView_OnItemUpdated" OnItemUpdating="DetailsView_OnItemUpdating"
EmptyDataText="N/A" OnDataBinding="DetailsView_OnDataBinding" CellPadding="0"
CellSpacing="7" GridLines="None" CssClass="Center">
<Fields>
<asp:TemplateField HeaderText="Name">
<EditItemTemplate>
<asp:TextBox ID="txtName" runat="server" Text='<%# Bind("Name") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblName" runat="server" Text='<%# Bind("Name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<Fields>
</asp:DetailsView>
Run Code Online (Sandbox Code Playgroud)
而背后的代码:
protected void OnModeChanging(object sender, DetailsViewModeEventArgs e)
{
foreach (DetailsViewRow row in DetailsView1.Rows)
{
if (row.RowType != DataControlRowType.DataRow) continue;
foreach (DataControlFieldCell cell in row.Cells)
{
var textbox = cell.FindControl("txtName");
var …Run Code Online (Sandbox Code Playgroud) 任何人都可以给我任何关于如何使这个运行更快一点的指针?
return mb_entities.prospects.
FirstOrDefault(x => x.address == person.Add &&
x.homePhone == person.HPhone &&
x.bizPhone == person.BPhone &&
x.cellPhone == person.CPhone &&
x.city == person.City &&
x.state == person.State &&
x.zip == person.Zip &&
x.email == person.Email &&
x.firstName == person.FName &&
x.lastName == person.LName &&
x.middleName == person.MName &&
x.genCode == person.GC) ?? new prospect();
Run Code Online (Sandbox Code Playgroud)
现在它运行在160到180毫秒之间.如果我不必这样做1000次就没问题.
任何提示将非常感谢.谢谢!
c# ×9
wcf ×3
asp.net ×2
linq ×2
datacontract ×1
detailsview ×1
lambda ×1
named-pipes ×1
string ×1
where ×1
winforms ×1