小编Har*_*run的帖子

写入事件日志时出错,阻止Windows服务启动?

我使用以下代码在我的Windows服务应用程序中创建自定义事件日志:

public ServiceConstructor()
{
  InitializeComponent();
  if (!EventLog.SourceExists("WinService"))
  {
    EventLog.CreateEventSource("WinService", "WinServiceLog");
    eventLog1.Source = "WinService";
    eventLog1.Log = "WinServiceLog";
  }
}
protected override void OnStart(string[] args)
{
 eventLog1.WriteEntry("Started");
}
Run Code Online (Sandbox Code Playgroud)

安装service.msi后,当我启动服务时,它启动然后停止.然后我在EventViewer Windows日志部分中发现以下错误:

服务无法启动.System.ArgumentException:在写入事件日志之前未设置Source属性.

at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData) at System.Diagnostics.EventLog.WriteEntry(String message) at WinService.Service.OnStart(String[] args) at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)

c# windows-services event-log

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

使用VisualSVN Server和Cruisecontrol.net检查内容集成中的修改失败

我正在使用CruiseControl.net进行持续集成.我使用VisualSvn服务器为我的项目创建了一个存储库(使用Windows身份验证).两台服务器都托管在同一系统中(Os-Microsoft Windows Server 2003 sp2).

当我使用CruiseControl.net强制构建项目时," 失败的任务:Svn:CheckForModifications "显示为消息.当我检查构建报告时,它说如下:

