DestyNova DestyNova - 6 days ago 4x Question

VS2015 - VB/ASP.NET Build fake error: "Type 'XYZ' is not defined" in UserControl code-behind

Ok guys, this one is not easy...

For the story, I got a old 3.5 ASP.NET/VB.NET website project (ASPX) build on VS2012 that I've upgraded to 4.5 to run well on VS2015.
I'm also trying to remove all the compilations errors that it got, even if the website was working under them (VB.NET is weird...)

During this operation, I've got some unchanged codes that worked well before but they don't let me run anymore.

So, here is the build problem:

I've got a UserControl (

), used in a page (
), that need some values from the MasterPage (

They all use the same namespace
, here are some excerpts to understand:

The MasterPage:

Namespace Vita

Partial Public Class private_MasterPage
Inherits System.Web.UI.MasterPage

Public _debug As Integer = HttpContext.Current.Request.Params("debug")

Public ReadOnly Property ModeDebug As Integer
Return _debug
End Get
End Property

The UserControl:

Namespace Vita

Public Class private_UserControls_FicheCRF_OngletAccueil
Inherits System.Web.UI.UserControl

Public ReadOnly Property modeDebug As Integer
Return DirectCast(Me.Page.Master, private_MasterPage).ModeDebug
End Get
End Property

The ASPX page:

<%@ Page Async="true" Title="" Language="VB" MasterPageFile="~/private/MasterPage.master" AutoEventWireup="false" CodeFile="ficheCRF.aspx.vb" Inherits="Vita.public_ficheCRF" %>

<%@ Register TagPrefix="VitaTools" TagName="OngletAccueil" Src="UserControls/FicheCRF/OngletAccueil.ascx" %>

With that, I got a compilation error about the MasterPage class type in the UserControl:
Type 'private_MasterPage' is not defined.

I don't even understand why it don't run the IISexpress when it was ok on previous framework...

I show you the code to make you understand that the code is not really the problem: it seems that the problem come from intelliSense or from the compilation temp files, like if the MasterPage class can't be seen (scope access) by the UserControl because they are not in the same temp assembly.

Before, I've got the same problem with a userControl used into another userControl (which files are saved in exactly the same folder...), but I was able to trick the compilator with a
setting, it seems to work:

<add tagPrefix="VitaTools" src="~/private/UserControls/FicheCRF/PosteUser.ascx" tagName="PosteUser" />
<add tagPrefix="VitaTools" src="~/private/UserControls/FicheCRF/NotesDeFrais.ascx" tagName="NotesDeFrais" />
<add tagPrefix="VitaTools" src="~/private/UserControls/FicheCRF/CrfEvals_CollaborateursInternes.ascx" tagName="EvalsCollaborateursInternes" />

But here, the MasterPage is not a control, it's a page, I can't use the same trick...

Thx for help guys, I've already spent a lot of time on it and I did analyzed a bunch of Q&A & MSDN docs before post it here, on this you're my last hope :'(

Here some last & useful infomation on the

<supportedRuntime version="v4.0"/>
<compilation debug="true" batch="false" strict="false" explicit="true" targetFramework="4.5">
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">


Ok guys, I got it, by changing PC...

I think the problem come from compilating the project on different versions of VS.

I did only one compilation of my project on 2012 and then the compilation on 2015 made this unbreakable error...

So even if you purge some temp folders like AppData\Local\Temp\Temporary ASP.NET Files, AppData\Local\Temp\VWDWebCache or .vs\project\v14\.suo, it's not enough.

After some more debug on others things that appeared, I can now compile with 0 errors and publish also after bit more debug. Now I'm on some other problems on runtime, it's still not fully working like before but it's getting closer ;)


What I did before worked for the compilation but it didn't solved the runtime (the bug came back on runtime as InvalidCastException).

To solve the runtime, I just checked the Build/Publish option "use fixed naming and single page assemblies" and it solved my case :)

Unckeck also the build (and publish) option "Allow this precompiled site to be updatable"

Here some useful links: