Jump to content

there is one gripe with 'AsSpan()'


chef

Recommended Posts

chef

Edit please read last comment.

 

 

 

 

HI guys, 

 

I'm not sure why, but when I update to the recent nuget package 4.2.0.20 in my plugin, ILibraryManager has an error asking me to install 'System.Memory' reference.

 

I have to move backwards two updates to get my plugin to play nice.

 

But, then I run into an issue where 'UserManager.GetUserByName' seems to no longer exists as a functional endpoint in the Api.. and I get an error in my logs:

2019-08-14 19:18:54.865 Error HttpServer: Error processing request
	*** Error Report ***
	Version: 4.2.1.0
	Command line: C:\Users\MediaServer\AppData\Roaming\Emby-Server\system\EmbyServer.dll -noautorunwebapp
	Operating system: Microsoft Windows NT 6.1.7601 Service Pack 1
	64-Bit OS: True
	64-Bit Process: True
	User Interactive: True
	Runtime: file:///C:/Users/MediaServer/AppData/Roaming/Emby-Server/system/System.Private.CoreLib.dll
	Processor count: 8
	Program data path: C:\Users\MediaServer\AppData\Roaming\Emby-Server\programdata
	Application directory: C:\Users\MediaServer\AppData\Roaming\Emby-Server\system
	System.MissingMethodException: System.MissingMethodException: Method not found: 'MediaBrowser.Controller.Entities.User MediaBrowser.Controller.Library.IUserManager.GetUserByName(System.String)'.
	   at AlexaController.API.AlexaApi.PlayMediaItemAsync(String device, String type)
	   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
	   at AlexaController.API.AlexaApi.PlayMediaItemAsync(String device, String type)
	   at AlexaController.API.AlexaApi.Post(AlexaRequest request)
	   at Emby.Server.Implementations.Services.ServiceController.Execute(HttpListenerHost appHost, Object requestDto, IRequest req)
	   at Emby.Server.Implementations.Services.ServiceHandler.ProcessRequestAsync(HttpListenerHost appHost, IRequest httpReq, IResponse httpRes, RestPath restPath, String responseContentType, CancellationToken cancellationToken)
	   at Emby.Server.Implementations.HttpServer.HttpListenerHost.RequestHandler(IRequest httpReq, ReadOnlyMemory`1 urlString, ReadOnlyMemory`1 host, ReadOnlyMemory`1 localPath, CancellationToken cancellationToken)
	Source: AlexaController
	TargetSite: Void MoveNext()
	
Edited by chef
Link to comment
Share on other sites

chef

Okay, upon further inspection it is because the UserManager.GetUserByName wants a ReadOnlySpan<> of char instead of string... why?

 

Edit: weird, There is a missing reference to 'System.Memory'

 

Is this because of beta server?

Edited by chef
Link to comment
Share on other sites

chef

Looks like it could be that I'm targeting .netStandard 2.0, and this reference is only in 2.1 preview.

Link to comment
Share on other sites

chef

And Finally it is possible that you have to Call "AsSpan()" on a string inorder to properly use these LibrarayManagers now...

 

Okay I have a gripe.This code is long winded! I just want the user Id and I'm convering a string to a Span to get a GUID and then finally converting it to a string! 

            var user = "Admin";
            var command = new PlaystateRequest()
            {
                Command = psCmd,
                ControllingUserId = UserManager.GetUserByName(user.AsSpan()).Id.ToString()
            };
Edited by chef
Link to comment
Share on other sites

BillOatman

Yeah I bumped into this as well with calls to GetUserByName() and trying to balance system.memory and 4.2.0.40.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...