简体   繁体   中英

Switching to Windows 8 requires running Visual Studio as administrator for generating dll

I have a Visual Studio 2010 C# class library project that produces DLL. After switching from Windows 7 to Windows 8 I started getting the error:

Cannot register assembly "C:\\Users\\Almeesoft User\\Dropbox\\code\\hysysintegration\\HysysMembraneExtension\\Almeesoft.HysysMembraneExtension\\bin\\Release\\Almeesoft.HysysMembraneExtension.dll" - access denied. Please make sure you're running the application as administrator. Access to the registry key 'HKEY_CLASSES_ROOT\\CLSID{0C1B5FDB-7C22-3FF9-B6B0-645C2E72D934}' is denied

Changing UAC and folders permissions did not help. The only thing that helped was running Visual Studio as administrator. Are there any other methods?

That's not new for Windows 8, allowing MSBuild to register a [ComVisible] assembly requires elevation since Vista. Since it writes registry keys that are protected by UAC. Perhaps you had a desktop shortcut before that launched VS with admin privileges. Which is what it takes.

You can do it by hand by unticking the "Register for COM interop" option and running Regasm.exe from an elevated command prompt. Use the /codebase and /tlb options. If you apply the [Guid] attribute to the interop interfaces and classes then this only needs to be done once. It is dangerous, you should remove them again and rebuild before you ship the assembly or you'll risk DLL Hell.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM