WARNING #7006

    The Named argument %1 was not resolved and corresponds to the following expression %2

    Description

    Both VB6 and VB.Net have support for Named parameters, which allow parameters to be especified by name and in any order, regardless of method signature. In C# versions 1 through 3.5 this feature is not supported. In most cases VBUC can resolve this issue by matching named parameters to method signatures and ensuring parameters are sent in the right overload / order. However, in certain cases where the VBUC cannot resolve references to methods with named parameters then this EWI is emitted.

    Recommendations

    For C# migrations the VBUC generally creates a series of method overloads that mimic the behavior of named parameters. This is normal behavior as it is the best approximation of optional named parameters in C#. Workarounds for this EWI include reordering parameters and using the Type.Missing reference for optional parameters that should be omitted. In cases where the reference could not be resolved this is particularly important. Since, this EWI is related to the VBUC not being able to find mapped references, ensuring that the machine doing the migration has access to all dependent assemblies and COM objects is essential. Repeating the migration once this has been correct can reduce or eliminate the occurrence of these EWIs

    Reference documentation for sample code:

    Since this EWI only appears in C#, an example will be shown just for that language.

    Sample VB6

    Public Function LoginIntoMAPI(ByVal strProfile As String, ByVal strPassword As String) As MAPI.Session
        On Error GoTo error_olemsg
        'LoginIntoMAPI As MAPI.Session
        Set LoginIntoMAPI = CreateObject("MAPI.Session")
        If Not LoginIntoMAPI Is Nothing Then
            If strProfile <> "" And strPassword <> "" Then
                'Known reference
                LoginIntoMAPI.Logon showDialog:=False, profileName:=strProfile, profilePassword:=strPassword, newSession:=False
                
                'Unknown reference
                LoginIntoMAPI2.Logon showDialog:=False, profileName:=strProfile, profilePassword:=strPassword, newSession:=False
            Else
                Err.Raise 1273, "Cannot logon to email system: no profile name or password"
            End If
        End If
        Exit Function
    error_olemsg:
        LoginIntoMAPI = Nothing
    End Function
    

    Target C#

    public MAPI.Session LoginIntoMAPI(string strProfile, string strPassword)
    {
    	MAPI.Session result = null;
    	object LoginIntoMAPI2 = null;
    	try
    	{
    		//LoginIntoMAPI As MAPI.Session
    		result = new MAPI.Session();
    		if (result != null)
    		{
    			if (strProfile != "" && strPassword != "")
    			{
    				//Known reference
    				result.Logon(strProfile, strPassword, false, false, Type.Missing, Type.Missing, Type.Missing);
    
    				//Unknown reference
    				//UPGRADE_WARNING: (7006) The Named argument newSession was not resolved and corresponds to the following expression False.
    				//UPGRADE_WARNING: (7006) The Named argument profilePassword was not resolved and corresponds to the following expression strPassword.
    				//UPGRADE_WARNING: (7006) The Named argument profileName was not resolved and corresponds to the following expression strProfile.
    				//UPGRADE_WARNING: (7006) The Named argument showDialog was not resolved and corresponds to the following expression False.
    				//UPGRADE_TODO: (1067) Member Logon is not defined in type Variant.
    				LoginIntoMAPI2.Logon(false, strProfile, strPassword, false);
    			}
    			else
    			{
    				throw new System.Exception("1273, Cannot logon to email system: no profile name or password, ");
    			}
    		}
    	}
    	catch
    	{
    		return result;
    	}
    }
    
    The following code shows how EWI can be addressed in this case:
    public MAPI.Session LoginIntoMAPI(string strProfile, string strPassword)
    {
    	MAPI.Session result = null;
    	object LoginIntoMAPI2 = null;
    	try
    	{
    		//LoginIntoMAPI As MAPI.Session
    		result = new MAPI.Session();
    		if (result != null)
    		{
    			if (strProfile != "" && strPassword != "")
    			{
    				//Known reference
    				result.Logon(strProfile, strPassword, false, false, Type.Missing, Type.Missing, Type.Missing);
    
    				//Unknown reference
    				LoginIntoMAPI2.Logon(false, strProfile, strPassword, false, Type.Missing, Type.Missing, Type.Missing);
    			}
    			else
    			{
    				throw new System.Exception("1273, Cannot logon to email system: no profile name or password, ");
    			}
    		}
    	}
    	catch
    	{
    		return result;
    	}
    }
    

    Download VBUC Free Trial
    Download VBUC Now

    It's time to eradicate VB6
    ROI of eradicating VB6

    8 Proven Tips for
    Planning a Successful Migration

    8 Tips for migration