我有一个有效的自定义配置部分。但是,通过 a 获取我的数据很痛苦,ConfigurationElementCollection但是当我尝试将我的属性实现为 IEnumerable 时,它失败并显示错误:
ConfigurationErrorsException 未处理“属性 'contacts' 不是 ConfigurationElement。”
这是导致失败的代码:
[ConfigurationProperty("contacts", IsDefaultCollection = false)]
public IEnumerable<string> Contacts
{
get { return ((ContactCollection)base["contacts"]).Cast<ContactElement>().Select(x => x.Address); }
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我将其更改为:
[ConfigurationProperty("contacts", IsDefaultCollection = false)]
public ContactCollection Contacts
{
get { return ((ContactCollection)base["contacts"]); }
}
Run Code Online (Sandbox Code Playgroud)
一切正常。这个答案听起来像是微软决定不允许的东西,所以我不能拥有除ConfigurationElement. 真的是这样吗?如何将我的财产实施为IEnumerable<string>?
以防万一,我正在尝试存储电子邮件,并且我希望每个电子邮件都有一个元素,因为可能有很多电子邮件,我们可能希望将来存储有关每个联系人的更多信息,我认为单个以逗号分隔的列表可能会变得丑陋。例如,类似于:
<emergency>
<contact address="sirdank@stackoverflow.com" />
<contact address="jon.skeet@stackoverflow.com" />
</emergency>
Run Code Online (Sandbox Code Playgroud)
或者
<emergency>
<contact>sirdank@stackoverflow.com</contact>
<contact>jon.skeet@stackoverflow.com</contact>
</emergency>
Run Code Online (Sandbox Code Playgroud)
谢谢!
我创建了一个这样的 gMSA:
New-ADServiceAccount -name Cust00000 -DNSHostName Cust00000.domain.com -PrincipalsAllowedToRetrieveManagedPassword "IIS_IUSRS" -ManagedPasswordIntervalInDays 60
Run Code Online (Sandbox Code Playgroud)
而生活似乎也很美好。然而,当我跑步时
Test-ADServiceAccount Cust00000
Run Code Online (Sandbox Code Playgroud)
这就是我得到的:
False
WARNING: Test failed for Managed Service Account Cust00000. If standalone Managed Service Account, the account is
linked to another computer object in the Active Directory. If group Managed Service Account, either this computer does
not have permission to use the group MSA or this computer does not support all the Kerberos encryption types required
for the gMSA. See the MSA operational log for more …Run Code Online (Sandbox Code Playgroud) 我按照入门Wix指南中的说明创建了一个合并模块:http://wix.sourceforge.net/manual-wix2/authoring_merge_modules.htm .
这是合并模块wxs:
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Module Id="SomeRepositoryMergeModule" Language="1033" Version="1.0.0.0">
<Package Id="f11e7321-a687-4d53-8be7-21a8ae0721a6" Manufacturer="SomeCompany Technologies" InstallerVersion="200" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="MODULEINSTALLLOCATION" Name="Some Repository">
<Component Id="ServicesHostWindowsService" Guid="257D1FAE-4AFF-4155-BDB8-D81F50E5862B">
<File Id="ServicesHostInstallerExecutable" KeyPath="yes" DiskId="1" Name="WindowsServiceHost.exe" Source="..\WindowsServiceHost\bin\Output_For_Installer\WindowsServiceHost.exe" />
<File Id="ServicesHostConfig" KeyPath="no" DiskId="1" Name="WindowsServiceHost.exe.config" Source="..\WindowsServiceHost\bin\Output_For_Installer\WindowsServiceHost.exe.config" />
<File Id="SomeCompanyCommon" KeyPath="no" DiskId="1" Name="SomeCompany.Common.dll" Source="..\WindowsServiceHost\bin\Output_For_Installer\SomeCompany.Common.dll" />
<File Id="SomeRepositorySqlScript" KeyPath="no" DiskId="1" Name="SomeRepository.sql" Source="..\..\..\..\..\DB\SomeRepository\SomeRepository.sql" />
<File Id="LogConfigXml" KeyPath="no" DiskId="1" Name="log.config.xml" Source="..\WindowsService\log.config.xml" />
<ServiceInstall Id="ServicesHostInstallElement" ErrorControl="normal" Start="auto" Type="ownProcess" Vital="yes"
Name="AServer WindowsService Host"
Description="The windows service responsible for hosting SomeCompany …Run Code Online (Sandbox Code Playgroud) 为什么有人会这样做?我不明白.我可以在不影响代码的情况下删除此try-catch块吗?
try
{
Collection<SvnLogEventArgs> svnLog = GetSVNRevisionsLog(lastRevision, currentRevision, svnUrl);
svnInfo = PopulateOutput(svnLog, svnUrl.ToString());
}
catch (Exception e)
{
throw e;
}
Run Code Online (Sandbox Code Playgroud) 我在自己的guid中使用自动guids,<Product>但无法弄清楚如何使用它们<Module>.我只收到这个错误:
组件X有一个密钥文件,路径为'TARGETDIR\company ...'.由于此路径未植根于其中一个标准目录(如ProgramFiles文件夹),因此该组件不符合自动生成guid的条件.
上面company是映射到的值!(loc.ProductManufacturerFolderName).
唯一的问题是这不是真的.我的目录根植于ProgramFiles,就像我的产品一样,我的产品工作正常:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="MODULEINSTALLLOCATION" Name="!(loc.ProductManufacturerFolderName)">
<Directory Id="Data" Name="Data">
Run Code Online (Sandbox Code Playgroud)
我的所有组件声明看起来大致如下:
<Component Id="DocumentationParty_Business_TestCases_v1xlsx.component" Guid="{YOURGUID-1234-1234-84B3-C595A63428AD}" MultiInstance="yes">
<File Source="../../Development/Integration/SSIS/Documentation/Party_Business_Test Cases_v1.xlsx" KeyPath="yes" Id="DocumentationParty_Business_TestCases_v1xlsx.file" />
</Component>
Run Code Online (Sandbox Code Playgroud)
打破它很容易,你只需要更改GUID *和上面的错误结果.这已破了:
<Component Id="DocumentationParty_Business_TestCases_v1xlsx.component" Guid="*" MultiInstance="yes">
<File Source="../../Development/ClaimsIntegration/SSIS/Documentation/Party_Business_Test Cases_v1.xlsx" KeyPath="yes" Id="DocumentationParty_Business_TestCases_v1xlsx.file" />
</Component>
Run Code Online (Sandbox Code Playgroud)
我有一个.wxs文件,用于安装组件的每个目录.我的所有组件持有.wxs文件具有以下结构:
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<ComponentGroup Id="DatabasePolicy_Files">
<ComponentRef Id="DatabasePolicyCreateDatabasecmdtemplate.component" />
</ComponentGroup>
<DirectoryRef Id="DataPolicy">
<Component Id="DatabasePolicyCreateDatabasecmdtemplate.component" Guid="*" MultiInstance="yes">
<File Source="../../Development/Database/Policy/CreateDatabase.cmd.template" KeyPath="yes" Id="DatabasePolicyCreateDatabasecmdtemplate.file" />
</Component>
</DirectoryRef>
</Fragment>
</Wix>
Run Code Online (Sandbox Code Playgroud)
每个<ComponentGroup>都包含在我的主.wxs文件中<ComponentGroupRef>.这适用于我所有的MSI项目,只有在我开始使用合并模块时才会中断.此外,我已经尝试注释掉除了与上述定义匹配的所有组件,它仍然会在同一错误上中断. …
我正在尝试使用以下VB脚本从Windows Temp文件夹中删除所有以字符串“ MyApp”开头的日志文件。
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
if objFSO.FolderExists("C:\Documents and Settings\guest\MyApp") Then
set folder = objFSO.getFolder("C:\Documents and Settings\guest\MyApp")
if folder.files.Count <> 0 then
objFSO.DeleteFile "C:\Documents and Settings\guest\MyApp\*.*", True
end if
objFSO.DeleteFolder "C:\Documents and Settings\guest\MyApp", True
end if
<!-- The below code is not deleting the files which starts with the name "Mpp.023648011.log" -->
if(objFSO.FileExists("C:\Documents and Settings\guest\Local Settings\Temp\MyApp.*")) Then
objFSO.DeleteFile "C:\Documents and Settings\guest\Local Settings\Temp\MyApp.*", True
end if
Run Code Online (Sandbox Code Playgroud)
似乎以下检查失败:
if(objFSO.FileExists(“ C:\ Documents and Settings \ guest \ Local Settings \ …
如何为~50 xml文件添加进程指令?
<?xml-stylesheet type="text/xsl" href="Sample.xsl"?>
Run Code Online (Sandbox Code Playgroud)
如果我追加节点,它会被添加到文件的末尾,但它必须是第一个.
这是我的加密和解密方法.我有两个数据库,我将加密的密码从一个数据库复制到另一个数据库.代码是在vb中,但我将其转换为C#.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
using System.IO;
namespace AccountSystem.Class{
class ClEncrDecr
{
private TripleDESCryptoServiceProvider tripleDESCryptoServiceProvider = new TripleDESCryptoServiceProvider();
private byte[] TruncateHash(string key, int length)
{
SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider();
//Hash the Key
byte[] keyBytes = System.Text.Encoding.Unicode.GetBytes(key);
byte[] hash = sha1.ComputeHash(keyBytes);
// truncate or pad the hash
Array.Resize(ref hash, length);
return hash;
}
public ClEncrDecr()
{
string key = "ABCD";
tripleDESCryptoServiceProvider.Key = TruncateHash(key, tripleDESCryptoServiceProvider.KeySize / 8 );
tripleDESCryptoServiceProvider.IV = TruncateHash("", tripleDESCryptoServiceProvider.BlockSize / 8 ); …Run Code Online (Sandbox Code Playgroud)