在C#解决方案中,我添加了一个现有项目.
之后,Visual Studio在其他.csproj文件中添加了以下条目:
<ItemGroup>
<Service Include="{B4F97281-0DBD-4835-9ED8-7DFB966E87FF}" />
</ItemGroup>
Run Code Online (Sandbox Code Playgroud)
这是用来干嘛的?
我可以删除它吗?
我需要在visual studio中删除和重命名一系列解决方案/项目配置,是否有任何工具可以帮助解决这个问题?
我发现内置工具非常无用.例如,当我从解决方案中删除配置时,它将拒绝删除相关的项目配置,以防其他地方需要它们.同时重命名解决方案配置不会重命名其相关配置.
必须有更好的方法来做到这一点.还有其他替代工具吗?
我偶然发现了一个为Microsoft自己的非托管DLL生成P/Invoke签名的工具:PInvoke Interop Assistant
是否有类似的工具将为第三方非托管DLL生成P/Invoke签名?
或者,任何方式将第三方DLL提供给PInvoke Interop Assistant
编辑:我试图解决的实际问题
我花了很多时间(谷歌搜索,反映.net二进制文件等)试图解决以下问题:
我在应用程序中看到了死锁(ASP.NET MVC + EF4).我们有几个EF的上下文,它们是在请求开始时创建的,并在最后被处理掉.有时我们会遇到以下情况:ASP.NET为每个请求创建一个线程,然后线程在访问EF上下文时进入"处于join或sleep"状态.
大多数死锁线程都有一个堆栈跟踪如下:
System.dll!System.ComponentModel.TypeDescriptor.Refresh(object component, bool refreshReflectionProvider) + 0x97 bytes
System.Data.dll!System.Data.SqlClient.SqlCommand.DesignTimeVisible.set(bool value) + 0x22 bytes
System.Data.dll!System.Data.SqlClient.SqlCommand.SqlCommand(System.Data.SqlClient.SqlCommand from) + 0xc9 bytes
System.Data.dll!System.Data.SqlClient.SqlCommand.Clone() + 0x27 bytes
System.Data.dll!System.Data.SqlClient.SqlCommand.System.ICloneable.Clone() + 0x9 bytes
System.Data.Entity.dll!System.Data.Common.DbCommandDefinition.CreateCommandDefinition(System.Data.Common.DbCommand prototype) + 0x47 bytes
System.Data.Entity.dll!System.Data.SqlClient.SqlProviderServices.CreateDbCommandDefinition(System.Data.Common.DbProviderManifest providerManifest, System.Data.Common.CommandTrees.DbCommandTree commandTree) + 0x21 bytes
System.Data.Entity.dll!System.Data.EntityClient.EntityCommandDefinition.EntityCommandDefinition(System.Data.Common.DbProviderFactory storeProviderFactory, System.Data.Common.CommandTrees.DbCommandTree commandTree) + 0x2a1 bytes
System.Data.Entity.dll!System.Data.EntityClient.EntityProviderServices.CreateDbCommandDefinition(System.Data.Common.DbProviderManifest providerManifest, System.Data.Common.CommandTrees.DbCommandTree commandTree) + 0x8e bytes
System.Data.Entity.dll!System.Data.Objects.Internal.ObjectQueryExecutionPlan.Prepare(System.Data.Objects.ObjectContext context, System.Data.Common.CommandTrees.DbQueryCommandTree tree, System.Type elementType, System.Data.Objects.MergeOption mergeOption, System.Data.Objects.Span span, System.Collections.ObjectModel.ReadOnlyCollection<System.Collections.Generic.KeyValuePair<System.Data.Objects.ObjectParameter,System.Data.Objects.ELinq.QueryParameterExpression>> compiledQueryParameters) + 0x113 bytes
System.Data.Entity.dll!System.Data.Objects.ELinq.ELinqQueryState.GetExecutionPlan(System.Data.Objects.MergeOption? forMergeOption) + 0x310 bytes
System.Data.Entity.dll!System.Data.Objects.ObjectQuery<CompuTool.Business.Portal.Desktop>.GetResults(System.Data.Objects.MergeOption? forMergeOption) + …Run Code Online (Sandbox Code Playgroud) 我有以下代码以en-us格式生成日期字符串.我想传入LCID(或本地化语言的等效值)来生成日期字符串的本地化版本.我怎么做到这一点?
public static string ConvertDateTimeToDate(string dateTimeString) {
CultureInfo culture = CultureInfo.InvariantCulture;
DateTime dt = DateTime.MinValue;
if (DateTime.TryParse(dateTimeString, out dt))
{
return dt.ToShortDateString();
}
return dateTimeString;
}
Run Code Online (Sandbox Code Playgroud) 假设我们有一个嵌套的泛型类:
public class A<T> {
public class B<U> { }
}
Run Code Online (Sandbox Code Playgroud)
这里,typeof(A<int>.B<>)本质上是一个具有两个参数的泛型类,其中只有第一个被绑定.
如果我有一个带有两个参数的单个类
public class AB<T, U> { }
Run Code Online (Sandbox Code Playgroud)
有没有办法提到" AB有T=int和U保持开放"?如果不是,这是C#限制还是CLR限制?
我有一个解决方案,其中包含不到100个项目,混合使用C++和C#(主要是C#).在VS2005中工作时,Visual Studio的工作集远小于VS2010的工作集.
我想知道是否有一些东西可以关闭,所以我可以在32位操作系统下在VS2010中开发而不会耗尽内存.
memory windows memory-management visual-studio-2010 visual-studio
Microsoft的Unity依赖注入框架可以通过代码或通过应用程序配置文件(app.config)进行配置.
代码示例:
IUnityContainer container = new UnityContainer()
.RegisterType<IInterface, ConcreteImplementation>();
Run Code Online (Sandbox Code Playgroud)
配置示例:
<unity>
<containers>
<container>
<types>
<type type="IInterface, MyAssembly"
mapTo="ConcreteImplementation, MyAssembly" />
Run Code Online (Sandbox Code Playgroud)
每种方法有哪些优点/缺点?我可以想到"用户可以轻松配置您的应用程序"的明显优势,以及"用户可以轻松破解您的应用程序"的明显缺点,但是有什么不那么明显吗?
configuration dependency-injection app-config ioc-container unity-container
以下代码在GCC中调用clz/ctz的内置函数,在其他系统上调用C版本.显然,如果系统有内置的clz/ctz指令,如x86和ARM,则C版本有点不理想.
#ifdef __GNUC__
#define clz(x) __builtin_clz(x)
#define ctz(x) __builtin_ctz(x)
#else
static uint32_t ALWAYS_INLINE popcnt( uint32_t x )
{
x -= ((x >> 1) & 0x55555555);
x = (((x >> 2) & 0x33333333) + (x & 0x33333333));
x = (((x >> 4) + x) & 0x0f0f0f0f);
x += (x >> 8);
x += (x >> 16);
return x & 0x0000003f;
}
static uint32_t ALWAYS_INLINE clz( uint32_t x )
{
x |= (x >> 1);
x |= (x >> 2);
x |= …Run Code Online (Sandbox Code Playgroud) 我正在寻找能够利用该语言的独特功能的框架.我知道FsUnit.你会推荐别的吗?为什么?
.net ×5
c# ×5
app-config ×1
c ×1
csproj ×1
cultureinfo ×1
currying ×1
datetime ×1
deadlock ×1
f# ×1
f#-unquote ×1
fsunit ×1
generics ×1
intrinsics ×1
memory ×1
pinvoke ×1
plugins ×1
unit-testing ×1
unmanaged ×1
visual-c++ ×1
windows ×1