PureMVC Architects Lounge

PureMVC Manifold => Standard Version => Topic started by: Sabine on February 14, 2011, 02:54:07



Title: Problems with VB.Net
Post by: Sabine on February 14, 2011, 02:54:07
Hi,

as programming language I'm using VB.Net. Usually the C#-libraries can be used with out any problems.

I now wanted to try PureMVC and started porting the EmployeeAdmin-WPF-Demo to VB.Net.
In the ApplicationFacde I have the problem that I cannot access the "m_instance" from the Facade.
I can access "m_controller", "m_model", "m_view" and also "m_staticSyncRoot".

The error-message is "The type of the field 'm_instance' is not supported".

The class so far:

:
Imports PureMVC.Core
Imports PureMVC.Patterns
Imports PureMVC.Interfaces

Public Class ApplicationFacade
    Inherits Facade

#Region "Notification name constants"
    Public Const STARTUP As String = "startup"
#End Region


#Region "Accessors"

    '/// <summary>
    '/// Facade Singleton Factory method.
    '/// </summary>
    Public Shared Function GetInstance() As IFacade
        If m_instance Is Nothing Then
            m_instance = New ApplicationFacade
        End If
    End Function

#End Region

End Class

Why is "m_instance" not accessable?

Regards
Sabine


Title: Re: Problems with VB.Net
Post by: puremvc on February 14, 2011, 08:10:06
Hoping Adam may be able to help with this one...

-=Cliff>


Title: Re: Problems with VB.Net
Post by: adamczak on February 14, 2011, 06:53:15
The code for the instance method in c# looks like this, so you need to do something similar in VB.

:

/// <summary>
/// Facade Singleton Factory method.  This method is thread safe.
/// </summary>
public new static IFacade Instance
{
get
{
if (m_instance == null)
{
lock (m_staticSyncRoot)
{
if (m_instance == null) m_instance = new ApplicationFacade();
}
}

return m_instance;
}
}


I will take a look and see what I can figure out later on tonight....


Title: Re: Problems with VB.Net
Post by: Sabine on February 18, 2011, 01:38:19
Yes, this is exactly the method I tried to implement in VB.Net.
I just skiped the "lock"-statement.


Title: Re: Problems with VB.Net
Post by: adamczak on February 18, 2011, 09:42:21
I can't find any information on why this might be a problem.  The only thing I can think of is that m_instance is a static (shared) variable.  So maybe you have to access it that way even though you are in a static (shared) method.  Did you try doing something like "Facade.m_instance ="?

That's really the only thing that comes to mind....


Title: Re: Problems with VB.Net
Post by: Sabine on February 21, 2011, 07:08:11
With "Facade. " I can only access "Facade.m_staticSyncRoot".