Reputation: 109
I have an .NET Core 2.0 Web API that, obviously is built in C#. I have a method that calls a void function from a VB dll and when I run the program this function call throws the following exception.
System.MissingMethodException: Method not found: 'System.Object Microsoft.VisualBasic.Interaction.IIf(Boolean, System.Object, System.Object)'
I have registered the dll on GAC, I have referenced the project itself other than the .dll file, and even so, Visual Studio wouldn't let me even debug it.
Using Visual Studio 2017, .NET Core 2.0 Framework.
Upvotes: 0
Views: 1396
Reputation: 15991
Convert the IIf
to If
.
Example: IIF(SomeCondition, "A", "B")
to IF(SomeCondition, "A", "B")
Reference: VB.NET Ternary Operator
Upvotes: 0
Reputation: 109
In short, there is no way to integrate a VB dll to a .NET Core. Most of the native VB functions don't work. My advice is to translate the dll to c#.
Upvotes: 2
Reputation: 40928
Everything in .NET Core is NuGet packages now. Just add the Microsoft.VisualBasic
package to your project from NuGet and you should be good to go.
Mind you, it looks like you're using the Microsoft.VisualBasic.Interaction.IIf
method. There is an equivalent to that build right into the C# language: the ?
operator. Use it like this:
var myVariable = something == "A" ? "Equals A" : "Doesn't equal A"
Upvotes: 0