我有一个来自同事的代码(可能是从网上某处获得的),但是他出去度假,我需要将它添加到清单文件中
<?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" />
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="requireAdministrator"
uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
</asmv1:assembly>
Run Code Online (Sandbox Code Playgroud)
我对此比较陌生,所以任何帮助都会受到赞赏.谢谢
我正在使用Visual Studio 2010
所以我正在编写一个需要访问注册表的应用程序.我没有触及任何构建设置,希望在添加其他触摸(例如描述或名称)之前让事情正常工作.
出乎意料的是,我得到了一个不会消失的错误.ClickOnce does not support the request execution level 'requireAdministrator'.现在,我没有在这个应用程序中触及ClickOnce.我所做的就是包括一个请求这些权限的清单文件.
我现在的问题是这个错误不会消失,我无法编译我的程序.关于该怎么做的任何建议?(旁注:我准备去睡觉了,明天下午我会检查一下).
我有一个Visual Studio Windows应用程序项目.我添加了代码来下载安装程序更新文件.完成下载后的安装程序需要管理员权限才能运行.我添加了一个清单文件.
当用户单击DownloadUpdate.exe时,UAC会提示用户输入管理员权限.所以我假设在DownloadUpdate.exe中创建和调用的所有进程都将以管理员身份运行.所以我使用以下代码调用我的下载文件:
Process p = new Process();
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.StartInfo.FileName = strFile;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
Run Code Online (Sandbox Code Playgroud) 有没有办法确定特定机器上次运行进程的时间?
我可以使用以下内容来确定某个进程是否正在运行,但如果该进程已停止,则该应用程序无法获取该进程.
Process[] process = Process.GetProcessesByName(processName, serverName);
Run Code Online (Sandbox Code Playgroud) 如何强制我的C#Winforms程序在任何计算机上以管理员身份运行?和任何类型的操作系统?
我需要代码解决方案(任何示例代码都会很棒)
提前致谢
我创建了我的第一个自托管WCF服务.我在C#控制台应用程序中托管它,但它抛出一个错误:
System.ServiceModel.AddressAccessDeniedException:HTTP无法注册URL http:8080
当我以管理员身份运行Visual Studio 2013时,它运行良好,但如果不运行则不行.那么有什么方法可以自动完成它而不是将VS作为ADMIN启动?
到目前为止,我创建了一个HelloService类库,在其中我添加了一个WCF服务,该服务由一个接口IHelloService和HelloService.
IHelloService:
namespace HelloService
{
[ServiceContract]
public interface IHelloService
{
[OperationContract]
String GetMsg();
}
}
Run Code Online (Sandbox Code Playgroud)
HelloService:
namespace HelloService
{
public class HelloService : IHelloService
{
public String GetMsg()
{
return "Service Accessed";
}
}
}
Run Code Online (Sandbox Code Playgroud)
然后我创建了一个C#控制台应用程序HelloServiceHost,它有一个app.config文件:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors >
<behavior name="MexBehaviour">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="HelloService.HelloService"
behaviorConfiguration="MexBehaviour" >
<endpoint
address="HelloService"
binding="basicHttpBinding"
contract="HelloService.IHelloService"></endpoint>
<endpoint …Run Code Online (Sandbox Code Playgroud) 我想启动一个具有提升权限但具有隐藏窗口的子进程(实际上是相同的控制台应用程序).
我做下一个:
var info = new ProcessStartInfo(Assembly.GetEntryAssembly().Location)
{
UseShellExecute = true, // !
Verb = "runas",
};
var process = new Process
{
StartInfo = info
};
process.Start();
Run Code Online (Sandbox Code Playgroud)
这工作:
var identity = new WindowsPrincipal(WindowsIdentity.GetCurrent());
identity.IsInRole(WindowsBuiltInRole.Administrator); // returns true
Run Code Online (Sandbox Code Playgroud)
但是UseShellExecute = true创建了一个新窗口,我也无法重定向输出.
所以我下次做的时候:
var info = new ProcessStartInfo(Assembly.GetEntryAssembly().Location)
{
RedirectStandardError = true,
RedirectStandardOutput = true,
UseShellExecute = false, // !
Verb = "runas"
};
var process = new Process
{
EnableRaisingEvents = true,
StartInfo = info
};
DataReceivedEventHandler actionWrite …Run Code Online (Sandbox Code Playgroud) 我的项目中有以下C#函数,它应该打开并返回一个现有的Excel工作簿对象:
Application _excelApp;
// ...
private Workbook OpenXL(string path, string filename)
{
try
{
if (_excelApp == null)
{
_excelApp = new Application();
}
Workbook workBook = _excelApp.Workbooks.Open(path + filename, // Name
0, // Do not update links
true); // Open read-only
return workBook;
}
catch (Exception e)
{
_excelApp = null;
throw new ArgumentException("Error opening " + path + filename, e);
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我用"C:\"和"scratch.xlsx"运行它时,Open()调用会抛出以下错误:
Microsoft Excel cannot access the file 'C:\scratch.xlsx'. There are several possible reasons:
• The file …Run Code Online (Sandbox Code Playgroud) 我知道这已经有很多东西已经尝试了一些东西,但没有运气来修复它.
我有一个C#程序,它构建了一个XML文档,我试图将它保存到MyDocuments中的文件夹.调用XMLDoc.Save函数时,我得到了以下异常.
访问路径'C:\ Users\Ash\Documents\ConfigOutput'被拒绝
我有视觉工作室作为管理员运行.有关如何解决它的任何想法?
我已经尝试保存到桌面和C:\文件夹中.
我正在使用Windows 7.
运行构建的可执行文件似乎也不起作用.
抱歉,我觉得自己很愚蠢.我确实没有在输出路径中添加文件名.我不会删除任何其他人通过这个问题完成的问题!感谢所有的帮助/评论.