question

Chiranjeevi avatar image
Chiranjeevi asked

Error CS0246: The type or namespace name 'PlayFabApiSettings' could not be found

Just learning Azure Function from this link and followed the sample TICTACTOE. Both samples worked without any issues, then created my own project and ran into bunch of errors as below.

D:\Unity\Playfab_CloudFunctions\Util\Settings.cs(8,44): error CS0246: The type or namespace name 'PlayFabApiSettings' could not be found (are you missing a using directive or an assembly reference?) [D:\Unity\Playfab_CloudFunctions\Playfab_CloudFunctions.csproj]
D:\Unity\Playfab_CloudFunctions\Util\Settings.cs(18,44): error CS0246: The type or namespace name 'PlayFabApiSettings' could not be found (are you missing a using directive or an assembly reference?) [D:\Unity\Playfab_CloudFunctions\Playfab_CloudFunctions.csproj]
D:\Unity\Playfab_CloudFunctions\Util\GetGameTitleData.cs(9,101): error CS0246: The type or namespace name 'PlayFabApiSettings' could not be found (are you missing a using directive or an assembly reference?) [D:\Unity\Playfab_CloudFunctions\Playfab_CloudFunctions.csproj]
D:\Unity\Playfab_CloudFunctions\Util\PlayerUserData.cs(10,127): error CS0246: The type or namespace name 'PlayFabApiSettings' could not be found (are you missing a using directive or an assembly reference?) [D:\Unity\Playfab_CloudFunctions\Playfab_CloudFunctions.csproj]
D:\Unity\Playfab_CloudFunctions\Util\PlayerUserData.cs(10,159): error CS0246: The type or namespace name 'PlayFabAuthenticationContext' could not be found (are you missing a using directive or an assembly reference?) [D:\Unity\Playfab_CloudFunctions\Playfab_CloudFunctions.csproj]
D:\Unity\Playfab_CloudFunctions\InitPlayerData.cs(9,10): error CS0246: The type or namespace name 'FunctionNameAttribute' could not be found (are you missing a using directive or an assembly reference?) [D:\Unity\Playfab_CloudFunctions\Playfab_CloudFunctions.csproj]
D:\Unity\Playfab_CloudFunctions\InitPlayerData.cs(9,10): error CS0246: The type or namespace name 'FunctionName' could not be found (are you missing a using directive or an assembly reference?) [D:\Unity\Playfab_CloudFunctions\Playfab_CloudFunctions.csproj]
D:\Unity\Playfab_CloudFunctions\InitPlayerData.cs(11,78): error CS0246: The type or namespace name 'HttpRequest' could not be found (are you missing a using directive or an assembly reference?) [D:\Unity\Playfab_CloudFunctions\Playfab_CloudFunctions.csproj]
D:\Unity\Playfab_CloudFunctions\InitPlayerData.cs(12,13): error CS0246: The type or namespace name 'ILogger' could not be found (are you missing a using directive or an assembly reference?) [D:\Unity\Playfab_CloudFunctions\Playfab_CloudFunctions.csproj]
D:\Unity\Playfab_CloudFunctions\InitPlayerData.cs(10,29): error CS0246: The type or namespace name 'Task<>' could not be found (are you missing a using directive or an assembly reference?) [D:\Unity\Playfab_CloudFunctions\Playfab_CloudFunctions.csproj]
D:\Unity\Playfab_CloudFunctions\InitPlayerData.cs(10,34): error CS0246: The type or namespace name 'IActionResult' could not be found (are you missing a using directive or an assembly reference?) [D:\Unity\Playfab_CloudFunctions\Playfab_CloudFunctions.csproj]
D:\Unity\Playfab_CloudFunctions\Util\PlayerUserData.cs(29,118): error CS0246: The type or namespace name 'PlayFabApiSettings' could not be found (are you missing a using directive or an assembly reference?) [D:\Unity\Playfab_CloudFunctions\Playfab_CloudFunctions.csproj]
D:\Unity\Playfab_CloudFunctions\Util\PlayerUserData.cs(29,150): error CS0246: The type or namespace name 'PlayFabAuthenticationContext' could not be found (are you missing a using directive or an assembly reference?) [D:\Unity\Playfab_CloudFunctions\Playfab_CloudFunctions.csproj]
D:\Unity\Playfab_CloudFunctions\Util\PlayerUserData.cs(52,116): error CS0246: The type or namespace name 'PlayFabApiSettings' could not be found (are you missing a using directive or an assembly reference?) [D:\Unity\Playfab_CloudFunctions\Playfab_CloudFunctions.csproj]
D:\Unity\Playfab_CloudFunctions\Util\PlayerUserData.cs(52,148): error CS0246: The type or namespace name 'PlayFabAuthenticationContext' could not be found (are you missing a using directive or an assembly reference?) [D:\Unity\Playfab_CloudFunctions\Playfab_CloudFunctions.csproj]
D:\Unity\Playfab_CloudFunctions\Util\PlayerUserData.cs(70,126): error CS0246: The type or namespace name 'PlayFabApiSettings' could not be found (are you missing a using directive or an assembly reference?) [D:\Unity\Playfab_CloudFunctions\Playfab_CloudFunctions.csproj]
D:\Unity\Playfab_CloudFunctions\Util\PlayerUserData.cs(70,158): error CS0246: The type or namespace name 'PlayFabAuthenticationContext' could not be found (are you missing a using directive or an assembly reference?) [D:\Unity\Playfab_CloudFunctions\Playfab_CloudFunctions.csproj]
D:\Unity\Playfab_CloudFunctions\InitPlayerData.cs(11,14): error CS0246: The type or namespace name 'HttpTriggerAttribute' could not be found (are you missing a using directive or an assembly reference?) [D:\Unity\Playfab_CloudFunctions\Playfab_CloudFunctions.csproj]
D:\Unity\Playfab_CloudFunctions\InitPlayerData.cs(11,14): error CS0246: The type or namespace name 'HttpTrigger' could not be found (are you missing a using directive or an assembly reference?) [D:\Unity\Playfab_CloudFunctions\Playfab_CloudFunctions.csproj]
D:\Unity\Playfab_CloudFunctions\InitPlayerData.cs(11,26): error CS0103: The name 'AuthorizationLevel' does not exist in the current context [D:\Unity\Playfab_CloudFunctions\Playfab_CloudFunctions.csproj]
D:\Unity\Playfab_CloudFunctions\InitPlayerData.cs(11,63): error CS0246: The type or namespace name 'Route' could not be found (are you missing a using directive or an assembly reference?) [D:\Unity\Playfab_CloudFunctions\Playfab_CloudFunctions.csproj]
The terminal process "C:\Program Files\dotnet\dotnet.exe 'build', '/property:GenerateFullPaths=true', '/consoleloggerparameters:NoSummary'" terminated with exit code: 1.

