Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected character encountered while parsing number: W. Path '' - Visual Studio Mac #874

Closed
jthake opened this issue Jul 4, 2018 · 8 comments

Comments

@jthake
Copy link

jthake commented Jul 4, 2018

I have just installed for first time on my iMac Visual Studio for Mac 7.5.3 (build 7).

I created a new Azure Functions project. I run it up in a debugger. When I call the default httptrigger in postman I get this error

[7/4/18 9:18:26 PM] Executing 'HttpTrigger' (Reason='This function was programmatically called via the host APIs.', Id=32ee26bd-13b2-4979-b32a-66ba4e49f517)
[7/4/18 9:18:26 PM] C# HTTP trigger function processed a request.
[7/4/18 9:18:29 PM] Executed 'HttpTrigger' (Failed, Id=32ee26bd-13b2-4979-b32a-66ba4e49f517)
[7/4/18 9:18:29 PM] System.Private.CoreLib: Exception while executing function: HttpTrigger. Newtonsoft.Json: Unexpected character encountered while parsing number: W. Path '', line 1, position 6.

From searching around. There appears to be a related error around it using the 1.0.13 version of the Microsoft.NET.Sdk.Functions in a Windows version of Visual Studio. It just seems odd that the default new project would set these if they were not correct?

The csproj file looks like this

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <AzureFunctionsVersion>v2</AzureFunctionsVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.13" />
  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
</Project>

My dotnet version is:

e$ dotnet --info
.NET Command Line Tools (2.1.4)

Product Information:
 Version:            2.1.4
 Commit SHA-1 hash:  5e8add2190

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.13
 OS Platform: Darwin
 RID:         osx.10.12-x64
 Base Path:   /usr/local/share/dotnet/sdk/2.1.4/

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.5
  Build    : 17373eb129b3b05aa18ece963f8795d65ef8ea54

Full debug terminal window

Hosting environment: Production
Content root path: /Users/jeremythake/Projects/YouStorianAPI/YouStorianAPI/bin/Debug/netstandard2.0
Now listening on: http://localhost:7071
Application started. Press Ctrl+C to shut down.
[7/4/18 9:18:20 PM] Reading host configuration file '/Users/jeremythake/Projects/YouStorianAPI/YouStorianAPI/bin/Debug/netstandard2.0/host.json'
[7/4/18 9:18:20 PM] Host configuration file read:
[7/4/18 9:18:20 PM] {}
[7/4/18 9:18:20 PM] Starting Host (HostId=jeremysimac-749503778, InstanceId=151bf265-a4b1-41ee-b2a4-5c023d154fb1, Version=2.0.11651.0, ProcessId=3900, AppDomainId=1, Debug=False, ConsecutiveErrors=0, StartupCount=1, FunctionsExtensionVersion=)
[7/4/18 9:18:21 PM] Unable to configure java worker. Could not find JAVA_HOME app setting.
[7/4/18 9:18:21 PM] 
[7/4/18 9:18:21 PM] Could not configure language worker Java.
[7/4/18 9:18:21 PM] 
[7/4/18 9:18:21 PM] Generating 1 job function(s)
[7/4/18 9:18:21 PM] Found the following functions:
[7/4/18 9:18:21 PM] YouStorianAPI.HttpTrigger.Run
[7/4/18 9:18:21 PM] 
[7/4/18 9:18:21 PM] Host initialized (1029ms)
Listening on http://localhost:7071/
Hit CTRL-C to exit...

Http Functions:

	HttpTrigger: http://localhost:7071/api/HttpTrigger

[7/4/18 9:18:22 PM] Host started (1511ms)
[7/4/18 9:18:22 PM] Job host started
[7/4/18 9:18:26 PM] Executing 'HttpTrigger' (Reason='This function was programmatically called via the host APIs.', Id=32ee26bd-13b2-4979-b32a-66ba4e49f517)
[7/4/18 9:18:26 PM] C# HTTP trigger function processed a request.
[7/4/18 9:18:29 PM] Executed 'HttpTrigger' (Failed, Id=32ee26bd-13b2-4979-b32a-66ba4e49f517)
[7/4/18 9:18:29 PM] System.Private.CoreLib: Exception while executing function: HttpTrigger. Newtonsoft.Json: Unexpected character encountered while parsing number: W. Path '', line 1, position 6.
@jthake
Copy link
Author

jthake commented Jul 4, 2018

UPDATE: I right clicked in Visual Studio for Mac and updated the nuget package for Microsoft.NET.Sdk.Functions 1.0.14. I cleaned my build, rebuilt and ran.
Now when I run the function. I get this error

[7/4/18 9:40:41 PM] System.Private.CoreLib: Exception while executing function: HttpTrigger. YouStorianAPI: Could not load file or assembly 'Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621). System.Private.CoreLib: Could not load file or assembly 'Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'.

I can see if i expand the nuget package that its pulled down Newtonsoft.Json (11.0.2). If I try and add the nuget package for 11.0.0 it does not exist as an available package.

I'm sure this is something silly. Can someone point me in the correct direction?

I used brew to update the CLI as described too. That didn't seem to fix anything either.

@ianadavies
Copy link

ianadavies commented Jul 12, 2018

Take a look at my post here

The suggested fix worked for me.

@jthake
Copy link
Author

jthake commented Jul 12, 2018

Thanks @ianadavies but unfortunately I had updated to the latest CLI too and still same error.

@LeviSchuck
Copy link

I am experiencing the same problem.

This has been recorded in https://youtu.be/v4DuNIA8dG4

I documented it in Azure/azure-functions-vs-build-sdk#218 though it seems issues on this repo are being ignored.

I encounter this problem if

  1. I upgrade to .14
  2. OR I add <PackageReference Include="Newtonsoft.Json" Version="11.0.2" /> while on .13

@LeviSchuck
Copy link

This SO post refers to the CLI version being to blame
https://stackoverflow.com/questions/51304256/azure-functions-newtonsoft-json-load-error?rq=1
Indeed my output states
Starting Host (HostId=levismacbook-144611310, InstanceId=a2531763-6b68-4424-9ccf-79ea75a2e5a3, Version=2.0.11651.0, ProcessId=88078, AppDomainId=1, Debug=False, ConsecutiveErrors=0, StartupCount=1, FunctionsExtensionVersion=)
which this SO post blames (2.0.11651.0)

I tried reinstalling the utilities, however I see

Warning: azure/functions/azure-functions-core-tools 2.0.1-beta.34 is already installed and up-to-date
To reinstall 2.0.1-beta.34, run `brew reinstall azure-functions-core-tools`

func reports version 2.0.11946.0
So I seem to have a newer CLI version than what visual studio Mac uses.

@JohnReeson
Copy link

@jthake-msft @LeviSchuck Have you tried to run func start in your content root path shown in your cli output like [ProjectPath]/bin/Debug/netstandard2.0? Json.Net v11 works with azure-functions-core-tools 2.0.1-beta.34 on my side.

@LeviSchuck
Copy link

Hello @JohnReeson
I tried two things, I changed the update channel to visual studio for Mac to Alpha, and also ran that command.
Either or both of those unblocked this issue as a work around.

@fabiocav
Copy link
Member

Closing this as this was on a pre-release version of the core tools. Please retry and open a new issue if you're still running into problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants