方法一:

以管理员身份运行VS。

方法二:

添加配置文件方法如下:

It turns out the root cause of the problem was how UAC interacts with processes.  I have some code in the application that kicks up to an elevated privilege level (administrator), however, UAC does not permit this (seemly silently).  It is only if the entire process begins with elevated privileges does the impersonation actually work.  So long story short, when I run either the application or the Visual Studio environment as Administrator, the application starts up a-ok.  (FYI, my domain account is in the local administrators group for the machine.)

So, to keep testing the theory, I turned User Account Control in Windows 7 *off*, restarted my computer, and tried again, and this time it worked.  I then turned UAC back *on*, restarted, and tried again, and as before the application failed.

The final solution was to add an app.manifest to the project that hosts the service, and specify the following elevated privileges (As seen in copied xml from the .manifest):

<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><assemblyIdentity version="1.0.0.0" name="MyApplication.app"/><trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"><security><requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"><!-- UAC Manifest OptionsIf you want to change the Windows User Account Control level replace the requestedExecutionLevel node with one of the following.<requestedExecutionLevel level="asInvoker" uiAccess="false" /><requestedExecutionLevel level="requireAdministrator" uiAccess="false" /><requestedExecutionLevel level="highestAvailable" uiAccess="false" />If you want to utilize File and Registry Virtualization for backward compatibility then delete the requestedExecutionLevel node.--><requestedExecutionLevel level="requireAdministrator" uiAccess="false" /></requestedPrivileges></security></trustInfo>
</asmv1:assembly>

So this resolved my problem, and I suspect it might help with the others as well.

I hope this helps,

j.

PS.  The steps to add a .manifest file to the Host Project were as follows:

1. Open the solution containing the Host Project

2. Right click on the project and add a new item

3. Select Application Manifest File

4. Edit the .manifest file to change default requestedExecutionLevel from "asInvoker" to "requireAdministrator"

5. Save the changes

6. Open the properties for the Host Project (not the solution)

7. Under the Application settings, sub-section Resources, under the Icon and Manifest area, change the Manifest drop down to "app.manifest" if it isn't already.

8. Save, build, run.  When you run from the application from the command line, you should get a prompt in Windows Vista and 7 to elevate the application privileges.



解决开ServiceHost时候System.PlatformNotSupportedException: Operation is not supported on this platform.相关推荐

  1. Eclipse里编辑代码,进度条出现“Remote System Explorer Operation”解决方法

    Eclipse里编辑代码,进度条出现"Remote System Explorer Operation"解决方法 参考文章: (1)Eclipse里编辑代码,进度条出现" ...

  2. linux c编译错误 cmake_symlink_library: System Error: Operation not supported

    在编译uchardet时遇到这个错误: cmake_symlink_library: System Error: Operation not supported 创建链接不成功,要确认当前帐户下是否有 ...

  3. System.PlatformNotSupportedException

    Httplistener报错: System.PlatformNotSupportedException 这个原因不知道怎么解决,换一台电脑就好了. 这个不知道怎么用 <TargetFramew ...

  4. IDEA解决开两个窗口问题

    在java编译器中针对于IDEA解决开两个窗口的问题 第一步 1.点击左上角的 file 第二步 2.点击弹出框的 settings 第三步 3.点击system settings然后勾选 open ...

  5. Remote System Explorer Operation卡死Eclipse解决方案

    在用eclipse开发时,经常遇到卡死的情况,其中一种就是右下角出现:"Remote System Explorer Operation",解决方案如下: 第一步:Eclipse ...

  6. win7 计算机 开不了,win7系统开不了机怎么办?云骑士教你解决开不了机的问题...

    原标题:win7系统开不了机怎么办?云骑士教你解决开不了机的问题 虽说Win7系统性能稳定,但在使用过程中,也避免不了出故障的时候,很多用户在使用电脑时遇到了开不了机的问题,那么该怎么办呢?今天小编整 ...

  7. 解决Windows Server 2008 System进程占用80端口

    解决Windows Server 2008 System进程占用80端口 我这台机子是64位系统 Netsata –ano 80   PID 4    在任管理器中是system   NT Kerne ...

  8. System.Drawing is not supported on this platform

    在跨平台编程中很有可能会遇到一些库执行不正确的问题,比如,我在用NuGet引入库的时候就遇到了类似问题.我引入System.Drawing.Common.dll到UWP工程中,编码的时候并没有报错,但 ...

  9. 成功解决explicit device specific/device:GPU:0' because no supported kernel for GPU devices is available.

    成功解决explicit device specific/device:GPU:0' because no supported kernel for GPU devices is available. ...

最新文章

  1. ladar:16线激光雷达(雷神)
  2. php 发送带附件的邮件,php发送带附件的电子邮件
  3. 炸了,为什么某高速网络总是二层通三层不通?
  4. 带你玩转css3的3D!
  5. maya2014中uvlayout2.08安装
  6. 蜂鸣器音乐代码 天空之城_歌单 | 音乐拥有魔力
  7. 工作学习办公软件助手集合
  8. 极米H5多少流明?采用新亮度标准的极米H5怎么样?性价比高吗?
  9. python自动喷人工具
  10. 使用mysqldump+WinRAR压缩备份数据库
  11. latex小技巧—极限符号下方分成两行
  12. python绘制动态k线及均线_Python绘制股票移动均线的实例
  13. python小白入门第二课-标识符数据类型字符串方法
  14. oracle 10g 与11g的几点常用区别
  15. win10/11上一键切换全拼/双拼
  16. CentOS 7.5 编译安装redis集成至系统服务(包括集群环境)
  17. 全国计算机等级考试三级信息安全技术考试大纲(2018 年版)
  18. 计算机毕业设计(77)php小程序毕设作品之维修保养汽车小程序系统
  19. 一个互联网+应用的创意
  20. input输入数字金额

热门文章

  1. Concurrenthashmap的putIfAbsent方法
  2. 06_LR和最大熵模型_统计学习方法
  3. PHP json_encode 文本形式数字下标数组导致下标丢失
  4. 【293天】我爱刷题系列052(2017.11.25)
  5. mysql慢查询分析工具和分析方法
  6. MS SQL入门基础:删除数据库
  7. MFC实现BCB中的ProcessMessages
  8. git remote 使用总结
  9. Hyperledger Fabric、Corda和以太坊对比
  10. 关于云主机拷贝复制资源异常的处理办法