I've referred the file System.Security.dll as described in this article but according to my IDE, the line using System.Security.Cryptography; can be safely removed as it's not being used.
The same IDE tells me that I've got an error with DataProtectionScope and ProtectedData. Those are supposed to be in that namespace. However, when I dot my way through the packages, I can't see them in there.
Is the article wrong? How can I access the two classes?
As #Coral Doe mentioned in a comment under #Dave Lucre:
"Had a similar problem and this worked. using System.Security.Cryptography; didn't [show] me [ProtectedData] and ProtectedMemory until I had referenced the System.Security.dll for the specific framework."
This fixed the issue for me. Specifically, I performed these steps:
Open the project in Visual Studio.
Right-click the project's name in Solution Explorer then choose Properties.
Click the References tab on the left.
Click the Add button.
Click the .NET tab.
Select System.Security and click OK to add the reference.
Hope this helps.
I have referenced the System.Security.dll here: C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Security.dll
Added using System.Security.Cryptography; and I can see both DataProtectionScope and ProtectedData.
I'm targeting the .net 4.0 full framework (not client profile).
What framework are you targeting?
I had to add this NuGet package in addition to System.Security.Cryptography.
It is https://www.nuget.org/packages/System.Security.Cryptography.ProtectedData/.
After that, System.Security.Cryptography became "used".
As #Dave Lucre asked, what framework is your application targeting? Visual Studio creates all new applications to use the Client Profile by default (which is asinine in my opinion), and it causes all sorts of trouble if you don't specifically change it back. Give that a look, then see where we go from there.
Remove references System.Security.Cryptography and add it again.
It works in my case.
I'm sorry, I know that this is a quite old post, but I'm having this issue now and the only workaround that I've found is:
Follow the steps mentioned in George Brian's answer
Use System.Security.Cryptography.DataProtectionScope scope = System.Security.Cryptography.DataProtectionScope.LocalMachine; instead of DataProtectionScope scope = DataProtectionScope.LocalMachine;
This might be a slap in your face because you've probably tried that (and you haven't, you might deserve one). What happens if you reinstall the whole IDE? And I meant really the whole thing. Remove the framwork, the VS, remove the files, go paranoid and clean up the trash can, switch to a different installation directory etc. Does the problem still remains?
I know it doesn't explain why it happened but at this stage I'm guessing you're mostly interested in how to kill the problem.
If you have access to a spare computer - why don't you install VS on that machine and see if you can reproduce the error. If not, then there's something fishy with your primary machine and you'll probably never know what happened.
I'm stressing here that it's only a list of general suggestions that every programmer should rely on when nothing sane nor logical seems to work. And yes, I do hate computers. I love programming but I hate computers. They are like small, evil people with keyboards...
Related
I have superficial knowledge on referencing libraries in projects. Usually most of the time a simple 'add reference' and then browsing to the appropriate path, just works. I am following an issue I will try to explain , and show all the approaches I tried to tackle it.
I am trying to use AutoIt. In their website it is stated that simply adding the .dll and using it, is enough to integrate their functionality in visual studio.
I am doing just that but for the moment I can not get my head around what is happening.
AutoItX is a public static class, as also the Run function is the same (public static). After adding the reference I can navigate to the appropriate .cs (if I control click on it for example). So the class AutoItX is not something unknown for the project. Moreover, the function Run indeed exists
however not inside the project itself. AutoItX also needs staff from (dont know if it is important):
The main error is that AutoItX doesnt exist in this context.
I have tried to register the dll, I have tried to add the com reference and remove it, I have tried to move the .cs files inside the project. None of those corrected the issue.
Any help would be valuable. If I missed something and you need extra info, I am willing to provide it. (Latest vs, latest autoit version, .net framework type of project).
Actually the above works.
For future reference.
The reason I did not try it first was, that they propose in their website to reference the autoItX.assembly.dll. This is probably deprecated and does NOT work anymore.
Second, if you have already referenced it , downloading this from NuGet WONT fix it.
Finally, the NuGet package does NOT work with .net CORE but ONLY with .net Framework project
I installed AutoItX.Dotnet 3.3.14.5, my test is no problem.
You can refer to my steps to create a new project to test it.
Right click References=>Manage NuGet Packages=>Browse=>AutoItX.Dotnet=>Install
Running result:
First of all, thanks for the help in advance, and excuse me for my relative lack of knowledge on these subjects, and this long post. I have a strange reference issue I'm trying to work out. I've done many hours of research on this subject, but I think my limited knowledge is holding me back from understanding. I'm losing my mind a bit here.
We are reviewing a project and came across an odd situation where there are references to System.IO and System.Runtime in the original .csproj file for an application (Sitefinity 10.1.6502), but in the copy of the .csproj we have on file post-development they have been removed. There are still references to System.Runtime.Caching and System.Runtime.Serialization in both.
When I looked online and in Sitefinity's public Git example repos, I found that about 1/2 of the examples with code for the same version DO have and like the original file does, and 1/2 DO NOT have them like the file in our repo. Some appear to have those references added at a later time when upgraded versions (to 10.2 or 11).
I also do not see System.Runtime.dll in the current /bin folder, or see it mentioned in web.config. I do not have access to the GAC.
The question is whether these missing references will cause any problems. The project seems to compile properly in VS2017 using the post-development .csproj file we have (without System.IO and System.Runtime)
We believe the project was originally built in VS2015, and found this article that mentions the exact references we're dealing with, so perhaps VS2015 was part of the problem? Unresolved Project References for System.IO, System.Runtime
I understand these are facades and that System.IO is a namespace in System, which is directly references in both .csproj versions, so that should be covered, correct?
The real question is whether the missing in the post-dev .csproj file could cause any issues. Like I mentioned above, the project is compiling without it in VS2017, and the files seem to work fine on a testing server (can navigate the front-end web pages and all functionality works, but we have not been able to test any of the back-end functionality due to it sharing a database with the live environment (out of our control).
Through my research I've seen it mentioned that System.Runtime should get automatically included during tooling/compiling, and that in normal circumstances it does not need to be directly referenced like it is in half the repos we saw. Is this correct?
I worry less about System.IO because it is already included via System, but from what I understand that isn't the case with System.Runtime
Again, thanks so much for helping clear this up for us, we're beginning to go batty trying to figure out if this is an issue we should worry about or not!
working with unity and c# and when I try these line
using System.Xml.Linq;
I get this error
The type or namespace name Linq' does not exist in the namespace
System.Xml'. Are you missing an assembly reference?
So I found online, through a lot of searching, that Linq can cause problems, and you need to manually add a reference in MonoDevelop. So I added a reference there (by right clicking References in the solutions pane, clicking Edit References and browsing for System.Xml.Linq)
Still no luck,
Any ideas?
I think this SO post will answer your question...
https://stackoverflow.com/a/875704/1246574
It's pretty much the same issue you're having.
You can't modify the monodevelop (or visual studio) solution or project manually. Because they are generated by Unity. Even if you modify it, Unity can overwrite your changes when it regenerates the solution files.
The reason you can't use some namespaces is the .net/mono version selected in your Unity project settings.
Search for "API Compatibility Level" in this documantation http://docs.unity3d.com/Documentation/Manual/class-PlayerSettings.html
C'mon people, Stop modifying the generated code files. This is 2013!
from this post, I found that Unity doesn't support .NET 3.5 by default (which is required to use Linq). In the settings Xtro talked about, you can only choose .NET 2.0. Instead, you need to drag the desired .dll file into Unity like a texture. Kinda hackish, but it works. Once again, like Xtro said, there is NO REASON to edit the MonoDevelop settings. They have no affect on the final compilation.
EDIT: See Xtro's answer for an alternate solution. He was able to make Linq work by changing the API Compatibility Level to .NET 2.0 (not Subset).
EDIT 2: I just updated from Unity 4.1 to 4.2 today and got an error that Linq was defined twice. by deleting the .dll, I solved the error. Note I'm still using .NET 2.0 Subset. Looks like they added Linq support by default.
output type of 'Class Library', and a target framework of '.NET Framework 4'.
According to everything I've read, I should have it available, but all I'm seeing in the System.Runtime namespace is the following:
CompilerServices
ConstrainedExecution
ExceptionServices
Hosting
InteropServices
Remoting
Serialization
Versioning
Any ideas?
You just need to add a reference to the System.Runtime.Caching assembly.
In solution explorer, right-click on "References"
Select "Add reference"
From left side menu select "Assemblies"
Look for (or filter) and add System.Runtime.Caching.dll.
It's not part of the default set of references in a class library, but you should be able to add it with no problems.
To complement Jon Skeets answer, (for those who run into this problem), if you still get red squiggly lines under Caching after having added reference to System.Runtime.Caching assembly, just restart the Visual Studio, after having saved the solution, and you should be good to go.
Having added the reference, saved the solution and ( if need may be ) restarted Visual Studio, you should be able to use the types within this namespace. In order to get my solution to work, I had to do this very way.
Edit:
While trying to recreate the problem, and solving this way, it seems that we need to set Copy Local to True in System.Runtime.Caching > Properties and then restart Visual Studio for getting it to work. At least, for my case, the problem didn't seem to solve without this. ;)
Reference System.Runtime.Caching.dll. This is another one of those rather obtuse gotchas in the .NET framework right now where there will be very similar namespaces in some things, but the actual classes you want will be referenced in different assembles. As an example, CacheItem is in this alternate DLL, whereas ApplicationActivator (in System.Runtime.Hosting) is in mscorlib.
For me the System.Runtime.Caching NuGet package is what I needed
little bit o this and all was well
dotnet add package System.Runtime.Caching --version 5.0.0
I'm attempting to follow David Betz' wonderful advice on how to use a library project in both your .NET and Silverlight code. In particular, I'm using his File-Level technique: I have a .NET library project already set up, so I created a Silverlight project, and added links in the latter to the former's files.
Unfortunately, there is a problem. I get compilation errors like crazy, of the form:
The type '...' exists in both 'Util.dll' and 'Util (Silverlight).dll'
In all of my other projects, I only reference one or the other. Neither Util dll has a reference to the other, so I'm not sure why the compiler can see both DLLs from any of the other projects.
Any ideas?
Answer posted by frank in comments. Porting to answer and community wikiing it in hopes that it'll be accepted as the answer.
Comment
Argh! It really was this simple :) I just fixed the compilation issues other then this one, and it suddenly stopped complaining.
I also added to the linked projects Project Dependencies on the real projects, and that helped keep the errors more consistent, at least.
– frank