小编jkh*_*jkh的帖子

安装在Visual Studio中创建的Windows服务

当我在Visual Studio 2010中创建新的Windows服务时,我收到消息,声明使用InstallUtil和net start来运行该服务.

我尝试了以下步骤:

  1. 创建新项目文件 - >新建 - >项目 - > Windows服务
  2. 项目名称:TestService
  3. 按原样构建项目(Service1构造函数,OnStart,OnStop)
  4. 打开命令提示符,运行"C:\ Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe"TestService.exe
  5. 运行net start TestService.

步骤4的输出

运行事务安装.

开始安装的安装阶段.

请参阅日志文件的内容以获取C:\ Users\myusername\Documents\Visual Studio 2010\Projects\TestService\TestService\obj\x86\Debug\TestService.exe程序集的进度.

该文件位于C:\ Users\myusername\Documents\Visual Studio 2010\Projects\Tes tService\TestService\_dj\x86\Debug\TestService.InstallLog.

安装程序集'C:\ Users\myusername\Documents\Visual Studio 2010\Projects\TestS ervice\TestService\_dj\x86\Debug\TestService.exe'.

受影响的参数是:

logtoconsole =

logfile = C:\ Users\myusername\Documents\Visual Studio 2010\Projects\TestService\T\testService\_dj\x86\Debug\TestService.InstallLog

assemblypath = C:\ Users\myusername\Documents\Visual Studio 2010\Projects\TestServ ice\TestService\obj\x86\Debug\TestService.exe

没有具有RunInstallerAttribute.Yes属性的公共安装程序可以在C:\ Users\myusername\Documents\Visual Studio 2010\Projects\TestService\TestSe rvice\_ obj\x86\Debug\TestService.exe程序集中找到.

安装阶段成功完成,提交阶段正在开始.

请参阅日志文件的内容以获取C:\ Users\myusername\Documents\Visual Studio 2010\Projects\TestService\TestService\obj\x86\Debug\TestService.exe程序集的进度.

该文件位于C:\ Users\myusername\Documents\Visual Studio 2010\Projects\Tes tService\TestService\_dj\x86\Debug\TestService.InstallLog.

提交程序集'C:\ Users\myusername\Documents\Visual Studio 2010\Projects\TestS ervice\TestService\_obj\x86\Debug\TestService.exe'.

受影响的参数是:

logtoconsole = …

c# windows service windows-services installutil

134
推荐指数
4
解决办法
14万
查看次数

右对齐的UITextField空格键不会在iOS 7中前进光标

在我的iPad应用程序中,我注意到iOS 6和iOS 7与UITextFields之间存在不同的行为.

我创建UITextField如下:

UIButton *theButton = (UIButton*)sender;
UITextField *textField = [[UITextField alloc] initWithFrame:[theButton frame]];

[textField setDelegate:self];
[textField setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter];
[textField setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight];

textField.textAlignment = UITextAlignmentRight;
textField.keyboardType = UIKeyboardTypeDefault;

...

[textField becomeFirstResponder];
Run Code Online (Sandbox Code Playgroud)

在iOS 6中,当我输入"hello world"时,当我在"你好"之后点击空格键时,光标会前进一个空格.

在iOS 7中,当我按下空格键时光标不会前进.但是,当我在"世界"中键入"w"时,它会显示空格和w.

在iOS 7中按空格键时,如何使光标前进?

更新:

如果我将textField.textAlignment更改为UITextAlignmentLeft,则该空间将显示在iOS 7中.如果可能,我希望将其保持正确对齐.

space objective-c uitextfield ios ios7

40
推荐指数
5
解决办法
1万
查看次数

从非管理员应用程序以管理员身份运行流程

从未以管理员身份运行的应用程序,我有以下代码:

ProcessStartInfo proc = new ProcessStartInfo();
proc.WindowStyle = ProcessWindowStyle.Normal;
proc.FileName = myExePath;
proc.CreateNoWindow = false;
proc.UseShellExecute = false;
proc.Verb = "runas";
Run Code Online (Sandbox Code Playgroud)

