You can call your own or 3rd-party .NET assemblies from add-in fuctions or event handlers.
It is a good idea, if possible, to add the C# or VB.NET project to your add-in solution (as we have in the AssemblyDemo sample). This lets you debug both sides at the same time: you can step from the C++ add-in into the .NET assembly and back again, seamlessly.
To call a .NET assembly from your add-in's C++ code, you must add a reference to your project.
Once the reference is added, a bonus is that Intellisense becomes available in your C++ code, which can save a lot of typing and errors.
The XLL+ framework adds an event handler to the current AppDomain so that the add-in can specify the location of the .NET assembly to be loaded.
By default, the add-in looks in its own directory for any .NET assemblies. So, if you deploy your .NET assemblies (and any assemblies upon which they depend) to the same directory as your XLL file, you need not concern yourself any further with the details of assembly loading.
If your assemblies are deployed to a different location, then use CXllApp::SetPrivateBinPath() to set the list of directories that the loader will search. You should call SetPrivateBinPath in the XllOpenEx() event handler, before you call any methods from your assemblies.
BOOL CClrAddinApp::OnXllOpenEx() { ... // Set up assembly loading // This will append "C:\Assemblies" to the assembly loader's search path SetPrivateBinPath(GetPrivateBinPath() + ";" + "C:\\Assemblies"); ... return TRUE; }
If your assemblies have been added to the Global Application Cache (GAC) then you do not need to concern yourself with the private bin path; your assemblies will automatically be loaded at run-time.
You need to ensure that the machines on which your .NET-dependent add-ins are deployed are properly configured to run .NET add-ins under Excel. Please see the technical note .NET requirements for more information.