Playfab_CloudFunctions.csproj

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
    <DefineConstants>NETCOREAPP2_0</DefineConstants>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="PlayFabAllSDK" Version="1.107.211209"/>
    <PackageReference Include="PlayFabCloudScriptPlugin" Version="1.53.190627-alpha"/>
    <PackageReference Include="Azure.Core" Version="1.21.0"/>
    <PackageReference Include="NETStandard.Library" Version="2.0.3"/>
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.0.1"/>
  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
</Project>

host.json

{
    "version": "2.0",
    "extensions": {
        "http": {
            "routePrefix": "api"
        }
    },
    "logging": {
        "applicationInsights": {
            "samplingSettings": {
                "isEnabled": true,
                "excludedTypes": "Request"
            }
        }
    }
}

How do i resolve this?

CloudScript
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Seth Du avatar image
Seth Du answered

PlayFabCloudScriptPlugin is no longer supported as it requires additional dependencies, please remove it first.

If you follow the instruction on PlayFab CloudScript using Azure Functions Quickstart Guide - PlayFab | Microsoft Docs, only PlayFabAllSDK is required for the Azure Function, meanwhile we also suggest importing CS2AFHelperClasses.cs to help handle the request and arguments.(which also should be the aim of PlayFabCloudScriptPlugin)

TICTACTOE is a test project for preview 2 years ago and please completely follow the official document to build your project.

Feel free to let me know if you still have this issue.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Chiranjeevi avatar image
Chiranjeevi answered

Why im unable to edit my question after posting it?

