C# Microsoft.CSharp.RuntimeBinder.RuntimeBinderException:&x27;无法对空引用执行运行时绑定';

C# Microsoft.CSharp.RuntimeBinder.RuntimeBinderException:&x27;无法对空引用执行运行时绑定';,c#,wpf,api,C#,Wpf,Api,我从OMDB API获得电影API,我想将API中的数据分配给字符串 Microsoft.CSharp.RuntimeBinder.RuntimeBinderException:“无法对空引用执行运行时绑定” 但我得到了这个错误。解决办法是什么 public主视图模型() { SearchCommand=newrelayCommand((e)=> { HttpResponseMessage response=新的HttpResponseMessage(); var name=SearchText

我从OMDB API获得电影API,我想将API中的数据分配给字符串

Microsoft.CSharp.RuntimeBinder.RuntimeBinderException:“无法对空引用执行运行时绑定” 但我得到了这个错误。解决办法是什么

public主视图模型()
{
SearchCommand=newrelayCommand((e)=>
{
HttpResponseMessage response=新的HttpResponseMessage();
var name=SearchText;
response=http.GetAsync($@)http://www.omdbapi.com/?apikey=a91a5037&t={name}&plot=full”)。结果;
var str=response.Content.ReadAsStringAsync().Result;
Data=JsonConvert.DeserializeObject(str);
MoviePosterPath=Data.Search[0].Poster;//我在这里遇到错误
MovieTitle=数据。搜索[0]。标题;
MovieIMDB=Data.Search[0].imdbRating;
MovieYear=Data.Search[0]。已发布;
});
} 
根据您想要通过
搜索获得详细信息的信息。在这种情况下,url中的参数应为
s
而不是
t

response = http.GetAsync($@"http://www.omdbapi.com/?apikey=a91a5037&s={name}&plot=full").Result;
代码的其余部分可以保持不变