I try to create a C# Library (.dll) using the .net Framework who can be run in Visual Basic (Excel). I develop on Visual Studio.
After some researches, I found that we can used the COM interface for communicate between DLL and VBA. I refer to Calling a .net library method from vba
I can't check the "Register for COM Interop" build option from Visual Studio. This option is disabled. option_disable
Then, when I used "InterfaceType(ComInterfaceType.InterfaceIsDual)", Visual Studio says me that argument is deprecated. argument obsolete
Finally, I can't call my "HelloWorld" function from VBA code.
Precision:
My C#/.net program build with success
I register my DLL with this command (register with no error)
regasm /s /codebase /tlb ClassLibrary3.dll
My full C#/.net program:
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
namespace ClassLibrary3
{
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
[ComVisible(true)]
public interface _Test
{
string HelloWorld();
}
[ClassInterface(ClassInterfaceType.None)]
[ComVisible(true)]
public class Test : _Test
{
public string HelloWorld() {
return "Hello, World! ";
}
}
}
There is a option that I can use other than COM ?
Or what is the problem in my program ?
Thank's for the help :)
Bastien