Visual Studio does not let me drag drop items into it?

风流意气都作罢 提交于 2020-01-18 16:00:26

问题


Using Visual studio 2010 I got problems when double-clicking, for example a config file (*.config). Visual Studio would open but give me a error message about parameters. If I simple try to drag and drop a file that Visual Studio usually can read in to it, the icon will give me the "not possible icon"?

I have now installed Visual Studio 2012 and it has the same problem?!

This makes my work a lot harder, it should be easy to just drag & drop files into Visual Studio, but it's not so? Now I have to manually find the file with the file menu?

Please note, I have re-installed the computer before installing Visual Studio 2012.


回答1:


On Windows Vista and newer Windows Explorer runs with medium integrity level. If you run Visual Studio as administrator (high integrity level) then for security reasons OS will disable drag and drop from Explorer to Visual Studio.

You can either run Visual Studio as normal user or you can install VSCommands for Visual Studio 2012 extension. It has several features that can help with this such as:

  • Elevated Windows Explorer - small tool which looks like Windows Explorer but runs with elevated permissions allowing Drag And Drop
  • Directory Explorer - tool window inside Visual Studio which again looks like Windows Explorer and allows Drag And Drop
  • Run Visual Studio with medium integrity - allows Drag And Drop from Windows Explorer, but you won't be able to attach to processes run by other users (e.g. IIS)



回答2:


If you run VS as administator, instead drag n drop, do copy (either ctrl+c, context menu "copy") the file selection in explorer and paste (ctrl+v, context menu) on selected node in VS




回答3:


This was driving me nuts. In my Visual Studio solution I have two Web Application which use IIS as web server so because of this I have to always start my Visual Studio in Administrator mode. After starting as Admin I wasn't able to drag and drop files from Explorer to Visual Studio.

Solution:

  1. Open Command Prompt as Administrator (Shortcut for Windows 8.1 is ⊞ Win + X + A)
  2. Type "explorer" this would open Windows Explorer with Admin privileges.

And now you should be able to drag and drop any file from explorer to Visual Studio




回答4:


I think the main goal of this question is how to add many folders and files to your project in a comfortable way. Drag and Drop files into your project is one solution, which fails under certain circumstances.

Another very easy way is:

  • Copy the new folders and files where you physically want them in your project
  • Open the project explorer in VS and click the button "Show all files"
  • All the folders and files, which are now not part of your project yet appear white
  • Select the the white folders or files, right-click and choose "Bind to project"
  • Done

This is also possible, if you run VS as admin.

Have some fun!

By the way: I found this question, because I had the same issue with drag and drop. I understand the security issues, but it is an annoying feature.




回答5:


If you disable UAC completely you can drag & drop from anywhere again. To do this you can't use the slider in the Control Panel because that only brings the UAC level down to 1. Make this registry change, reboot, and you can again use your computer like god intended.

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
"EnableLUA"=dword:00000000



回答6:


I'm using this easiest approach. When you run Visual Studio in Administrator Mode. When you need to drag and drop, just press CTRL+O to open up a file browser within visual studio, and use that file browser as an Elevated Explorer to do your drag and drop.




回答7:


I had a similar problem but my issue was a bit different. I was trying to drag and drop a file from inside a zipped folder. Once I unzipped the folder drag & drop started working again.




回答8:


I had this problem as well because I was opening VS in admin mode and the file explorer by default is not in admin mode.

Ended up creating a PowerShell and bat script to start explorer in admin mode every time the computer start.

admin.bat file:

@ECHO OFF
PowerShell.exe -Command "& {Start-Process PowerShell.exe -ArgumentList '-ExecutionPolicy Bypass -File ""%~dpn0.ps1""' -Verb RunAs}"

admin.ps1 file:

taskkill /f /im explorer.exe
start-process explorer.exe

The files just have to be in the same folder. Doesn't matter what they are called. Run the .bat file to restart explorer in admin mode or just create a shortcut to the .bat file in the startup folder ;) the script and ps1 file can be hidden.




回答9:


On windows 8.1, change the registry key: Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\EnableLUA and set value = 0.



来源:https://stackoverflow.com/questions/15226600/visual-studio-does-not-let-me-drag-drop-items-into-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!