当我调用Process.Start(proc)时,我没有弹出请求以管理员身份运行的权限,并且exe不以管理员身份运行.

我尝试将app.manifest添加到myExePath中找到的可执行文件,并将requestedExecutionLevel更新为

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
Run Code Online (Sandbox Code Playgroud)

使用更新的app.manifest,在Process.Start(proc)调用中,我得到一个异常,"请求的操作需要提升."

为什么.Verb操作没有设置管理员权限?

我正在测试Windows Server 2008 R2 Standard.

c# uac processstartinfo runas

29
推荐指数
1
解决办法
6万
查看次数

检测表单何时关闭c#

我有一个我创建的WinForm,它显示一个带按钮的提示.这是一个自定义的WinForm视图,因为消息框对话框还不够.

我有一个后台工作人员开始运行.aBackgroundWorker.IsBusy如果单击myForm上的按钮,我也想退出while()循环.

//MyProgram.cs

using(CustomForm myForm = new CustomForm())
{
    myForm.Show(theFormOwner);
    myForm.Refresh();

    while(aBackgroundWorker.IsBusy)
    {
        Thread.Sleep(1);
        Application.DoEvents();
    }
}
Run Code Online (Sandbox Code Playgroud)

现在,在CustomForm这次Button_clicked活动中,我有

//CustomForm.cs

private void theButton_Click(object sender, EventArgs e)
{
  this.Close();
}
Run Code Online (Sandbox Code Playgroud)

我是否需要向CustomForm类或我声明和初始化表单的位置添加更多代码以便能够检测到闭包?

c# events event-handling winforms

13
推荐指数
2
解决办法
4万
查看次数

由于不支持的API FindFirstFileEx(WACK在本地传递)导致UWP应用程序提交失败

我有一个UWP项目作为我的Xamarin.Forms解决方案的一部分.在本地运行Windows App Cert Kit时,它会毫无问题地通过.

将我的应用程序提交到商店时,它未通过认证过程,并出现以下错误:

发现错误:

支持的API测试检测到以下错误:

此应用程序类型不支持api-ms-win-core-file-l1-2-0.dll中的API FindFirstFileEx.PInvoke.Kernel32.dll调用此API.

如果没有修复影响:

使用不属于Windows SDK for Windows Store应用程序的API会违反Windows应用商店认证要求.

怎么修:

查看错误消息以识别不属于Windows SDK for Windows Store应用程序的API.请注意,在调试配置中构建的应用程序或未启用.NET Native的应用程序(如果适用)可能会使此测试失败,因为这些环境可能会引入不受支持的API.在发布配置中重新测试您的应用程序,并启用.NET Native(如果适用).

我已经验证我的应用在发布模式下运行,并验证了我的UWP构建设置:

UWP

我尝试联系微软的聊天支持,但被重定向进入事件报告,然后我被重定向到只是在论坛上寻求帮助或支付高级技术支持,所以我无法获得有关是否有任何更多信息这是一个有效的失败.

