I get this error when I attempt to load a mixed mode C++/CLI assembly into SQL Server 2012:
CREATE ASSEMBLY [Test]
AUTHORIZATION [dbo]
from \'H:\\test.dll\'
It is impossible to load a mixed mode C++/CLI assembly into SQL Server.
You can only load a "pure" C++/CLI assembly:
However, there may be a way around this. Use P/Invoke
in your C# file. This is equivalent to writing a mixed mode C++/CLI assembly wrapper, because when CLR
code calls native
code in your assembly, it performs an implicit P/Invoke
(let me know if this works for you).
This is my theory:
If we go back to 2005, things were different. When they released the first version of SQL Server to support the CLR, mixed mode assemblies would sometimes deadlock on a load. See Microsoft - Mixed DLL Loading Problem. Even after they fixed this issue, there was still arguments centered around security and stability which tipped the scales against allowing loading of mixed mode C++/CLI assemblies into the core of SQL server.
If anyone on the original Microsoft design team can fill in the blanks, I'd be very curious!