Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RBS can't run the app if the localized page is open on designer #82

Closed
koksalbasar opened this issue Dec 2, 2022 · 12 comments
Closed

Comments

@koksalbasar
Copy link

Hi guys,

This post is created after a Radzen forum discussion. You can access it from this link.

Problem

This is about multi-language selection <CulturePicker /> component and the issue started after the last update (1.0.6).

To regenerate the issue please follow the directions.

  1. Load my sample project.
  2. Run it before opening any page.
  3. You can run it without any problem for each turn.
  4. Open the sample page
  5. Try to run the project again.
  6. You will get warning messages ten times and an error message like the following.
  7. To stop and run the app again or close the page is not the solution. The only way is the quit the RBS.
  8. This is not a design time problem. It occurs only at runtime.

Error

C:\Program Files\dotnet\sdk\7.0.100\Microsoft.Common.CurrentVersion.targets(4786,5): error MSB3027: Could not copy "obj\Debug\net6.0\en-US\RadzenResourceTest.resources.dll" to "bin\Debug\net6.0\en-US\RadzenResourceTest.resources.dll". Exceeded retry count of 10. Failed. The file is locked by: ".NET Host (18448)" [C:\Users\Administrator\source\repos\RadzenTestMultiLanguage\server\RadzenResourceTest.csproj]
C:\Program Files\dotnet\sdk\7.0.100\Microsoft.Common.CurrentVersion.targets(4786,5): error MSB3021: Unable to copy file "obj\Debug\net6.0\en-US\RadzenResourceTest.resources.dll" to "bin\Debug\net6.0\en-US\RadzenResourceTest.resources.dll". The process cannot access the file 'C:\Users\Administrator\source\repos\RadzenTestMultiLanguage\server\bin\Debug\net6.0\en-US\RadzenResourceTest.resources.dll' because it is being used by another process. [C:\Users\Administrator\source\repos\RadzenTestMultiLanguage\server\RadzenResourceTest.csproj]

The given process number (18448 in my sample) is pointing to dotnet.exe.

The temporary solution

When the <CulturePicker /> component is removed on the MainLayout.razor page, design time and run time works seamlessly.

I hope you can regenerate the issue with my sample.

RadzenTest4.zip

@akorchev
Copy link
Contributor

akorchev commented Dec 3, 2022

I couldn't reproduce a file lock but reproduced something else which is probably related - opening SysProjectTotal.razor caused the RBS server process to crash. This effectively disables RBS and if you have a running project at the time it stayed running in the background thus locking the build artefact files.

The problem seems to be caused by this code (poor <CulturePicker /> seems to be innocent):

        protected async void Datagrid0Render(DataGridRenderEventArgs<ValuraManager.Models.SqlExpress.VwProjectTotal> args)
        {
            GetCompanyTotal();
        }

It performs a DB query and crashes in design-time (which is to be expected). Can you try modifying this code to and reloading the project in RBS:

        protected async void Datagrid0Render(DataGridRenderEventArgs<ValuraManager.Models.SqlExpress.VwProjectTotal> args)
        {
#if !RADZEN
            GetCompanyTotal();
#endif
        }

This will hide GetCompanyTotal() from RBS and should prevent the crash and hopefully the locking that you experience.

We plan to make a change to not execute any Blazor Component event handlers in RBS (such as we did in Radzen). We should have probably make it so from the beginning.

@koksalbasar
Copy link
Author

Hi @akorchev,

I'm really so sorry. Please forgive me, I took your time. That file is not related to our issue. I shared the wrong file with you. There is no <CulturePicker /> component inside that.

Here is the right file. Please follow the instruction to reproduce the error.
RadzenTestMultiLanguage.zip

PS. In this example selecting language process is disabled. You will see the 2 components for this action. Both of them remarked but the result is the same. Maybe you are right <CulturePicker /> can be innocent but something is happening about language. Removing <CulturePicker /> does not worked for this sample but in my project when I removed <CulturePicker /> I can continue work in design time.

PS. in some cases (I couldn't catch it exactly) RBS forgets its configuration and, when restarted turns to the light theme instead of dark (I'm setting it to the dark always).

Thanks for your support,

@akorchev
Copy link
Contributor

akorchev commented Dec 3, 2022

I am sorry but I don't understand what the problem is and how to test it. I need the exact steps. A quick test by uncommenting the <RadzenDropDown /> in MainLayout does not cause any problems.

@koksalbasar
Copy link
Author

Hi @akorchev,
I know you are busy with many issues but I added to the story of the problem in my first post.

Hi guys,

This post is created after a Radzen forum discussion. You can access it from this link.

Problem

This is about multi-language selection component and the issue started after the last update (1.0.6).

To regenerate the issue please follow the directions.

  1. Load my sample project.
  2. Run it before opening any page.
  3. You can run it without any problem for each turn.
  4. Open the sample page TextResourceTestPage.razor
  5. Try to run the project again.
  6. You will get warning messages ten times and an error message like the following.
  7. To stop and run the app again or close the page is not the solution. The only way is the quit the RBS.
  8. This is not a design time problem. It occurs only at runtime.