根据FindFirstFileEx(https://msdn.microsoft.com/en-us/library/windows/desktop/aa364419 ( v= vs.85 ) .aspx )上的文档,它看起来像Windows桌面支持,存储应用程序和Windows Phone.我的UWP应用程序被提交以支持桌面和移动系列,这些系列似乎包含在此功能的受支持客户端中,因此不清楚导致故障的原因.

关于从哪里去的任何想法?

xamarin windows-store-apps xamarin.forms uwp wack

9
推荐指数
1
解决办法
924
查看次数

OVER ORDER BY中的多个列

有没有办法在OVER ORDER BY子句中指定多个列?

SELECT ROW_NUMBER() OVER(ORDER BY (A.Col1)) AS ID FROM MyTable A
Run Code Online (Sandbox Code Playgroud)

以上工作正常,但尝试添加第二列不起作用.

SELECT ROW_NUMBER() OVER(ORDER BY (A.Col1, A.Col2)) AS ID FROM MyTable A
Run Code Online (Sandbox Code Playgroud)

','附近的语法不正确.

sql sql-server row-number sql-order-by

8
推荐指数
1
解决办法
3万
查看次数

通过BinaryReader将字节数组解压缩为字符串,产生空字符串

我试图解压缩一个字节数组,并使用二进制读取器将其转换为字符串.执行以下代码时,inStream位置从0更改为数组的长度,但str始终为空字符串.

BinaryReader br = null;
string str = String.Empty;

using (MemoryStream inStream = new MemoryStream(pByteArray))
{
    GZipStream zipStream = new GZipStream(inStream, CompressionMode.Decompress);
    BinaryReader br = new BinaryReader(zipStream);
    str = br.ReadString();
    inStream.Close();
    br.Close();
}
Run Code Online (Sandbox Code Playgroud)

c# memorystream gzipstream binaryreader

7
推荐指数
1
解决办法
2万
查看次数

XMLDocument - > Byte [] ...如何返回XMLDocument?

我有一个XmlDocument并获取对象的字节,如下所示:

XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("C:\\myxml.xml");

byte[] data = Encoding.UTF8.GetBytes(xmlDocument.outerXml);
Run Code Online (Sandbox Code Playgroud)

并且数据存储在数据库中.

现在我正在读取byte []数据,并希望返回到XmlDocument对象.我怎么能这样做,因为我不能简单地将byte []放到XmlDocument中?

谢谢.

c# encoding xmldocument bytearray type-conversion

6
推荐指数
1
解决办法
8439
查看次数

DynamoDB ExclusiveStartKey 的字典序列化不起作用

对于 Dynamo 的分页响应,我试图保留该ExclusiveStartKey值。在代码示例中,如果我response.LastEvaluatedKey直接使用该值,后续请求可以正常工作。

但是,如果我序列化response.LastEvaluatedKey然后将其序列化回用作值ExclusiveStartKey,则后续请求将失败并显示以下错误消息:

提供的起始键无效:一个或多个参数值无效:空属性值类型必须具有 true 值

反序列化的字典似乎与原始字典具有相同的值...是否需要检查两者之间的差异?

QueryResponse response = null;

do
{

    string gsiPartitionKey = "gsi-pk-value-1";

    var queryRequest = new QueryRequest()
    {
        TableName = "my-table",
        IndexName = "my-index",
        KeyConditionExpression = "IndexPk = :s_gsiPartitionKey",
        ExpressionAttributeValues = new Dictionary<string, AttributeValue>
        {
            {
                ":s_gsiPartitionKey", new AttributeValue { S = gsiPartitionKey}
            }
        },
        Limit = 1
    };

    if (response != null)
    {
        //OPTION 1 - OK - Using LastEvaluatedKey directly works fine
        //queryRequest.ExclusiveStartKey = …
Run Code Online (Sandbox Code Playgroud)

c# serialization dictionary amazon-dynamodb jsonconvert

6
推荐指数
1
解决办法
1479
查看次数

读取NetworkStream不会提前流

我有一个客户端 - 服务器应用程序,其中服务器传输一个4字节的整数,指定下一次传输的大小.当我在客户端读取4字节整数(指定FILE_SIZE)时,下次读取流时,我得到FILE_SIZE + 4个字节读取.

从此流中读取时是否需要将偏移量指定为4,或者是否有办法自动推进NetworkStream以使我的偏移量始终为0?

服务器

NetworkStream theStream = theClient.getStream();

//...
//Calculate file size with FileInfo and put into byte[] size
//...

theStream.Write(size, 0, size.Length);
theStream.Flush();
Run Code Online (Sandbox Code Playgroud)

客户

NetworkStream theStream = theClient.getStream();

//read size
byte[] size = new byte[4];
int bytesRead = theStream.Read(size, 0, 4);

...

//read content
byte[] content = new byte[4096];
bytesRead = theStream.Read(content, 0, 4096);

Console.WriteLine(bytesRead); // <-- Prints filesize + 4 
Run Code Online (Sandbox Code Playgroud)

c# networkstream stream

3
推荐指数
1
解决办法
738
查看次数