Hi there everyone! I have been trying to get the simple example of the official Terraform Azure C# repo to work
But I keep getting an error at the app argument within the object declaration of new TfLogic:
App app = new App();
TfLogic tf = new TfLogic(app, "azure");
The error is the following:
Argument 1: cannot convert from 'VFrameworkBlazor.App' to 'Constructs.Construct'
This error seems to happen only within the context of Blazor. If I try to do this inside a console application template, it seemingly works. Am I missing something like prerequisite steps?
Thank you for your time!
Fixed: I was missing the NuGet package for Amazon Constructs… The packages should be listed somewhere in the documentation (or I simply overlooked, not sure)
Nevermind, that did not fix it, the solution still won’t build even though Intellisense claims that its recognised. Same error as before "Cannot convert from ‘VFrameworkBlazor.App’ to ‘Constructs.Construct’
I’m no C# expert, so maybe a dumb question, but why would it be
VFrameworkBlazor.App, shouldn’t it be
Constructs is a transitive dependency of
cdktf so you shouldn’t need to explicitly reference it unless you have transitive dependencies disabled.
From the looks of it, your file contains references to two different
App classes. If you need both, you’ll need to fully quality one of them. For example:
There are no dumb questions! What happened is that the C# compiler tried to resolve the App type to
App.Razor, which is a file inside of my solution.
This coincidentally linked the datatype of
App to that very file which causes the compiler to think that I’m trying to work with the VFrameworkBlazor.App
But thankfully, as your colleague stated, it was as simple as putting
HashiCorp.Cdktf.App. before the datatype of
App and now everything is being resolved correctly :)!!