我在解决方案中有一个SQL Server项目.我直接在SQL Server Management Studio中对数据库进行了一些更新,我想在Visual Studio中更新SQL Server项目以匹配数据库的模式.在Visual Studio中,当我选择"比较架构"并选择数据库作为源和项目目录作为目标,然后单击"比较"时,比较结果将显示在屏幕上,但随后Visual Studio立即崩溃.我正在运行安装了Update 2的Visual Studio 2015 Professional,并且我有Microsoft SQL Server数据工具2015.以下详细信息显示在事件查看器中:
Application: devenv.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: Microsoft.VisualStudio.Composition.CompositionFailedException
at Microsoft.VisualStudio.Composition.ExportProvider.GetExports(Microsoft.VisualStudio.Composition.ImportDefinition)
at Microsoft.VisualStudio.Composition.ExportProvider.GetExports[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.String, Microsoft.VisualStudio.Composition.ImportCardinality)
at Microsoft.VisualStudio.Composition.ExportProvider.GetExport[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.String)
at Microsoft.VisualStudio.Composition.ExportProvider.GetExport[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.String)
at Microsoft.VisualStudio.Composition.ExportProvider.GetExport[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]()
at Microsoft.VisualStudio.Composition.ExportProvider.GetExportedValue[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]()
at Microsoft.VisualStudio.ComponentModelHost.ComponentModel.GetService[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]() …Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的.NET Core测试程序集中使用NUnit3.ConsoleRunner版本3.70 NuGet包.我已经安装了NuGet包,发现它在这个位置:
%USERPROFILE%\.的NuGet \包\ NUnit.ConsoleRunner\3.7.0 \工具\nunit3,console.exe
如果我对我的.NET Core 1.1测试程序集运行该工具,如下所示:
nunit3-console.exe MyTestAssembly.dll
Run Code Online (Sandbox Code Playgroud)
我收到以下错误(来自TestResults.xml的片段):
<failure>
<message><![CDATA[An exception occurred in the driver while loading tests.]]></message>
<stack-trace><![CDATA[
Server stack trace:
at NUnit.Engine.Runners.DirectTestRunner.LoadDriver(IFrameworkDriver driver, String testFile, TestPackage subPackage)
at NUnit.Engine.Runners.DirectTestRunner.LoadPackage()
at NUnit.Engine.Runners.DirectTestRunner.EnsurePackageIsLoaded()
at NUnit.Engine.Runners.DirectTestRunner.RunTests(ITestEventListener listener, TestFilter filter)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at NUnit.Engine.ITestEngineRunner.Run(ITestEventListener listener, TestFilter filter)
at NUnit.Engine.Runners.ProcessRunner.RunTests(ITestEventListener listener, TestFilter filter)]]></stack-trace>
</failure> …Run Code Online (Sandbox Code Playgroud) 所以我试图使用PowerShell对文件顶部的C#"using"语句进行排序.对于给定的输入文件File.cs,using语句如下所示:
using System.Reflection;
using System.Configuration;
using System.Runtime.Caching;
using System.Linq;
using System;
Run Code Online (Sandbox Code Playgroud)
我希望输出"使用System"作为第一个"使用",但实际上Sort-Object将它排序到底部.如何更改此选项以排序到列表顶部?
function Update-UsingStatements
{
param (
[Parameter(Mandatory=$true)][string]$FilePath
)
$fileLines = Get-Content $FilePath
$contents = $fileLines | Out-String
$list = New-Object 'System.Collections.Generic.List[string]'
$contents | Select-String -pattern 'using\s[\w\.]+;' -AllMatches | ForEach-Object {$_.Matches} | ForEach-Object { $list.Add($_.Value) }
$list = $list | Sort-Object
for ($i = 0; $i -lt $list.Count; $i++)
{
$fileLines[$i] = $list[$i]
}
$fileLines | Out-File $FilePath -Encoding utf8
}
Run Code Online (Sandbox Code Playgroud) NHibernate 3或4是否具有与Entity Framework的“包含”方法等效的方法,该方法采用字符串参数而不是llambda?我想在NHibernate中做这样的事情:
Contact contact =
context.Contacts.Include("SalesOrderHeaders.SalesOrderDetails")
.FirstOrDefault();
Run Code Online (Sandbox Code Playgroud)
我从这篇文章中看到了这段代码,该代码在一个很酷的循环中使用“获取”,但这仅处理作为主要对象的第一级子对象的对象,而上述EF代码下降了2级,而无需非常严格地-键入lambdas。
public IQueryable<T> All<T>(params Expression<Func<T, Object>> [] fetchPaths)
{
var queryable = this.session.Query<T>();
foreach (var fetchPath in fetchPaths)
{
queryable = queryable.Fetch(fetchPath);
}
return queryable;
}
Run Code Online (Sandbox Code Playgroud) 我有一个环境,我只有一个应用服务器.我有一些消息需要一段时间来服务(比如10秒左右),我想通过配置运行代码的消费者应用程序的多个实例来处理这些消息来增加吞吐量.我已经读过"竞争消费者"模式,并认为在使用MassTransit时应该避免这种情况.根据此处的MassTransit文档,每个接收端点应具有唯一的队列名称.我很难理解如何将此建议映射到我的环境. 是否有可能让N个消费者实例运行,每个实例都接收相同的消息,但实际上只有一个实例会对其进行操作? 换句话说,我们可以实现"竞争消费者"模式,但是跨多个队列而不是一个队列?
或者我看错了吗?我是否真的需要查看"发送"方法而不是"发布"?"发送"的缺点是它要求发送者直接了解端点的存在,并且我希望我拥有的消费者/端点的数量是动态的.MassTransit内置了什么可以帮助跟踪有多少消费者实例/队列/端点可以为特定消息类型提供服务?
谢谢,安迪
如何在PowerShell中添加JSON数组?我正在尝试使用以下代码,但它抱怨"集合是固定大小的"异常:
$json = @"
[
{
"name": "First"
},
{
"name": "Second"
}
]
"@
$toAdd =@"
{
"name": "Third"
}
"@
$jobj = ConvertFrom-Json -InputObject $json
$jobj.Add((ConvertFrom-Json -InputObject $toAdd))
Run Code Online (Sandbox Code Playgroud) c# ×3
powershell ×2
.net-core ×1
json ×1
linq ×1
masstransit ×1
nhibernate ×1
sorting ×1
unit-testing ×1