In order to correctly load the assemblies, all of assemblies from ikvm support libraries must be added to Global Assembly Cache (GAC)
for line in $(find /usr/lib/ikvm/ -iname '*.dll'); do 
    gacutil -i "$line"
done
Of course, the script must be executed with root/sudo credentials. Target Runtime: v2.0.50727 ========================== mcs -r:/usr/lib/ikvm/IKVM.OpenJDK.Core.dll -r:bin/p2jpl.dll -target:library -pkg:dotnet -out:bin/P2JLogical.dll src/P2JLogical.cs mcs -r:/usr/lib/ikvm/IKVM.OpenJDK.Core.dll -r:bin/P2JLogical.dll -pkg:dotnet -target:exe -out:bin/TestApp1.exe src/TestApp1.cs Target Runtime: v4.0.30319 ========================== mono /usr/bin/ikvm/bin/ikvmc.exe -target:library lib/p2jpl.jar -out:bin/p2jpl.dll -version:0.0.1.1 2> p2jpl_conv.log --------------------------------------------------------------------------------------------------------------------- Version: ea6b3aaa-6e1e-4f1c-a53d-3b1fc9981e47 Location: C:\Work\x-compiled\p2jpl.dll Size: 1740288 Bytes Target Runtime: v4.0.30319 Platform Target: Any @error CS0006: Metadata file `cscompmgd.dll' could not be found@ Manually add the requested assembly: dmcs -r:/usr/lib/mono/2.0/cscompmgd.dll -r:System.Windows.Forms -r:/usr/lib/ikvm/IKVM.OpenJDK.Core.dll -r:bin/p2jpl.dll -pkg:dotnet -target:library -out:bin/P2JLogical.dll src/P2JLogical.cs src/AssemblyInfo.cs ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Version: 53f5cbab-b91d-4bfb-9959-069746ba62a2 Location: C:\Work\x-compiled\P2JLogical.dll Size: 5120 Bytes Target Runtime: v4.0.30319 Platform Target: Any dmcs -r:/usr/lib/mono/2.0/cscompmgd.dll -r:/usr/lib/ikvm/IKVM.OpenJDK.Core.dll -r:bin/P2JLogical.dll -pkg:dotnet -target:exe -out:bin/TestApp1.exe src/TestApp1.cs ------------------------------------------------------------------------------------------------------------------------------------------------------------------ Version: c36c66d2-4863-4660-9c2a-8cc107364e01 Location: C:\Work\x-compiled\TestApp1.exe Size: 3584 Bytes Target Runtime: v4.0.30319 Platform Target: Any ALTER ASSEMBLY for assembly 'p2jpl' failed because assembly 'p2jpl' failed verification. Check if the referenced assemblies are up-to-date and trusted (for external_access or unsafe) to execute in the database. CLR Verifier error messages if any will follow this message [ : com.goldencode.p2j.util.FileChecker::checkFileType][mdToken=0x6001a84][offset 0x00000054] Instruction cannot be verified. [ : com.goldencode.p2j.util.FileChecker::getFileCreationTime][mdToken=0x6001a86][offset 0x00000054] Instruction cannot be verified. [ : com.goldencode.p2j.util.LaunchManager::pseudoTerminalWait][mdToken=0x6001bcd][offset 0x0000004E] Instruction cannot be verified. [ : com.goldencode.p2j.util.LaunchManager::pseudoTerminalLaunch][mdToken=0x6001bcf][offset 0x0000006E] Instruction cannot be verified. [ : com.goldencode.p2j.util.MemoryManager::isLittleEndian][mdToken=0x6001d04][offset 0x0000004C] Instruction cannot be verified. [ : com.goldencode.p2j.util.MemoryManager::allocate][mdToken=0x6001d05][offset 0x0000004D] Instruction cannot be verified. [ : com.goldencode.p2j.util.MemoryManager::deallocate][mdToken=0x6001d06][offset 0x0000004D] Instruction cannot be verified. [ : com.goldencode.p2j.util.MemoryManager::findNextNull][mdToken=0x6001d07][offset 0x0000004F] Instruction cannot be verified. [ : com.goldencode.p2j.util.MemoryManager::read][mdToken=0x6001d08][offset 0x00000051] Instruction cannot be verified. [ : com.goldencode.p2j.util.MemoryManager::write][mdToken=0x6001d09][offset 0x00000056] Instruction cannot be verified. [ : com.goldencode.p2j.util.MemoryManager::copy][mdToken=0x6001d0a][offset 0x00000050] Instruction cannot be verified. [ : com.goldencode.p2j.util.Registry::setKeyVal][mdToken=0x6001ff8][offset 0x0000006C] Instruction cannot be verified. [ : com.goldencode.p2j.util.Registry::removeValueName][mdToken=0x6001ff9][offset 0x00000064] Instruction cannot be verified. [ : com.goldencode.p2j.util.Registry::removeSubKey][mdToken=0x6001ffa][offset 0x0000005C] Instruction cannot be verified. [ : ... (Microsoft SQL Server, Error: 6218) ALTER ASSEMBLY failed because type 'com.goldencode.expr.CompiledExpression' in safe assembly 'p2jpl' has a static field '$assertionsDisabled'. Attributes of static fields in safe assemblies must be marked readonly in Visual C#, ReadOnly in Visual Basic, or initonly in Visual C++ and intermediate language. (Microsoft SQL Server, Error: 6211) mono --runtime=v2.0.50727 /usr/bin/ikvm/bin/ikvmc.exe -target:library lib/p2jpl.jar -out:bin/p2jpl.dll -version:0.0.1.1 2> p2jpl_conv.log * will generate Target Runtime: v4.0.30319, too Target Runtime v2.0.50727 - the default in windows ========================= mono --runtime=v2.0.50727 /usr/bin/ikvm/bin/ikvmc.exe -target:library -nostdlib -r:/usr/lib/mono/2.0/mscorlib.dll -r:/usr/lib/mono/2.0/System.dll -out:bin/p2jpl.dll -version:0.0.1.1 lib/p2jpl.jar dmcs -r:/usr/lib/mono/2.0/cscompmgd.dll -r:System.Windows.Forms -r:/usr/lib/ikvm/IKVM.OpenJDK.Core.dll -r:bin/p2jpl.dll -pkg:dotnet -target:library -out:bin/P2JWrapper.dll src/P2JLogical.cs src/P2JInt64.cs src/AssemblyInfo.cs dmcs -r:/usr/lib/mono/2.0/cscompmgd.dll -r:/usr/lib/ikvm/IKVM.OpenJDK.Core.dll -r:bin/P2JWrapper.dll -pkg:dotnet -target:exe -out:bin/TestApp1.exe src/TestApp1.cs # after loading the assemblies into SQL, creating table and populating: # ========================================================================= SELECT [p2j_int64].P2J_Add('10').value(), [p2j_int64].P2J_Add('-99') FROM [p2j_wrappers] -- ERR: More than one method, property or field was found with name 'P2J_Add' in class 'P2JInt64' in assembly 'P2JWrappers'. Overloaded methods, properties or fields are not supported.