Why "System.Environment.GetFolderPath(SpecialFolder)" method is not found during run time?

Chanumolu Bala Naren 1 Reputation point
2020-03-04T11:39:13.903+00:00

Hi,

I have a Progressive Web App(Universal Windows) which uses a Windows Runtime Component(Universal Windows). This Windows Runtime Component(Universal Windows) uses a .Net Standard library(.dll).

Properties of Progressive Web App(Universal Windows):
3801-5.png

After running Progressive Web App(Universal Windows), a button appears and when we click this button below code snippet executes in which a method from Windows Runtime Component(Universal Windows) is called.

function onClickbtn()  
{  
  var strPath=WinMDComponent.WinMDComp.getPath();  
}  

In Windows Runtime Component(Universal Windows) project i have the below code which calls a method from the .Net Standard library:

using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Text;  
using System.Threading.Tasks;  

namespace WinMDComponent  
{  
    public sealed class WinMDComp  
    {  
        public static string getPath()  
        {  
            return NetStandard2Component.NetStand2Comp.getDataPath();  
        }  
    }  
}  

in .Net Standard project i have the below code:

using System;  

namespace NetStandard2Component  
{  
    public class NetStand2Comp  
    {  
        public static string getDataPath()  
        {  
            return Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);  
        }  
    }  
}  

Problem Description:

1.If i keep the minimum version of Windows Runtime Component(Universal Windows) project as 10240 (Target Version is always 16299) , i had to add "netstandard.dll" as a reference in Windows Runtime Component(Universal Windows) project and after running Progressive Web App(Universal Windows) project i got below error

3811-one.png

2.If i keep the minimum version of Windows Runtime Component(Universal Windows) project as 16299 (Target Version is always 16299) , i don't need to add "netstandard.dll" as a reference in Windows Runtime Component(Universal Windows) project and if run Progressive Web App(Universal Windows) project i got below error:

3821-2.png

Can anyone help me to solve this problem?

Universal Windows Platform (UWP)
{count} votes