Right now I am writing a .net dll which should be useable within VBA code (Excel, Access etc.). The following setup is working fine:
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
[ComVisible(true)]
[Guid("8079e4a4-1e4b-4788-92ba-9d5b017fa9be")] //Allocate your own GUID
public interface ICommunication
{
string TestProp { get; set; }
string Login();
string Disconnect();
}
[ClassInterface(ClassInterfaceType.None)]
[ComVisible(true)]
[Guid("19fd86e2-f1b9-478c-ba7a-bd76bdf19b85")] //Allocate your own GUID
[ProgId("TestDll.Communication")]
public class Communication : ICommunication
{
public string TestProp { get; set; }
public string Login()
{
// use of BouncyCastle here
return "logged in";
}
public string Disconnect()
{
// ...
return "disconnected";
}
}
By referencing the generated tlb file I can properly use the Property aswell Disconnect function however calling the Login function leads to problems ("File not found" messagebox in Excel) which I guess are related to the usage of referenced BouncyCastle.
Sub Button1_Click()
Dim o: Set o = CreateObject("TestDll.Communication")
Dim value As String
value = o.Login()
MsgBox value
End Sub
What is the best way to deal with references to other .net assemblies inside com visible libraries? So far I tried registering bouncycastle to the GAC with no success.
Thanks :)