Error

C:\Program Files\dotnet\sdk\7.0.100\Microsoft.Common.CurrentVersion.targets(4786,5): error MSB3027: Could not copy "obj\Debug\net6.0\en-US\RadzenResourceTest.resources.dll" to "bin\Debug\net6.0\en-US\RadzenResourceTest.resources.dll". Exceeded retry count of 10. Failed. The file is locked by: ".NET Host (18448)" [C:\Users\Administrator\source\repos\RadzenTestMultiLanguage\server\RadzenResourceTest.csproj]
C:\Program Files\dotnet\sdk\7.0.100\Microsoft.Common.CurrentVersion.targets(4786,5): error MSB3021: Unable to copy file "obj\Debug\net6.0\en-US\RadzenResourceTest.resources.dll" to "bin\Debug\net6.0\en-US\RadzenResourceTest.resources.dll". The process cannot access the file 'C:\Users\Administrator\source\repos\RadzenTestMultiLanguage\server\bin\Debug\net6.0\en-US\RadzenResourceTest.resources.dll' because it is being used by another process. [C:\Users\Administrator\source\repos\RadzenTestMultiLanguage\server\RadzenResourceTest.csproj]
The given process number (18448 in my sample) is pointing to dotnet.exe.

The temporary solution

When the component is removed on the MainLayout.razor page, design time and run time works seamlessly.

I hope you can regenerate the issue with my sample.

Can't you reproduce the error?

In my environment, this project generates an error when try to run the project if you open the TextResourceTestPage.razor on the designer.
RadzenTestMultiLanguage.zip

@akorchev
Copy link
Contributor

akorchev commented Dec 5, 2022

Here is my experience as a screen recording. Unfortunately I can't reproduce the dll locking.
localization
Let me know if I am doing something out of the order.

@koksalbasar
Copy link
Author

Hi @akorchev,
You are doing right. This is about my local as I understood.

Could you give me permission to run RBS on a second machine with the same license for testing purposes simultaneously for a limited time?

Maybe I can find something meaningful.

@akorchev
Copy link
Contributor

akorchev commented Dec 5, 2022

You can run RBS on as many machines as you want with the same license key. As long as you are the only person using it everything is fine.

@koksalbasar
Copy link
Author

Hi @akorchev,

I will really be crazy.

The new setup did the same. No VS, no other development environment except RBS. Just OS.

I changed everything.
Region : United States
Regional Format : English (United States)
Display Language : English
App and web language : English

Nothing changed.
The only thing that I have as a clue is the file that is locked could be deleted after RBS closed.

I couldn't find a meaningful reason.

I gave up totally.
I removed multi language things in my project. Because I can't work other ways.

I'll check out from time to time. Please do the same.

@koksalbasar
Copy link
Author

Hi @akorchev,

I said I gave up but I think I love RBS more than I think. I spent all my night and I found a working solution. I don't know the backend mechanism. Maybe you can find something meaningful.

I'll try to explain.

First I thought if I can add a fake resources.dll file to the process because the XXX.resources.dll file fails, maybe I can create a cheat.

I was using the culture option when I created language files.
English : en-US (English - United States) - default
Turkish : tr-TR (Turkish - Türkiye)

I added an English language file (without culture) : (en - English) and set it as default.

It worked for once. But when I changed the language to Turkish I got errors again. This time I added Turkish without culture (tr - Turkish) and I removed the other configurations (that with cultures).

Suprise...

This configuration is working for now.

Does this tell you something?

@akorchev
Copy link
Contributor

akorchev commented Dec 6, 2022

Unfortunately this doesn't make much of a difference. I still can't reproduce such locking. Hopefully this workaround would allow you to continue your work.

@koksalbasar
Copy link
Author

koksalbasar commented Dec 7, 2022

Yes I do for now.

There is only a question. Will using the definitions without culture ("en" instead of "en-US" etc.) cause some side effects in the future?

UPDATED!!!!

Yes, if some prerequisites are available.

  1. The default language must be selected as en (English). The other languages are not important. You can select it with the culture options.
  2. The default language that is shown on the designer must not change while design time.
    image

Added : Even if you make changes in the default language to the second or third one, when you run the application, the screen returns to the default language.

Whit these prerequisites, RBS is working for me.

PS. Can you share your test box configuration the language and the region parts of the OS?

@koksalbasar
Copy link
Author

After some digging with @akorchev's suggestions, I found the solution.

First, I saw that my approach was old fashioned. I was using property based localization. But Microsoft offers a totally different technique for ASP.NET Core Blazor. RBS supports this method for page level. The following article explains the shared level localization. When I implement it in my project everything found peace.

https://learn.microsoft.com/en-us/aspnet/core/blazor/globalization-localization?view=aspnetcore-7.0&pivots=server#shared-resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants