我正在尝试将Unity包添加到我的解决方案中,但我一直收到列出的消息:
试图解决依赖'Unity(≥3.5.1404.0)'.
'Unity'已经为'CommonServiceLocator'定义了依赖关系.
任何想法如何解决这个问题?
我正在使用TFS和Visual Studio 2013.每当我们使用的包有变化时,TFS会尝试将这些二进制文件添加到Source Control.如果你不注意,你会检查大量的二进制文件.另一方面,如果排除这些,您将在整个地方拥有大量被排除的项目 - 这些项目将显示在待处理的签到视图中.
我尝试将.tfignore文件添加到存储库的根目录:
######################################
# Ignore all files in the packages sub-folder
\packages
packages\
\packages\
Run Code Online (Sandbox Code Playgroud)
......没有效果.在每个工作区中重新删除打包的文件夹只是让人讨厌.
有没有办法配置TFS/VS或其他什么来忽略这些文件夹?必须有一个,因为/ bin,/ obj等也被忽略了.
我有以下场景:
我的主应用程序(APP1)启动一个进程(SERVER1).SERVER1通过命名管道承载WCF服务.我想连接到这个服务(从APP1),但有时它还没有准备好.
我创建了ChannelFactory,打开它并让它生成一个客户端.如果我现在在生成的客户端上调用一个方法,我会收到一个excpetion whitch告诉我没有找到Enpoint:
var factory = new ChannelFactory<T>(new NetNamedPipeBinding(), new EndpointAddress("net.pipe//localhost/myservice");
factory.Open()
var Client = factory.CreateChannel();
Client.Foo();
Run Code Online (Sandbox Code Playgroud)
如果我在拨打电话前等一下,一切都很好;
var Client = factory.CreateChannel();
Thread.Sleep(2000);
Client.Foo();
Run Code Online (Sandbox Code Playgroud)
如何确保服务准备就绪而无需等待一段随机时间?
我试图在同一台机器上运行多个WCF服务托管应用程序.
我想在一个应用程序中运行多个应用程序 - 而不是多个服务.
var host = new ServiceHost(typeof(MyClass1), new Uri[] { new Uri("net.pipe://localhost") });
host.AddServiceEndpoint(typeof(ISomeInterface), new NetNamedPipeBinding(), "FOO");
host.Open();
Run Code Online (Sandbox Code Playgroud)
我为每个应用程序更改"FOO",但仍无法启动多个服务.猜猜它很简单,但我卡住了:(
问候
我对自定义依赖属性疯狂.我已在这里检查了大量的线程,但还没有找到任何解决方案.我想要做的是,如果源提供特定值(对于给定示例为null),则替换Property的值.无论我尝试什么,源中的属性值都保持为null并且永远不会更新.
这是我的自定义控件:
public class TextBoxEx : TextBox
{
public TextBoxEx()
{
TrueValue = 0;
this.TextChanged += (s, e) =>
{
TrueValue = Text.Length;
SetCurrentValue(MyPropertyProperty, TrueValue);
var x = BindingOperations.GetBindingExpression(this, MyPropertyProperty);
if (x != null)
{
x.UpdateSource();
}
};
}
public int? TrueValue { get; set; }
public int? MyProperty
{
get { return (int?)GetValue(MyPropertyProperty); }
set { SetValue(MyPropertyProperty, value); }
}
public static readonly DependencyProperty MyPropertyProperty =
DependencyProperty.Register("MyProperty", typeof(int?), typeof(TextBoxEx), new PropertyMetadata(null, PropertyChangedCallback));
private static void PropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) …Run Code Online (Sandbox Code Playgroud) 我使用EF与SQL Server数据库.我Instead Of Insert为该视图创建了一个视图和触发器,如下所示:
insert into Target (value, someFk)
select value, 4 from inserted
select id from Target where @@ROWCOUNT > 0 and id = scope_identity()
Run Code Online (Sandbox Code Playgroud)
我将视图映射到EF edmx.当我尝试添加实体时,我在调用时遇到以下异常SaveChanges():
无法更新EntitySet'TargetView',因为它具有DefiningQuery,并且元素中不存在支持当前操作的元素.
视图在映射中标记了标识列.
有什么建议?
我刚开始使用企业库的v5,似乎遇到了一些奇怪的问题.通常我开始使用日志记录.我刚刚添加了所需的引用并执行以下代码:
Logger.Write("test");
Run Code Online (Sandbox Code Playgroud)
到目前为止没什么特别的.检查输出我发现了一个非常奇怪的问题; 当第一次调用代码并加载所有必需的库时,似乎有例外......
A first chance exception of type 'System.Threading.SynchronizationLockException' occurred in Microsoft.Practices.Unity.dll
A first chance exception of type 'System.Threading.SynchronizationLockException' occurred in Microsoft.Practices.Unity.dll
Run Code Online (Sandbox Code Playgroud)
由于我在打开cought异常时工作,这非常烦人.知道它是什么或如何摆脱它?
此外,我想添加一个Trace Listener来打印所有登录VS输出.但似乎"System Diagnostings Trace Listener"不支持格式化程序,这会导致输出泛滥.我是否仍然需要编写自定义侦听器(就像我以前在v3中所做的那样)来完成这个非常基本的任务?
.net logging enterprise-library exception enterprise-library-5
简单的问题:
我的代码如下所示:
var con = new OracleConnection("Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=172.20.10.8)(PORT=1521))(CONNECT_DATA=(SID=orcl12c)));");
con.Open();
var adp = new OracleDataAdapter("select * from adr;select * from person;", con);
var ds = new DataSet();
adp.Fill(ds);
Run Code Online (Sandbox Code Playgroud)
现在我希望在 DataSet 中得到两个表,但我宁愿得到一个异常,告诉我 SQL 语法不正确......似乎; 不被认可的方式..?有任何想法吗?
编辑 #1:同时添加BEGIN+END;不起作用(多种变体)
编辑#2:用立即执行包装选择将运行,但不会返回结果集。
解决方案:将提供的答案与将 Dapper 与 Oracle 存储过程结合使用,返回游标并享受。
我使用XMLSpy使用以下XSLT:
<?xml version="1.0" encoding="UTF-16"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:output method="xml" version="1.0" encoding="UTF-16" indent="yes"/>
<xsl:template match="*">
<xsl:element name="{lower-case(local-name())}">
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="* | text()"/>
</xsl:element>
</xsl:template>
<xsl:template match="@*">
<xsl:attribute name="{lower-case(local-name())}"><xsl:value-of select="."/></xsl:attribute>
</xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)
如果我尝试在我的源代码中使用它(XslCompiledTransform),我会得到一个异常,告诉我函数'lower-case()'不是XSLT synthax的一部分.
所以我改变了一点转变:
fn:lower-case
Run Code Online (Sandbox Code Playgroud)
现在我的例外是找不到以'http://www.w3.org/2005/xpath-functions'为前缀的脚本或外部对象.这件事怎么回事?我该如何解决?
问候
我使用以下类使用log4net打印出消息:
public class Message
{
public String Text { get; set; }
public int Id { get; set; }
public override string ToString()
{
return Text;
}
}
Run Code Online (Sandbox Code Playgroud)
我使用Logger.Info(MessageInstance),因此log4net只是调用该ToString方法并打印出消息。我也想记录Id消息对象的属性,但是我不知道该如何实现。
我的转换模式与此类似:
<conversionPattern value="%date %-5level %message%newline" />
Run Code Online (Sandbox Code Playgroud)
我尝试添加,%message{Id}但这只会将整个消息打印两次。
有什么建议么?