Search code examples
.netcomcom-interopregasm

Can I use regasm to register a .Net COM as SingleUse


Can I register a .Net COM class with the SingleUse-flag?

The reason I want to use SingleUse is that otherwise the static fields inside the COM instances (the client application uses 2 instances with different database connection strings) are shared resulting in any COM instance to access the same database.


Solution

  • No, this doesn't go in the registry. It is a property of an out-of-process COM server, used when it registers its class factories. The dwClsContext argument for CoRegisterClassObject().

    Using static fields is your mistake. Easy to fix.