BUILD EXCEPTION 
Error Message: ThoughtWorks.CruiseControl.Core.CruiseControlException: Source control operation failed: svn: OPTIONS of 'https://system:8443/svn/folder/Source': **Server certificate verification failed: issuer is not trusted** (https://system:8443). Process command: C:\Program Files\VisualSVN Server\bin\svn.exe log **sameUrlAbove** -r "{2010-04-29T08:35:26Z}:{2010-04-29T09:04:02Z}" --verbose --xml --username ccnetadmin --password cruise --non-interactive --no-auth-cache
at ThoughtWorks.CruiseControl.Core.Sourcecontrol.ProcessSourceControl.Execute(ProcessInfo processInfo)
at ThoughtWorks.CruiseControl.Core.Sourcecontrol.Svn.GetModifications (IIntegrationResult from, IIntegrationResult to)
at ThoughtWorks.CruiseControl.Core.Sourcecontrol.QuietPeriod.GetModifications(ISourceControl sourceControl, IIntegrationResult lastBuild, IIntegrationResult thisBuild)
at ThoughtWorks.CruiseControl.Core.IntegrationRunner.GetModifications(IIntegrationResult from, IIntegrationResult to)
at ThoughtWorks.CruiseControl.Core.IntegrationRunner.Integrate(IntegrationRequest request) 
Run Code Online (Sandbox Code Playgroud)

ccnet.config中的我的SourceControl节点如下所示:

<sourcecontrol type="svn">
  <executable>C:\Program Files\VisualSVN Server\bin\svn.exe</executable>
  <trunkUrl>
    check out …
Run Code Online (Sandbox Code Playgroud)

svn cruisecontrol.net visualsvn-server

5
推荐指数
2
解决办法
3813
查看次数

如何使用c#中的文件上传控件的内容类型属性(不检查扩展名)来验证上传的文件是否为csv?

我需要检查上传文件是否是csv而不检查文件扩展名.如果将非csv文件重命名为".csv"扩展名,则使用filecontent属性也无法有效地找到该类型.我需要防止这种事情发生.

任何人请建议一种通过阅读标题信息来查找内容类型的方法.

c# asp.net validation content-type file-upload

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

如何从UTF 8编码的csv中删除BOM()字符?

我需要解析一个utf8编码的csv.在转换之后,我刚刚看到问题在于beging的BOM()字符.我无法使用utf8编码创建一个避免BOM的csv,因为我需要解析它,即使它是utf8编码的.

任何人请告诉我如何使用c#.net从csv中删除BOM()字符.

更新:我已经添加了我的代码来读取csv头文件,因为我在文件的开头获取了BOM.

 string CSVConnectionString = "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" + ConfigurationSettings.AppSettings["CSVFolder"].ToString() + ";Extensions=asc,csv,tab,txt;Persist Security Info=False;";

        using (OdbcConnection Connection = new OdbcConnection(CSVConnectionString))
        {
            List<string> CSVHeaders = new List<string>();

            string SelectQuery = string.Format(@"SELECT TOP 1 * FROM [{0}]", CSVFileName);

            OdbcCommand Command = new OdbcCommand(SelectQuery, Connection);

            Connection.Open();

            OdbcDataReader Reader = Command.ExecuteReader(System.Data.CommandBehavior.CloseConnection);

            int ColumnCount = Reader.FieldCount;

            for (int column = 0; column < ColumnCount; column++)
            {
                CSVHeaders.Add(Reader.GetName(column));
            }

            return CSVHeaders;
        }
Run Code Online (Sandbox Code Playgroud)

c# csv parsing utf-8

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

如何在不使用循环的情况下从数据表中过滤空行?

我的情况是数据表可能包含大量行.因此,我无法使用循环迭代和更新数据表.

我试过以下代码,

          from row in table.AsEnumerable()
          where table.Columns.Any(col => !row.IsNull(col))
          select row;
Run Code Online (Sandbox Code Playgroud)

但是我找不到Any()的定义.我应该使用任何命名空间来获取Any()吗?

任何机构请告诉我如何更正或建议任何替代解决方案..

c# datatable

4
推荐指数
1
解决办法
2438
查看次数

如何在c#中使用OpenXml为excel文件的列/列设置数据验证列表?

我需要使用openXml使用特定列表作为excel文件的列/列中的源创建下拉列表.

我使用以下代码,

     SpreadsheetDocument spreadSheetDocument = SpreadsheetDocument.Open("C:\\Users\\Harun.TV\\Desktop\\OpenXml\\1.xlsx",true);

        WorkbookPart workbookpart = spreadSheetDocument.WorkbookPart;
        Workbook workbook=workbookpart.Workbook;


        WorksheetPart worksheetPart=workbookpart.WorksheetParts.First();            


        DataValidations dataValidations1 = new DataValidations();
        DataValidation dataValidation2 = new DataValidation() { Formula1 = new Formula1("'mySheet'!$A$1:$A$4"), Type = DataValidationValues.List, AllowBlank = true, ShowInputMessage = true, ShowErrorMessage = true, SequenceOfReferences = new ListValue<StringValue>() { InnerText = "A4:B4" } };
        Formula1 formula12 = new Formula1();
        formula12.Text = "$A$1:$A$3";
        dataValidations1.Append(dataValidation2);
        worksheetPart.Worksheet.Append(dataValidations1);

         workbookpart.Workbook.Save();


        spreadSheetDocument.Close();
Run Code Online (Sandbox Code Playgroud)

并且它会在打开excel时抛出错误.日志如下,

      <?xml version="1.0" encoding="UTF-8" standalone="true"?>
     -<recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">     <logFileName>error055840_01.xml</logFileName>
      <summary>Errors were detected in file  'C:\Users\Harun.TV\Desktop\OpenXml\6.xlsx'</summary>
      -<removedParts summary="Following is …
Run Code Online (Sandbox Code Playgroud)

validation list openxml c#-4.0

4
推荐指数
1
解决办法
3855
查看次数

使用**SUBST cmd**创建的文件夹无法在IIS 6上运行

使用SUBST cmd创建的文件夹无法在IIS 6上运行.在IIS 7(使用Windows 7)中,虚拟驱动器在浏览时不会列出,以便为虚拟目录设置物理路径.

任何人都可以告诉我如何解决这个问题吗?有没有更好的方法来创建SUBST以外的虚拟驱动器

iis-7 iis-6 virtual-directory

3
推荐指数
2
解决办法
1967
查看次数

使用 ng2-adal 库的 Angular4 azure 活动目录身份验证在与哈希位置策略一起使用时失败

使用 ng2-adal 库的 Angular4 azure 活动目录身份验证从 url 中删除 id_token。

我参考了以下博客的实现。 https://dotronald.be/add-azure-active-directory-to-an-existing-angular-2-single-page-application/

  1. 安装 ng4-adal

  2. 为 ng4-adal 创建了一个 typescript 配置文件来设置 azure 连接细节,如下所示,从 '@angular/core' 导入 {Injectable};

            @Injectable()
           export class AdalConfig {
                  public get getAdalConfig(): any {
                  return {
                      tenant: 'YOUR TENANT NAME',
                      clientId: 'YOUR CLIENT ID',           
                      redirectUri: window.location.origin + '/',
                       postLogoutRedirectUri: window.location.origin + 
                      '/logout'
                };
                }
             }
    
    Run Code Online (Sandbox Code Playgroud)
  3. 创建了一个 canActivate 守卫,在导航前验证角度路线,如下所示,

             import { Injectable } from '@angular/core';
             import { Router, CanActivate,   
             ActivatedRouteSnapshot,RouterStateSnapshot, NavigationExtras } 
             from '@angular/router';
             import {AdalService} from "ng4-adal/core";
    
             @Injectable()
             export class AuthenticationGuard …
    Run Code Online (Sandbox Code Playgroud)

azure-active-directory angular

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

将asp迁移到asp.net(c#.net)

我有一个用经典asp开发的网站.现在我想将它转换为asp.net(2.0或更高版本).

如果不从头开始编码,我怎么能这样做?
你能建议一个免费或廉价的工具来做这项工作吗?

asp.net-2.0 asp-classic

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

在处理大文件时,通过Windows服务运行ffmpeg.exe无法完成

我使用ffmpeg.exe将视频文件转换为flv格式.为此,我使用Windows服务在后台运行转换过程.当试图通过Windows服务转换大文件(我在文件大小> 14MB时遇到它)时,它会卡在启动进程的行(即process.start();).

但是,当我尝试直接从命令提示符执行ffmpeg.exe时,它解决了任何问题.

我的代码Windows服务是为如下:

private Thread WorkerThread; 
protected override void OnStart(string[] args)
{ 

   WorkerThread = new Thread(new ThreadStart(StartHandlingVideo));
   WorkerThread.Start();
}

protected override void OnStop()
{ 
   WorkerThread.Abort();
}

private void StartHandlingVideo()
{   
   FilArgs = string.Format("-i {0} -ar 22050 -qscale 1 {1}", InputFile, OutputFile);
   Process proc;
   proc = new Process();

   try
   {

     proc.StartInfo.FileName = spath + "\\ffmpeg\\ffmpeg.exe";
     proc.StartInfo.Arguments = FilArgs;
     proc.StartInfo.UseShellExecute = false;
     proc.StartInfo.CreateNoWindow = false; …
Run Code Online (Sandbox Code Playgroud)

.net c# windows-services ffmpeg video-processing

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

使用进程通过c#.net执行exe文件时,Windows服务无法启动

我正在使用Windows服务来执行ffmpeg.exe转换视频文件.我是通过在c#.net中查看进程来完成此操作的.问题是

我在Windows服务的OnStart()中的代码如下:

FilArgs = string.Format("-i {0} -ar 22050 -qscale 1 {1}", InputFile, OutputFile);

Process proc;
proc = new Process();

try
{
    proc.StartInfo.FileName = spath + "\\ffmpeg\\ffmpeg.exe";
    proc.StartInfo.Arguments = FilArgs;
    proc.StartInfo.UseShellExecute = false;
    proc.StartInfo.CreateNoWindow = false;
    proc.StartInfo.RedirectStandardOutput = true;
    proc.StartInfo.RedirectStandardError = true;

    eventLog1.WriteEntry("Going to start process of convertion");

    proc.Start();

    string StdOutVideo = proc.StandardOutput.ReadToEnd();
    string StdErrVideo = proc.StandardError.ReadToEnd();

    eventLog1.WriteEntry("Convertion Successful");
    eventLog1.WriteEntry(StdErrVideo);               

}
catch (Exception ex)
{
    eventLog1.WriteEntry("Convertion Failed");
    eventLog1.WriteEntry(ex.ToString());            
}
finally
{
    proc.WaitForExit();
    proc.Close();
}
Run Code Online (Sandbox Code Playgroud)

当我试图转换大型视频文件(我在文件大小> …

c# windows-services

0
推荐指数
1
解决办法
495
查看次数