My Visual Studio .NET project fails to build or throws an exception during runtime when using SKCLNET
Posted by Abram P, Last modified by Dan H on 19 May 2016 11:47 AM

If you are creating a new Visual Studio project which targets the .NET 4.0 Framework or later, or upgrading an existing project to target the .NET 4.0 Framework or later, you may run into the following exception during runtime or at compile time:

Mixed mode assembly is built against version 'v1.0.3705' of the runtime and cannot be loaded in the 4.X runtime without additional configuration information.

Although SKCLNET is not version-specific, it requires you to specify that the assembly is able to load components of older .NET Framework versions when the assembly is compiled targeting .NET Framework 4.0 or later.  To correct this, you will need to update your application configuration file (usually app.config). This update needs to go in the *.exe.config file. If your project does not have an app.config file, click the Project/Add NewItem menu option, click General on the left, and select Application Configuration File.  Open your application configuration file, and find the startup element.  You will need to add the useLegacyV2RuntimeActivationPolicy attribute with a value of "true" to this element.  So for example, your application configuration might initially look something like:

<?xml version="1.0"?>
<configuration><startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

Updating the startup element as specified in the XML shown above would make it then look like (the part highlighted in red is the part that you need to add):

<?xml version="1.0"?>
<configuration><startup useLegacyV2RuntimeActivationPolicy="true"><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

If you find that you are still getting these errors after applying this change, you may also need to update your project settings to disable generation of serialization assemblies.  To do this, click the Project/Properties... menu option.  If you are using C#, click the Build tab and change the "Generate serialization assembly" option from Auto to Off.  If you are using VB.NET, click the Compile tab, click the "Advanced Compile Options..." button at the bottom, and change the "Generate serialization assembly" option from Auto to Off.

Additionally, if you get a compile error that says "The type or namespace name 'SKCLNET' could not be found" or "Type 'SKCLNET.LFile' is not defined", along with a warning that says "Could not resolve assembly "System.Design", this means that the assembly is not in the currently targeted framework, and you will need to make sure that your project only targets the .NET 4 Framework -- NOT the .NET 4 Framework Client Profile.  To make sure this is set correctly, click the Project/Properties... menu option.  If you are using C#, click the Application tab and make sure "Target framework" is set to ".NET Framework 4".  If you are using VB.NET, click the Compile tab, click the "Advanced Compile Options..." button at the bottom, and make sure "Target framework" is set to ".NET Framework 4".

If you are using Visual Studio 2010 and targeting the .NET 3.5 Framework or lower and get a compile error that says "is not a valid Win32 application.", we ask that you open a support ticket and we can provide you with a possible workaround.

File Associations

After implementing the above, if your application runs successfully from its executable, but you receive a FileLoadException error when executing the application using an associated file type make sure you are using the long name path format surrounded by quotes for your executable path.  There are several ways to achieve file associations, but somewhere you will have created a “shell\open\command” registry key with a value similar to "C:\Program Files\MyApp\MyApp.exe" "%1".  Be sure the path is not using the short name (8.3) format and make sure the path is surrounded by quotes. 

PLUSManaged Library Availability

These errors do not apply to the new PLUSManaged library.  PLUSManaged is a new, fully managed .NET class library which is now available. This library uses digital signatures and public-key cryptography to protect a read-only XML license file issued by a SOLO Server.  For more information regarding PLUSManaged and to download a free, no-obligation trial version, click here.