DotVVM 4.2: Sharing MasterPage Between Projects Leads to 'File Not Found' Exception

I’m attempting to share a MasterPage between multiple DotVVM projects (version 4.2). However, I encounter the following exception:

DotVVM.Framework.Compilation.DotvvmCompilationException: File 'Demo.Web.MasterPage.Views.MasterPage.dotmaster' was not found. This exception is possibly caused because of incorrect route registration.

In an older project using DotVVM 2.0, I successfully achieved this, but in version 4.2, it no longer works. Here’s my MasterPage.dotmaster file (with the build action set to Embedded resource):

@viewModel Demo.Web.MasterPage.ViewModels.MasterPageViewModel, Demo.Web.MasterPage
<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
   ...
</head>
<body>

    <dot:ContentPlaceHolder ID="MainContent" />

</body>
</html>

And here’s an example Page1.dothtml with the master page embedded:

@viewModel Demo.Module1.ViewModels.Page1ViewModel, Demo.Module1
@masterPage embedded://Demo.Web.MasterPage/Views/MasterPage.dotmaster

<dot:Content ContentPlaceHolderID="MainContent">
</dot:Content>

I’ve tried various path combinations, but none seem to work. Any insights into resolving this issue would be greatly appreciated. Thank you!

Thanks for reaching out, it surely looks like a bug if it worker in an older version.

Could you please share the full stack trace of the exception? I find it weird that the message contains File 'Demo.Web.MasterPage.Views.MasterPage.dotmaster', instead of File 'embedded://Demo.Web.MasterPage/Views/MasterPage.dotmaster'. That either could mean we are calling this function second time with the mangled file name, or you could have another page with @masterPage Demo.Web.MasterPage.Views.MasterPage.dotmaster

1 Like

Thank you for your prompt response. I appreciate your attention to this matter.

To confirm that the issue is isolated and not influenced by other factors, I created a separate clean project containing only one MasterPage. Despite this, I still encounter the same problem.

Regarding the discrepancy in the exception message, I agree that it’s unusual for it to display the file path without the ‘embedded://’ prefix. This could indeed suggest a potential bug or an unexpected behavior in the DotVVM framework.

Here you can find the stack trace

Default.dothtml (1.7 KB)

I’m sorry, but I still don’t what could cause this. I have also tried in a new project, and it works for me (embeddedmasterpagetest.zip (7.4 KB)). If you already made the repro project, would you mind to share it here?

1 Like

Sure, Here (.zip file)

Thanks.

I see, I forgot we already fixed in 4.2.4 (#1754), you can upgrade to 4.2.6. I’m quite surprised that dotnet does not issue a warning about using 4.2.0, as it has a critical bug

1 Like

I’ll proceed with the upgrade to resolve the issue. Your support is greatly appreciated!

1 Like