Designer does not recognize referenced namespaces

Hello Radzen Team!

In my project I reference an external .csproj, from outside of my solution, called Global.csproj:

Global is a library class and it's used as an utility to access other APIs, such as the DB API, that owns and manages the MySQL database. Here's an example:

Although everything works in runtime, the designer cannot render the components properly:

It seems that it fails to recognize anything from the Global project. In column binding, for example, it can't find the class properties, since brands are seen as an object[]:

In code there are no errors as it successfully finds the referenced type:

Thanks in advance!

I am logging this for future investigation. We could probably find some workaround.

Here's some more info. I think it's also linked to the problem described in the first post.

Unfortunately it's been impossible to build my project after setting up a dialog.

dotnet: obj\Debug\netcoreapp3.1\Razor\Pages\BrandItem.razor.g.cs(89,22): error CS1503: Argument 6: cannot convert from 'Microsoft.AspNetCore.Components.EventCallback' to 'Microsoft.AspNetCore.Components.EventCallback<Global.Models.Brand>' [C:\Files\Repositories\SolidAccessWeb\Code\Front\server\Front.csproj]

From my testing, this only happens if the Submit event from the TemplateForm is being used.

There is a similar error involving Radzen, that was described here.

Radzen won't infer model types that are not from the Radzen project. You will have to set the TItem or TValue as a custom attribute manually.

In the case of RadzenTemplateForm you should add a custom attribute with Name - TItem and Value - Global.Models.Brand.

1 Like

Thanks for this, now I can build and test the project.
Unfortunately, the designer is unable to render the RadzenTemplateForm, thus blocking me from modifying the items inside.

UPDATE: for now I'll manually select the controls inside the form from the Outline.

Indeed, Radzen does not support model types from other projects at the moment. No workaround for that.

I think this will be useful in the future, or maybe help you in finding a fix for this, so decided to share.
Here's my workaround:

  1. Added 'server/Front.csproj' to the ignore list, because Radzen was removing any extra PropertyGroup in the project file.

  2. In the .csproj, included the code below, which first creates the SolutionDir macro, and then copies the needed files from outside of the solution project.

    <SolutionDir Condition=" '$(SolutionDir)' == '' ">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Front.sln))</SolutionDir>
      xcopy "$(SolutionDir)\..\Global\Models" "$(SolutionDir)\server\Models" /E /H /I /Y /D
  1. Result is now Radzen can see the TItem and thus render everything correctly.

Extra. Of course you wouldn't want the duplicated files in your version control, so add a line in .gitignore for it.

# Specific folders
1 Like