Can anyone verify that in SA 11.0.1 running on W2K8 x64 can make external function call to .Net C# dll? I am getting object reference error on the call into the dll. Dll has simple static function to return 1. Dll was compiled using csc /t:library /out:my.dll /platform:x64
The setup I have works if using SA 11.0.1 on W2K3 x86 with same dll recompiled for x86.
asked 07 Jun '11, 12:32
Here is what I think might be happening in your particular case. In SQL Anywhere 11, the dbextclr11.exe is built with /platform:anycpu. The same is true for the SQL Anywhere .NET Provider which the CLR external environment makes use of. The SA .NET Provider attempts to load some native pieces, including the SQL Anywhere language dll. If the provider ends up loading the 32-bit language dll instead of the 64-bit language dll, then the framework will (most likely) expect everything to work in a 32-bit environment. Hence a dll that is built /platform:x64 will not load as a result. Have a look at your path variable and see if bin32 appears before bin64. That might be why the 32-bit language dll is being loaded. If bin32 does appear before bin64, then try switching the two around within the path and see if that solves the problem. Of course, the other thing you can do is build your dll with /platform:anycpu if possible.
Note that this problem is resolved in SQL Anywhere 12 since the dbextclr12.exe is now built specifically with /platform:x86 (for the bin32 one) and /platform:x64 (for the bin64 one).
answered 07 Jun '11, 16:34
We think we might have solved this problem. Can you please try the following...
Instead of creating your function as:
ALTER FUNCTION "ev"."fn_clr_test"() returns integer external name 'CLRDLL.DLL::CLRDLL.StaticTest.GetValue() int' language CLR
can you instead try:
ALTER FUNCTION "ev"."fn_clr_test"() returns integer external name 'CLRDLL.dll::CLRDLL.StaticTest.GetValue() int' language CLR
Let me know if that is sufficient to work around the problem for you. In the meantime, we will try and put together a proper fix.
answered 08 Jul '11, 11:19