IOptions<Applications> does not contain definition 'Options' in ASP.NET 5 Beta 8

故事扮演 提交于 2019-12-24 15:03:27

问题


Problem

I am having trouble with upgrading my beta7 application to beta8. I orginally had over 50 errors, but I have basically gotten it down to two persistent errors remaining that I have been unable to resolve. One is with Options.

Options Missing Error

Here is the error:

Error CS1061 'IOptions<ApplicationSettings>' does not contain a definition for 'Options' and no extension method 'Options' accepting a first argument of type 'IOptions<ApplicationSettings>' could be found (are you missing a using directive or an assembly reference?) SampleProject.DNX 4.5.1

Here is the code:

private IOptions<ApplicationSettings> _applicationSettings;

// Authenticate user credentials against Active Directory
bool isAuthenticated = await Authentication.ValidateCredentialsAsync(
                domainController: _applicationSettings.Options.DomainController,
                port: _applicationSettings.Options.DomainControllerSslPort,
                domain: _applicationSettings.Options.DomainController,
                username: model.eID,
                password: model.Password);

The specific problem above is with _applicationSettings.Options.DomainController

Attempts:

I tried the following things:

  • I tried using intellisense and GitHub to find where 'Options' for IOptions went, but I have been unsuccessful.
  • I also tried dnu restore just to be sure the upgrade didn't do something strange with my project.json lock.

Now that beta8 is feature complete, I may rewrite significant portions of my project. However, for now I need to resolve these errors so that I can compile the project again. Any help, assistance, and advice rendered would be greatly appreciated.

Note: I edited this to one question based on feedback


回答1:


The Options property of IOptions<T> was renamed to Value. Try:

_applicationSettings.Value

Also see this issue.



来源:https://stackoverflow.com/questions/33348852/ioptionsapplications-does-not-contain-definition-options-in-asp-net-5-beta-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!