I have a console application in visual studio 2015.(.Net FrameWork 4.8)
I've added 3 dlls to this app by NuGet installation like below :
System.Security.Cryptography.Algorithms
System.Security.Cryptography.Encoding
System.Security.Cryptography.Primitives
But i have error in this line of c# :
using System.Security.Cryptography.Algorithms;
The type or namespace name 'Algorithms' does not exist in the
namespace 'System.Security.Cryptography' (are you missing an assembly
reference?)
What is the problem and how can i fix it?
Two things to note here:
The AesGcm implementation you're looking for is not available for .NET Framework 4.8, hence the failure to resolve the desired type name. For a cross-platform implementation it looks like you'll need to upgrade to .NET 5.0
System.Security.Cryptography.Algorithms is not a namespace - it's just the name of the assembly (the DLL file on disk) that contains a number of cryptographic algorithm implementations. All public types contained in the corresponding DLL are namespaced to System.Security.Cryptography, so the qualified type name for AesGcm would have been:
System.Security.Cryptography.AesGcm
Related
I have taken over a project that is targeting .net4.
One of the projects within the solution is using System.Runtime.CompilerServices.CallerMemberNameAttribute from the System.Runtime.dll that is installed when you are using the Microsoft BCL Portability Pack.
I have checked and the project is currently using version 1.1.3.
When the solution is build on local dev machines, everything compliles with no problems.
I am now trying to get the solution built in teamcity, but when TeamCity attempts to compile the solution I am getting this error.
error CS0246: The type or namespace name 'CallerMemberName' could not be found (are you missing a using directive or an assembly reference?)
error CS0433: The type 'System.Runtime.CompilerServices.CallerMemberNameAttribute' exists in both 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll' and 'c:\apps\teamcity\buildAgent\work\bb8aacaa9fabeac8\packages\Microsoft.Bcl.1.1.3\lib\net40\System.Runtime.dll'
I have read Jon Skeets answer to this question: Using CallerMemberName attribute in a portable library But I am already using the BCL library.
After spending some time on this, I found another question answered by Jon Skeet that resolved this issue.
When must we use extern alias keyword in C#?
Within my project, after getting the links to the Package, for each dll I had to change the name of the alias. ie from global to newglobal
Then in the classes that where using the CallerMemberName, had to do the following
At the top of the page, above the using statements
extern alias newglobal;
And then when referencing CallerMemberName, enter the code as
[newglobal::System.Runtime.CompilerServices.CallerMemberName]
This allows the code to be successfully built on teamcity where .net 4.5 has been installed.
The type or namespace name 'DataServiceKeyAttribute' does not exist in
the namespace 'System.Data.Services.Common' (are you missing an
assembly reference?)
This is the error that I have been getting and its driving me crazy. I am trying to build a web portal and I am following this tutorial.
Now after extensive search I am done and out. My target Framework is .Net Framework4 and there are some assemblies, specially the one from CRM sdk with version 5.0.
Could this be an issue?
This Type is defined in the .NET Framework Assembly Microsoft.Data.Services.Client. Ensure that this assembly is referenced by your project and it should work fine.
Visual Studio 2012.
I have two projects A and B. A is the console application. The default namespace of A is "PayT'. B is class library type, the sAssembly name' is 'RetentionPolicyManager', the default namespace of B is 'RetentionPolicyManager'.
Now in project A, I added reference of B that is RetentionPolicyManager.dll to it.
In one class of A, there is one line:
using PayT.RetentionPolicyManager;
However I always got the error when I rebuild the solution:
The type or namespace name 'RetentionPolicyManager' does not exist in the namespace 'PayT'(are you missing an assembly reference?)
If I don't build the solution, it seems to be okay and no error.
I faced same issue some months ago. The problem was both projects didn't target the same platform, i.e. the console application targeted .Net framework 4.0 Client Profile while the library targeted full .Net framework 4.0.
Fixed by targeting full .Net 4.0 framework for both projects.
That's because RetentionPolicyManager doesn't exist in PayT it is it's own namespace in a separate dll, you just need:
using RetentionPolicyManager
As per your description, it should be:
using RetentionPolicyManager;
In A just use:
using RetentionPolicyManager;
the namespace of B is RetentionPolicyManager, PayT is the namespace of the Assembly A. remove PayT from using statement.
using RetentionPolicyManager;
I've created a Class Library project called Core. The default namespace is XXX.Tasker.Core.
I've created another Console project which references Core. In my Main() I've got some calls to stuff inside the Core but I'm getting an error:
The type or namespace name 'Core' does
not exist in the namespace
'XXXX.Tasker' (are you missing an
assembly reference?)
The only thing I can think of is that the fact my assembly name is Core might be confusing it.. but that really doesn't make much sense.
Any other suggestions?
The problem turned out to be that Core was compiled as .Net Framework 4 and the Console was .Net Framework 4 Client Profile. Apparently you'll just get really weird errors instead of a proper notification when this occurs.. thanks MS! ;)
I have a class library project that references another class library. The project fails to build and I get the error 'The type or namespace name 'ReportLibrary' does not exist in the namespace 'MSF' (are you missing an assembly reference?)'
The weird part is that I have other projects referencing the same class library that build fine. The only difference is that they are Windows Application projects. If I change the project type to a Windows Application and add a Program.cs with a [STAThread] and it builds.
So WTF? Anybody know what I'm doing wrong?
Edit (More Details): All projects in the solution are set to the same Target Framework: .NET Framework 3.5
EDIT (Unobfuscated the error message per Hans)
Is the class library (with the error) targeting the Client Profile, and the applications (as well as the reference library) targeting the full framework? If so, this could cause the reference to be invalid, and cause that message.