> Linking To ClientProtector In Your
Application > Linking To ClientProtector™ Using Microsoft C#.NET®
Linking To ClientProtector™ Using Microsoft C#.NET®Please be sure you have read Linking To The ClientProtector COM Component In Your Application before you perform this procedure. If you run into trouble, you may prefer to start with the Sample Code. There are a set of three complete compile-able C#.NET programs available. The following example was prepared and tested in Microsoft Visual Studio .NET 2003 in the C# language. The method we use here involves using the interoperability mechanism available to .NET applications to use the ClientProtector COM server just like it was another object in our application. This is a breeze in MSVC#. For additional information you may wish to see the MSDN page "Calling COM Components from .NET Clients".
When you use the "#using SSCProt" directive, the IDE also has visibility to the enumerated constants defined in RETURNCODES and CPDEBUGFLAGS (inside COM server). You have access to these defined constants directly. Important Note About .NET FPU (Floating Point Unit) Control Word The .NET framework expects the floating point control word to mask all exceptions internally. However the SoftwareShield COM servers expect (and must have) a standard FPU exception mask (during load and construction). If you are having strange exceptions that disappear when you comment out the creation of your SoftwareShield COM servers, you may need to use the following simple work-around to get and reset the default control word. This is illustrated as well inside each of the C# sample programs in this SDK. This should only have to be done immediately after the COM servers construction call. 1) Import the _controlFP function from the msvcrt.dll using InteropServices: [System.Runtime.InteropServices.DllImport("msvcrt.dll")] 2) Create a member variable to store the default control word for your application: private int DefaultCW; 3) During construction of your main form (or module) get the default control word and store it: DefaultCW = _controlfp(0, 0); 4) Immediately after your call to construct the ClientProtector, reset the default control word: SSCP = new SSCProtectorClass(); // restore
the FPU control
word .NET expects You should only have to restore the default control word once (or at least only after you create an instance of the ClientProtector).
|