MediaSource doesn't contain any method - c#

I followed this tutorial: https://learn.microsoft.com/en-us/windows/uwp/audio-video-camera/media-playback-with-mediasource and copied following line:
mediaSource = MediaSource.CreateFromStorageFile(file);
But Visual Studio shows an error:
"The type name 'CreateFromStoargeFile' does not exist in the type 'MediaSource'"
And MediaSource doesn't contain any Method/Property/... The IntelliSense poup doesn't even show.
I guess there is something wrong with Visual Studio or the UniversalWindowsPlatform core. I let Visual Studio repair itself but it doesn't work.
Edit:
The metadata of MediaSource contains all methods though...
Solution:
I put the new keyword in front of the MediaSource...
I am ashamed of myself...

From your screenshots, it looks like you are using the new keyword in front of your method call.
Try removing that.

Related

What is unknown construction in class declaration?

I've just made a mistake while writing my code, and I find out some interesting unknown stuff.
public class OperationFactory(int code)
{
}
What (int code) it is here?
My compiler doesn't tell anything, so that's why I'm asking
I hope that You are not using Visual Studio IDE. are you?
I thought you are using Visual studio Code, need to install c# intelligence extensions if using other IDE's.
Compilation error. You may see warning if you are using Visual Studio IDE.
The Definition of class not allowing to take parameters msdn link
//[access modifier] - [class] - [identifier]
public class Customer
{
// Fields, properties, methods and events go here...
}

AutoMapper non-static conversion from static - MapperConfiguration, CreateMapper

I'm moving from a mixture of v2 & v4 AutoMapper static coding on .NET Framework 4, to version 6.0.1 using .NET Framework 4.6.2. I am running into problems in my conversion development under Visual Studio 2015.
var dummy = new MapperConfiguration(cfg => cfg.CreateMap<DateTime,string>());
Visual Studio tells me that MapperConfiguration.MapperConfiguration(Action<IMapperConfigurationExpression> configure) (+1 overload)
Constructor 'MapperConfiguration' has 0 parameter(s) but is invoked with 1 argument(s).
When I code the next line:
var dmy1 = dummy.CreateMapper();
Visual Studio tells me that IMapper MapperConfiguration.CreateMapper() (+1 overload) Cannot resolve symbol CreateMapper.
This is all basic non-static stuff, and I could use another pair of eyes giving me a heads up on what I'm missing. I'm thinking once I solve the problem with the first line of code, the other problem will go away. Ideas?
The problem goes away when I restart Visual Studio. There must have been something residual in the VS instance causing problems.
I has the same problem after Edmx update. The problem goes away after Visual Studio restart.

Visual Studio 2013 Extending Solution Explorer Filter

I'm trying to create a VsPackage with a custom filter for the solution explorer.
I followed the walkthrough on https://msdn.microsoft.com/en-us/library/hh966591.aspx to the latter, I see the button and I can click it but the filter is never applied. And I can't even debug it because no single method in the filter class is ever called.
Does anyone have experience writing a custom filter or maybe just had the same problem?
The command handler doesn't need to do anything, in fact you can remove the command binding, the filter is bound through the Guid/Id parameters of the SolutionTreeFilterProvider(guid, id) attribute.
Your case seems a bug of VS 2013 because in VS 2012 it works.
I have opened a bug report in MS Connect: https://connect.microsoft.com/VisualStudio/feedback/details/1131606
UPDATE: it's a bug in the documentation sample of VS 2013 that it's correct in VS 2012:
The first parameter should be of type SVsServiceProvider and not IServiceProvider:
[ImportingConstructor]
public FileNameFilterProvider(**SVsServiceProvider** serviceProvider, IVsHierarchyItemCollectionProvider hierarchyCollectionProvider)
{
ServiceProvider = serviceProvider;
this.HierarchyCollectionProvider = hierarchyCollectionProvider;
}

The var keyword not showing up in visual studio

I've installed a new instance of visual studio 2010 premium and everything seems to work fine when I load old projects. When I start to write new classes though, the var keyword is not working or showing up in intellisense. This is a new solution and no web project. (so no web.config) Target framework for the project is set to .net 4.0. When I try compiling it by writing
var x = "this";
I get "A get or set accessor expected" error.
Do I need to reinstall? Any ideas what could be wrong here?
You don't have parentheses after your method name so the compiler thinks you're defining a property.
public void Server_Test()
{
var ...
}

Web Api Content.ReadAsAsync method not found, but code compiles

I am using System.Net.Http.HttpClient to access a rest service. This code compiles and runs just fine:
var client = new HttpClient();
var result = client.GetAsync(ServiceUrl + "/whatever").Result;
var content = result.Content.ReadAsAsync<StatusReport>().Result;
However the ReadAsAsync method is colored red in my IDE, and intellisense cannot find it. I have made sure to update all of my nuget packages. Referenced and added using statement for System.Net.Http.Formatting, but error persists (and resharper tells me the using statement is unused).
I am not sure if this is a problem with visual studio 2012, or with resharper 7. Sometimes restarting visual studio helps, and sometimes it doesn't. I suspect I may have some older version of some assembly referenced, or something like that, but I have updated everything I know how and the problem is still intermittent.
What else can I try?
You must add reference from Nuget "ASP.NET Web API 2 Client". Microsoft.AspNet.WebApi.Client
Try clearing your resharper cache. (ReSharper > Options > Environment > General > Clear Caches)
HttpClient is new in 4.5 AFAIK and maybe your assemblies are cached from 4.0 or something?

Categories