小编Ant*_*ino的帖子

是否概述了所有SQL Server 2012错误代码?

SQLGetDiagRec返回本机错误代码.是否有任何概述SQL Server 2012的错误代码?我在MSDN上找不到任何东西.

sql-server odbc c++-cli sql-server-2012

17
推荐指数
3
解决办法
3万
查看次数

NHibernate和ADO.NET连接池

似乎NHibernate不会集合ADO.NET数据库连接.仅在提交或回滚事务时关闭连接.对源代码的回顾表明,没有办法配置NHibernate,以便在处理ISession时关闭连接.

这种行为的意图是什么?ADO.NET本身就有连接池.在交易中不需要一直打开它们.使用此行为也是不必要的分布式事务创建.因此,http: //davybrion.com/blog/2010/05/avoiding-leaking-connections-with-nhibernate-and-transactionscope/中描述的可能解决方法不起作用(至少不适用于NHibernate 3.1.0).我正在使用Informix.对于每个其他数据库(NHibernate Connection Pooling),似乎存在同样的问题.

有没有其他解决方法或建议避免这个问题?

这是一个重现问题的单元测试:

  [Test]
  public void DoesNotCloseConnection()
  {
     using (SessionFactoryCache sessionFactoryCache = new SessionFactoryCache())
     {
        using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions() { IsolationLevel = IsolationLevel.ReadCommitted, Timeout = TimeSpan.FromMinutes(10) }))
        {
           fixture.Setup(); // Creates test data

           System.Data.IDbConnection connectionOne;
           System.Data.IDbConnection connectionTwo;

           using (ISessionFactory sessionFactory = sessionFactoryCache.CreateFactory(GetType(), new TestNHibernateConfigurator()))
           {
              using (ISession session = sessionFactory.OpenSession())
              {
                 var result = session.QueryOver<Library>().List<Library>();
                 connectionOne = session.Connection;
              }
           }

           // At this point the first IDbConnection used …
Run Code Online (Sandbox Code Playgroud)

.net nhibernate ado.net connection-pooling

9
推荐指数
1
解决办法
2万
查看次数

如何在Visual Studio编辑器中禁用字体平滑?

如何在Visual Studio的文本编辑器中禁用字体平滑?在我使用的一些机器上,这是有效的,但是,大多数机器都没有.

左边编辑器中的文字并不是很清晰.但是Windows中的字体是.

windows fonts visual-studio-2012

8
推荐指数
3
解决办法
1万
查看次数

如何使用Castle 3.0删除组件?

我有IWindsorContaner,它存在于整个应用程序生命周期中.对于Unittests,可以在其类型下注册模拟/存根等.当测试完成并且处理夹具时,用自创的称为"取消注册"的方法移除测试中的注册组件.

现在,我想更新到最新的Castle版本3.0.根据3.0发布说明的东西

public void Unregister(string contextName, string registrationName)
{
   IWindsorContainer context = GetOrCreateContext(contextName);
   context.Kernel.RemoveComponent(registrationName);
}
Run Code Online (Sandbox Code Playgroud)

因为已删除了IKernel.RemoveComponent方法,所以不再可能.解决这个问题的描述还不够("尝试使用IHandlerSelectors.").

我用于单元测试的夹具的简化版本:

public sealed class DependencyInjectionFixture : IDisposable
{
  private Stack<Type> registeredTypes = new Stack<Type>();

  // Registering of mocks/stubs, etc
  public void RegisterSingleton<T>(T singleton, string objectName)
  {
     registeredTypes.Push(typeof(T));

     IWindsorContainer context = GetOrCreateContext(contextName);

     context.Register(Component.For(typeof(T))
                               .Named(objectName)
                               .Instance(singleton)
                               .LifeStyle.Singleton);
  }

  // Called when tests ends
  public void Dispose()
  {
     IWindsorContainer context = GetOrCreateContext(contextName);

     while (registeredTypes.Count > 0)
        context.Kernel.RemoveComponent(CSApplicationContext.GetRegistrationNameFor(registeredTypes.Pop()));
  }
Run Code Online (Sandbox Code Playgroud)

}

如何使用Castle 3.0删除组件?

.net c# castle-windsor castle

7
推荐指数
1
解决办法
1789
查看次数

是否有一个示例为什么应该在NHibernate中覆盖Equals/GetHashCode?

我发现很多帖子都解释说应该总是在NHibernate实体类上重写Equals/GetHashCode.如果我不使用套装,这真的有必要吗?

我根本找不到一个示例,其中显示缺少Equals/GetHashCode会导致意外和错误的行为.没有它们,一切似乎都很完美.这真是奇怪,每个人都说这是必要的,但没有人能提供一个样本,说明为什么需要这样做.

.net c# nhibernate domain-driven-design

7
推荐指数
1
解决办法
1707
查看次数

PowerShell参数值建议

我已经用C#编写了一个Cmdlet。是否可以提供特定字符串参数的所有可能值(此示例为“ PackageId”)?

public sealed class InstallPackageCommand : PSCmdlet
{
    [Parameter(Position = 0, Mandatory = true)]
    public string PackageId { get; set; }

    protected override void BeginProcessing()
    {
       //...
    }
} 
Run Code Online (Sandbox Code Playgroud)

c# powershell

3
推荐指数
1
解决办法
1192
查看次数

C++/CLI前向声明

我的标题看起来像这样:

    namespace Dummy
    {
        ref class ISYSession {};

        namespace Afw
        {
            /// <summary>Sammlung von AFW-Utility-Methoden</summary>
            public ref class AfwUtility
            {
            public:
                static void CopyAFWParamsToIDictionary(AFWParams &parameterIn, System::Collections::IDictionary^ parameterOut);
                static AFWParams* CopyIDictionaryToAFWParams(System::Collections::IDictionary^ dictionary);
                static void ShowExceptionLog(System::String^ sessionId);
                static void ShowStatementLog(System::String^ sessionId);
                static Dummy::ISYSession^ GetSession(AFWAppClass *acl);
            };
        }
    }
Run Code Online (Sandbox Code Playgroud)

如果我不使用我的ref类的标题,我不能在同一个程序集中使用它.但是使用这个头文件我的代码不再编译了.

这是前两个错误:

c:\ develop ...\xy.dll:警告C4944:'ISYSession':Das Symbol kann nicht aus'c:\ develop ...\xy.dll'importiert werden:'Dummy :: ISYSession'isre bereits im aktuellen Bereich vorhanden.

(英语:"'Dummy :: ISYSession':无法从xy.dll导入符号:Dummy :: ISYSession已存在于当前范围内.")

错误C3699:"^":Diese Referenzierung kannnichtfürdenTyp"Schleupen :: CS :: SY :: ISYSession"verwendet werden. …

.net c++ c++-cli forward-declaration

2
推荐指数
1
解决办法
6000
查看次数