Box SDK for .net - VB.net Async / Await issue
回答済みHi,
I searched, but I can't find an existing answer to this newbie question. I'm trying to return a collection of all metadata templates. I have two in my test environment. My code fails at the GetEnterpriseMetadataAsync line. Either I add async to the sub this is running within or remove the Await modifier, but neither work.
Please advise on the correct approach to working with async methods in the SDK.
Const DevToken As String = "abc1234" Dim BoxConfig As New Box.V2.Config.BoxConfig("abc1234", "abc1234", New System.Uri("https://www.mysite.com/")) Dim BoxSession As New Box.V2.Auth.OAuthSession(DevToken, "NOT_NEEDED", 3600, "bearer") Dim BoxClient As New Box.V2.BoxClient(BoxConfig, BoxSession) Dim MetaDataMgr As Box.V2.Managers.BoxMetadataManager
MetaDataMgr = BoxClient.MetadataManager Dim AllTemplates = Await MetaDataMgr.GetEnterpriseMetadataAsync("enterprise")
-
Answered my own question. I forgot to install Microsoft.Bcl.Async. Once that was installed, this code works:
Const DevToken As String = "abc123" Dim BoxConfig As New Box.V2.Config.BoxConfig("abc123", "abc123", New System.Uri("https://localhost/")) Dim BoxSession As New Box.V2.Auth.OAuthSession(DevToken, "NOT_NEEDED", 3600, "bearer") Dim BoxClient As New Box.V2.BoxClient(BoxConfig, BoxSession) Dim MetaDataMgr As Box.V2.Managers.BoxMetadataManager Dim AllTemplates As Box.V2.Models.BoxEnterpriseMetadataTemplateCollection(Of Box.V2.Models.BoxMetadataTemplate) MetaDataMgr = BoxClient.MetadataManager AllTemplates = Await MetaDataMgr.GetEnterpriseMetadataAsync("enterprise")
サインインしてコメントを残してください。
コメント
1件のコメント