Update log:

D:\Unity\Playfab_CloudFunctions\Util\Settings.cs(8,44): error CS0246: The type or namespace name 'PlayFabApiSettings' could not be found (are you missing a using directive or an assembly reference?) [D:\Unity\Playfab_CloudFunctions\Playfab_CloudFunctions.csproj]
D:\Unity\Playfab_CloudFunctions\Util\Settings.cs(18,44): error CS0246: The type or namespace name 'PlayFabApiSettings' could not be found (are you missing a using directive or an assembly reference?) [D:\Unity\Playfab_CloudFunctions\Playfab_CloudFunctions.csproj]
D:\Unity\Playfab_CloudFunctions\Util\GetGameTitleData.cs(14,101): error CS0246: The type or namespace name 'PlayFabApiSettings' could not be found (are you missing a using directive or an assembly reference?) [D:\Unity\Playfab_CloudFunctions\Playfab_CloudFunctions.csproj]
D:\Unity\Playfab_CloudFunctions\InitPlayerData.cs(18,13): error CS0246: The type or namespace name 'ILogger' could not be found (are you missing a using directive or an assembly reference?) [D:\Unity\Playfab_CloudFunctions\Playfab_CloudFunctions.csproj]
D:\Unity\Playfab_CloudFunctions\Util\PlayerUserData.cs(15,127): error CS0246: The type or namespace name 'PlayFabApiSettings' could not be found (are you missing a using directive or an assembly reference?) [D:\Unity\Playfab_CloudFunctions\Playfab_CloudFunctions.csproj]
D:\Unity\Playfab_CloudFunctions\Util\PlayerUserData.cs(15,159): error CS0246: The type or namespace name 'PlayFabAuthenticationContext' could not be found (are you missing a using directive or an assembly reference?) [D:\Unity\Playfab_CloudFunctions\Playfab_CloudFunctions.csproj]
D:\Unity\Playfab_CloudFunctions\Util\PlayerUserData.cs(34,118): error CS0246: The type or namespace name 'PlayFabApiSettings' could not be found (are you missing a using directive or an assembly reference?) [D:\Unity\Playfab_CloudFunctions\Playfab_CloudFunctions.csproj]
D:\Unity\Playfab_CloudFunctions\Util\PlayerUserData.cs(34,150): error CS0246: The type or namespace name 'PlayFabAuthenticationContext' could not be found (are you missing a using directive or an assembly reference?) [D:\Unity\Playfab_CloudFunctions\Playfab_CloudFunctions.csproj]
D:\Unity\Playfab_CloudFunctions\Util\PlayerUserData.cs(57,116): error CS0246: The type or namespace name 'PlayFabApiSettings' could not be found (are you missing a using directive or an assembly reference?) [D:\Unity\Playfab_CloudFunctions\Playfab_CloudFunctions.csproj]
D:\Unity\Playfab_CloudFunctions\Util\PlayerUserData.cs(57,148): error CS0246: The type or namespace name 'PlayFabAuthenticationContext' could not be found (are you missing a using directive or an assembly reference?) [D:\Unity\Playfab_CloudFunctions\Playfab_CloudFunctions.csproj]
D:\Unity\Playfab_CloudFunctions\Util\PlayerUserData.cs(75,126): error CS0246: The type or namespace name 'PlayFabApiSettings' could not be found (are you missing a using directive or an assembly reference?) [D:\Unity\Playfab_CloudFunctions\Playfab_CloudFunctions.csproj]
D:\Unity\Playfab_CloudFunctions\Util\PlayerUserData.cs(75,158): error CS0246: The type or namespace name 'PlayFabAuthenticationContext' could not be found (are you missing a using directive or an assembly reference?) [D:\Unity\Playfab_CloudFunctions\Playfab_CloudFunctions.csproj]
The terminal process "C:\Program Files\dotnet\dotnet.exe 'build', '/property:GenerateFullPaths=true', '/consoleloggerparameters:NoSummary'" terminated with exit code: 1.
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Chiranjeevi avatar image Chiranjeevi commented ·

Ive figured it out that PlayFabServerInstanceAPI comes under Playfab namespace as sample TICTACTOE namespace of PlayFab.TicTacToe

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.