Reputation: 829
I've come across one issue following the tutorial at https://learn.microsoft.com/en-us/bot-framework/dotnet/bot-builder-dotnet-formflow in a vb.net project.
Specifically around "Connect the form to the framework" where the following code exists.
internal static IDialog<SandwichOrder> MakeRootDialog()
{
return Chain.From(() => FormDialog.FromForm(SandwichOrder.BuildForm));
}
Which I have in my vb.net
Friend Shared Function MakeRootDialog() As IDialog(Of SandwichOrder)
Return Chain.From(Function() FormDialog.FromForm(Of IForm(Of SandwichOrder))(SandwichOrder.BuildForm))
End Function
The error highlighted is that FromForm
must have a public parameterless instance constructor to satisfy the 'New' constraint for type parameter 'T'.
Which makes sense to me, as it does, IForm clearly has.
Protected Sub New()
I don't c# very often, but I can't figure out why it works there and doesn't return the same error especially since the constructor in c# is.
protected IForm();
I'm thinking that I'm creating a new instance of the class where in c# we aren't.... But I can't figure out why that would be.
Does anybody have any clues?
edit:
While in c# the following does work
return Chain.From(() => FormDialog.FromForm(SandwichOrder.BuildForm));
The following does not, even though they are the same but with the correct type parameters.
return Chain.From(() => FormDialog.FromForm<IForm<SandwichOrder>>(SandwichOrder.BuildForm));
The reason I wasn't using the equivalent vb
Return Chain.From(Function() FormDialog.FromForm(SandwichOrder.BuildForm))
Was that I get the following error.
type parameter(s) in method cannot be inferred from these arguments. Specifying the data type(s) explicitly might correct this error.
And I followed the instructions, this apparently caused the error above and might be a red herring. Apparently, I have another problem to figure out, why in vb.net it thinks the return of the function isn't identical.
Buildform is wonderfully simple and is just.
Public Shared Function BuildForm() As IForm(Of SandwichOrder)
Return New FormBuilder(Of SandwichOrder)().Message("Welcome to the simple sandwich order bot!").Build()
End Function
Upvotes: 2
Views: 95
Reputation: 829
Figured it out.
The issue was BuildFormDeligate - the expected type for FromForm was not been implicitly returned. The solution was to simply create the object and pass it in. Odd since I didn't need to do this in c# but hey ho.
Dim BuildFormDeligate As New BuildFormDelegate(Of SandwichOrder)(AddressOf SandwichOrder.BuildForm)
Return Chain.From(Function() FormDialog.FromForm(BuildFormDeligate))
Upvotes: 1