Getting Started with Solid Framework for .NET

All of the samples for Solid Framework require you to download a license file, specify its location and import the license within the code. Downloading a license and SolidFramework are discussed in this video.

In this code, when “RunSample” is called, the license is validated, and if successful a message is written to the console, and Solid Framework is ready to be used.

While this code has been written as the basis of a command line interface style application, it can be moved into a Forms based application with only minor changes.

The C# and VB.Net samples use partial classes. This is not a requirement of Solid Framework, and has been done only to be consistent with the code used in the full tutorial sample applications which can be downloaded from https://solidframework.net/complete-projects/.

 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CSharp_Tutorials { public static partial class Tutorials { public int RunSample() { // Set the path to the license string licensePath = "..\\SolidFramework\\license.xml"; // Initialize SolidFramework and import the license if (!InitializeSolidFramework(licensePath)) { Console.WriteLine("SolidFramework initialization failed."); return -1; } Console.WriteLine("SolidFramework is initialized and ready to be used."); // Now you can start to use Solid Framework // [Enter your code here to create a converter class or a core model] return 0; } public static bool InitializeSolidFramework(string licensePath) { try { SolidFramework.License.Import(licensePath); } catch (SolidFramework.InvalidLicenseException ex) { Console.WriteLine("Couldn't import license from path " + licensePath + " due to exception: " + ex.Message); return false; } return true; } static int Main(string[] args) { try { return RunSample(); } catch (Exception ex) { Console.WriteLine("Unhandled " + ex.GetType().Name + ": " + ex.Message); return -2; } } } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
Imports System Imports System.Collections.Generic Imports System.Linq Imports System.Text Imports System.Threading.Tasks Namespace VBNet_Tutorials Partial Module Tutorials Function RunSample() As Integer Dim licensePath As String = "..\SolidFramework\license.xml" If Not InitializeSolidFramework(licensePath) Then Console.WriteLine("SolidFramework initialization failed.") Return -1 End If Console.WriteLine("SolidFramework is initialized and ready to be used.") Return 0 End Function Function InitializeSolidFramework(ByVal licensePath As String) As Boolean Try SolidFramework.License.Import(licensePath) Catch ex As SolidFramework.InvalidLicenseException Console.WriteLine("Couldn't import license from path " & licensePath & " due to exception: " & ex.Message) Return False End Try Return True End Function Private Function Main(ByVal args As String()) As Integer Try Return RunSample() Catch ex As Exception Console.WriteLine("Unhandled " & ex.[GetType]().Name & ": " & ex.Message) Return -2 End Try End Function End Module End Namespace
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
using namespace SolidFramework::Platform; bool InitializeSolidFramework(const wstring & frameworkPath, const wstring & licensePath) { // Initialize SolidFramework if (!SolidFramework::Initialize(frameworkPath)) { wcout << L"Couldn't initialize SolidFramework from path " << frameworkPath << endl; return false; } // Import the license try { SolidFramework::License::Import(licensePath); } catch (SolidFramework::InvalidLicenseException &ex) { wcout << L"Couldn't import license from path " << licensePath << L" due to exception: " << ex.what() << endl; return false; } return true; } int RunSamples() { // Allow SolidFramework to treat '\' and '/' as the platform-specific directory separator SolidFramework::SupportPlatformIndependentPaths(true); // Set the path to the license const wstring licensePath = L"..\\SolidFramework\\license.xml"; // Set the path to the SolidFramework DLLs (varies depending on the platform) const wstring frameworkPath = L"..\\SolidFramework\\" + SolidFramework::GetTargetPlatformName(); // Initialize SolidFramework and import the license if (!InitializeSolidFramework(frameworkPath, licensePath)) { wcout << L"SolidFramework initialization failed." << endl; return -1; } wcout << L"SolidFramework is initialized and ready to be used."); // Now you can start to use Solid Framework // [Enter your code here to create a converter class, a core model or whatever else you require] return 0; } int main() { try { return RunSamples(); } catch (exception &ex) { wcout << L"Unhandled std::exception: " << ex.what() << endl; return -2; } catch (...) { wcout << L"Unhandled Exception!" << endl; return -3; } }

Previous sample Samples Next sample