Pages

Tuesday, December 11, 2018

MS SQL 2017 CLR with Oxygene


Integration of programmer's code with SQL perhaps is one of dilemmas for many years. You have tons of legacy specific code written in Delphi/Object Pascal and you are unable to port it all into Transact SQL - that is true. But .NET was developed in mind to let your code run everywhere. Microsoft did a great job allowing CLR to be a essential part of SQL.

Good news! Today Oxygene can be used to produce SQL CLR projects e.g. user defined functions, stored procedures etc…

Let us create create .NET assembly with a User Defined Function for MS SQL.




We will call our assembly SqlClrOxygene.dll.

And some basic global function in Oxygene that will return us hardcoded string.


Now we are ready to build our SqlClrOxygene.dll which is as tiny as 5kb in size. But to get use of it 
we must register the dll in MS-SQL2017 as Assembly. 
Go to Your Database->Programmability->Assemblies and add New Assembly.. in pop-up menu.



After that we should register new Scalar-valued Function in assembly with SQL engine.

Ready to Go?


Thank you RemObject guys who move us into .NET. Vivat! Vivat! Vivat!



Monday, November 12, 2018

Virtual Box automation with C#. Part1

Test Automation and Seamless Software Integration.

On Windows hosts, one can control some of the VirtualBox Main API functionality from C# code, for system integration purpose. There are many applications where VirtualBox comes in need for software Test Automation and Seamless Software Integration. In this example let us consider stable 5.2.22 VirtualBox release.

Step1

Create Visual C# new project (in this example Console Application) and VirtualBox reference. VirtualBox is VBoxC.dll
(normally located in C:\Program Files\Oracle\VirtualBox). It is a COM dll and Virtual Box API available throughout .Net COM Interop technology.


Step2

Access to VBox COM server is managed by means of IVirtualBox interface. IMachine is a particular machine properties interface. The following C# code will iterate over all available virtual machines. 



please note to set Embed Interop Types property of Interop.VirtualBox reference to false, otherwise proxy Interop.VirtualBox.dll will not be able to load.



Result

Now we have list of virtual machines registered on the host. Hopefully .Net CTS will give you more information about virtual machines properties and methods.