I just installed Visual Studio 2012 so I could take advantage of better ways to implement MVVM with Silverlight.
The first thing I wanted to do is start using the [CallerMemberName] attribute so I didn't have to hard-code property name strings.
I created a new Silverlight app, created a new class, included 'using System.Runtime.CompilerServices', and proceeded to type [CallerMemberName]. However, I get the error:
"The type or namespace name 'CallerMemberNameAttribute' could not be found (are you missing a using directive or an assembly reference?)"
However, I did include the using directive and there are no other assemblies that need to be referenced.
This is driving me up the wall since no Google search returned any information about why I might not be able to use it in VS2012/Silverlight. How do I fix this?
It looks like the version of Silverlight you're targetting doesn't include that attribute.
However, that's OK; you can simply define it yourself:
namespace System.Runtime.CompilerServices {
sealed class CallerMemberNameAttribute : Attribute { }
}
Related
I am building in Visual Studio an iOS Binding Library. Objective Sharpie generated a code in ApiDefinition.cs. I am using directive namespace "Foundation" but clicking F12 at "Foundation" is not redirecting me to namespace definition. The "NSURL" type is not recognized. Other classes like "NSString" etc. are recognized well. There is an error:
CS0246 C# The type or namespace name 'NSURL' could not be found (are you missing a using directive or an assembly reference?)
What should I do to make 'NSUrl' recognized?
The compiler will prompt a large number of errors . Such as
You have to do something. For example, use the ulong/long instead of nuint ,and annotate the code such as [Verify(MethodToProperty)] .In addition,there are some differences between iOS and Xamarin.iOS in name of Object.For example ,NSURL in OC and NSUrl in C#.You need to manually modify it.
I am maintaining a visual studio 2008 application (website project). There is no chance to upgrade to higher version of.net framework or upper version of entity framework. Like many IT shops, unless there are major issues, people are not going to allow me to do major upgrade on the system.
The .net framework is 3.5. and the EF version is 1.0
I need to change my program, so my select linq statement will work
Calling a SQL User-defined function in a LINQ query
As you can tell, I need to include stored function as a part of select statement
So I copied the statement.
I have struggled for hours, and I keep getting compilation.
//..various using statement
using System.Data.Objects.DataClasses;
using System.Data.Metadata.Edm;
//..other class
public static class EntityFunctions
{
[EdmFunction("FBLModel.Store", "SampleFunction")]
public static int SampleFunction(int param)
{
throw new NotSupportedException("Direct calls are not supported.");
}
}
I keep getting compilation errors
error CS0246: The type or namespace name 'EdmFunctionAttribute' could not be found (are you missing a using directive or an assembly reference?)
I have searched the whole internet include stackoverflow and MSDN blog, the namespace looks correct
Any suggestions? Thank you
The problem here is that you have a conflicting reference with your namespaces.
The System.Data.Metadata.Edm namespace contains a class called EdmFunction. The System.Data.Objects.DataClasses namespace contains a class called EdmFunctionattribute (which is the one you are trying to use).
For some reason your code is referencing the EdmFunction class. Try removing the namespace import for System.Data.Metadata.Edm, as you probably didn't want to import this in the first place.
I am using .NET 4.5/4.6 and C#.
I am trying to follow the following sites Generic DAL and Entity Framework with my winforms application. I was able to implement link 2, however after implementing part of link 1 (specifically after moving my model Text Template, I have errors stating that The type or namespace name 'ObservableListSource<>' could not be found (are you missing a using directive or an assembly reference?)
What namespace do I need to reference at the project level to fix this for my solution or what reference do I need to include with my text template in order for the entities to contain no errors?
Assuming you're using this ObservableListSource the proper namespace would be System.Data.Entity
Found it. the answer is at the beginning of Databinding with winforms. Its a section of code that was overlooked several times and not a c# keyword.
I have an issue with a class being used in another project.
Visual studio is able to add a using statement using Resolve (Ctrl+.), but:
The type or namespace name 'SomeClass' could not be found (are you missing a using directive or an assembly reference?
Resolving this again fully qualifies the type but the namespace in the type path is highlighted as not being found.
The namespace appears also in intellisense and the target class is visible in the Object Browser.
Removing unused namespaces removes the added using statement.
I've tried:
Rebuild.
Confirm project dependency in solution options.
Delete reference and re-add.
Confirm class accessibility (despite namespace not being found).
Checked build mode (Debug/Release).
Restart Visual Studio.
Cleared bin folders in both projects.
Restart machine.
What is the next step to diagnosing this baffling issue?
This is likely to be a .Net framework versioning issue. The class being referenced was probably built using a higher version of the framework.
Try checking your framework versions all align in properties, build settings. A project cannot reference an assembly of a higher framework version.
Last time I had this problem my class was not marked public. Just an idea.
This issue was caused by similar namespaces e.g. Company.Product.Project and Product.Project with:
namespace Company.Product.Project
{
using Product.Project;
The class was in Product.Project, but the compiler was searching for Company.Product.Project.
See: Should 'using' statements be inside or outside the namespace? for more details.
I have a class lib and I referenced it to another windows project. I added its namespace to my Form.cs (using SaglikNetClassLib;). they are seem unknown when I want to access to classes. I can see their properties and methods. But the complier says "Error 7 The type or namespace name 'SaglikNetClassLib' could not be found (are you missing a using directive or an assembly reference?), Do you have any suggestion?
KR,
Çağın
Are you targeting the .net Client Framework? Visual Studio let's you add references to incompatible assemblies, but then gives exactly that error.
Check your project settings to make sure you're targeting the full .net framework.
Also, check that the Ilalcar class is public and not internal (which is the default if it's only declared as class without any modifier)
You probably need an using statement to put the class into scope.
using SaglikNetClassLib;
C# won't auto suggest it if the project has not been rebuild. Also make sure the class library project has been build before using it in code.
Intellisense seems to lag behind a bit at times. Simply pressing f5 (run) sometimes rebuilds the project completely and simply runs or gives a better error message.