Installing .NET component into Visual Studio

.NET component is contained in CBFSDisk2017Net.dll, located in the subfolders of <CBFS Disk>\dotNET\ folder. CBFSDisk2017Net.dll requires MSVC Runtime DLLs. Please refer to Deployment instructions for details on installing those Runtime DLLs on your system for development and on target systems during deployment.

To install components to Visual Studio Toolbox

  1. Use Main Menu -> Tools -> Choose Toolbox items to open Toolbox Customization dialog
  2. In the dialog that appears activate .NET Framework Components tab
  3. Find CBFSDisk component in the list and check it.
  4. If you don't find the component in the list, use Browse button to find and add the assembly, which contains the component, to the list.
    Assemblies (32-bit and 64-bit) for .NET 4.6 are located in <CBFS Disk>\dotNET\NET_46 folder.
    Assemblies (32-bit and 64-bit) for .NET 4.5.1 are located in <CBFS Disk>\dotNET\NET_451 folder.
    Assemblies (32-bit and 64-bit) for .NET 4.5 are located in <CBFS Disk>\dotNET\NET_45 folder.
    Assemblies (32-bit and 64-bit) for .NET 4.0 are located in <CBFS Disk>\dotNET\NET_40 folder.
    Assemblies (32-bit and 64-bit) for .NET 2.0 are located in <CBFS Disk>\dotNET\NET_20 folder.

Using the components

To use CBFS Disk in your project, you need to include CBFSDisk2017Net.dll to the list of project references. Then add the following line to the source file:

  • C#:
    using CBFS_Disk;
  • VB.NET:
    imports CBFS_Disk;
  • C++:
    #using <CBFSDisk2017Net.dll>

Referencing plastform-specific assemblies from AnyCPU project

To use CBFS Disk in your AnyCPU project, you need to tell the loader, how to find and load the assembly, which matches your architecture. The sample code in C#-based pseudocode is provided below. The code assumes that you have copies of the assembly, stored in "x86" and "x64" subdirectories of your project's directory. Be sure to turn off "Copy local" option for the assembly reference, so that the compiler doesn't make a (wrong) copy of the assembly to the directory with your project assemblies.


[DllImport("kernel32.dll")]
public static extern IntPtr LoadLibrary(string dllToLoad);

// call this line of code as soon as possible in your project
AppDomain.CurrentDomain.AssemblyResolve += PlatformDepResolve;
...
private static Assembly PlatformDepResolve(object sender, ResolveEventArgs args)
{
	string AsmName = "CBFSDisk2017Net";
	if (args.Name.StartsWith(AsmName))                
	{
		string architecture;
		if (Environment.Is64BitOperatingSystem)
			architecture = "x64";
		else
			architecture = "x86";

		string fileName;

		// Load the MSVC DLL
		fileName = Path.Combine(Environment.CurrentDirectory, architecture, "VCRUNTIME140.dll");
		LoadLibrary(fileName);

		// Load the main assembly
		fileName = Path.Combine(Environment.CurrentDirectory, architecture, AsmName + ".dll");
		Assembly assembly = Assembly.LoadFile(fileName);
		if (args.Name == assembly.FullName)
		    return assembly;
	}
    return null;
}
Thanks to Tyrone Erasmus for the custom resolver implementation.