Blazor Server : Problem with load RCL at Runtime

Hamed Vaziri 136 Reputation points
2022-02-16T23:15:21.297+00:00

Hi guys ..

Base on this link, I've created a sample project to accomplish this and load external rcl at runTime. but i have a problem! Please see this link which works correctly & this link which does not works correctly (It means when you click on "Data" page, the content of Cmp1 page does not show on ComponentPage)!

If you made the following changes to the working project, then it's not working anymore! :

  1. RCLModule01 -> Remove Project as Reference (BlazorServerApp.Web)
  2. RCLModule01 -> MyComponent -> Change "Component" of Type "BlazorServerApp.Web.Modules.RCLModule01.Cmp1" to "Cmp1"
  3. BlazorServerApp.Web -> Modules folder -> Exclude "RCLModule01" project.

Where is my problem & how to solve it?
Thanks in advance ...

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,140 questions
Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,378 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,204 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Zhi Lv - MSFT 32,006 Reputation points Microsoft Vendor
    2022-02-17T06:01:28.833+00:00

    Hi @Hamed Vaziri ,

    but i have a problem! Please see this link which works correctly & this link which does not works correctly (It means when you click on "Data" page, the content of Cmp1 page does not show on ComponentPage)

    The problem is to make the not working sample to work, right?

    From the "works" project, if you modify the content of the Cmp1.razor view component in the RCLModule01 class library (Not the RCLModule01 in the Modules folder). And running the BlazorServerApp.Web application, you can see the cmp1 page content not change. Because, it will show the Cmp1.razor component in the Modules folder, instead of the Cmp1.razor component in the RCLModule01 class library. In another word, the RCLModule01 class library project seems not working, if you Unload the RCLModule01 class library project, the BlazorServerApp.Web application also works well.

    So, to make the "Not works" project working, you can try the following steps:

    1. Right click the Modules folder, select the RCLModule01 folder and choose the Include In Project option to add it in the BlazorServerApp.Web application.
    2. Add using BlazorServerApp.Web.Modules.RCLModule01; in the MyComponent.cs file.

    Then, running the BlazorServerApp.Web application, the result is like this:

    175263-image.png


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,
    Dillion

    0 comments No comments

  2. Hamed Vaziri 136 Reputation points
    2022-02-17T06:48:14.62+00:00

    Hi @Zhi Lv - MSFT
    Thanks for answer, But i want to make my rcl project working! I don't want to use a project which included in Modules folder, I want to use rcl project without any dependence on web project!
    My problem is that how to make changes to my not working project to make it working!
    Thanks in advance


  3. Hamed Vaziri 136 Reputation points
    2022-02-18T17:02:33.383+00:00

    Can anybody help me?


  4. Hamed Vaziri 136 Reputation points
    2022-02-23T14:42:00.077+00:00

    Many thanks @Zhi Lv - MSFT
    Also, after a lot of research on Oqtane framework which can load rcl dynamically, i found that the static css & js files(s) of rcl project copied to Oqtane.Server project static files inside a folder as follow :

    ..\wwwroot\Modules\MyRCLProjectName\Module.css
    ..\wwwroot\Modules\MyRCLProjectName\Module.js

    This copy process occures automatically & immediately after i build my rcl solution. In the MyRCLProjectName.Package project, we have debug & release cmd file(s) which execute this code(s) after i build entire solution :

    ..
    XCOPY "..\Server\wwwroot*" "....\oqtane.framework-dev\Oqtane.Server\wwwroot\" /Y /S /I
    ..

    To use these staic files, In Oqtane.Server and in _Host.cshtml's code behind, It create "link ..." tag dynamically inside head tag.

    That's it!
    However, Thank you very much ..

    0 comments No comments