标签: sections

保存自定义配置节导致System.UnauthorizedAccessException

我在app.config中尝试使用自定义配置部分时遇到以下问题.我使用自定义配置部分来跟踪我想用我的程序备份的文件夹选择,如下所示:

<CustomConfigSection>
    <BackupLocations>
        <clear />
        <add path="C:\Users\Marcel\Documents\" />
    </BackupLocations>
</CustomConfigSection>
Run Code Online (Sandbox Code Playgroud)

现在,每当我保存配置文件时,我都会遇到以下异常:

System.Configuration.ConfigurationErrorsException:加载配置文件时发生错误:拒绝访问路径C:\ Program Files(x86)\ Backup Solutions\uqhuxi1j.tmp.(C:\ Program Files(x86)\ Backup Solutions\BS.exe.Config)---> System.UnauthorizedAccessException

我使用的代码是:

Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
CustomConfigSection section = (CustomConfigSection)config.GetSection("CustomConfigSection");

section.BackupLocations.Add(element);

section.SectionInformation.ForceSave = true;
config.Save(ConfigurationSaveMode.Full);
Run Code Online (Sandbox Code Playgroud)

以管理员身份登录时这种方法很有效,只有在PC上配置了多个帐户时才会发生这种情况,这意味着它是一个UAC /权限问题.作为普通用户,我没有该文件夹的正确写入权限.

现在我的问题:

为什么用户设置保存到AppData,而自定义配置部分试图保存在ApplicationFolder/exe.config中?如何将我的自定义部分保存到AppData配置文件中?

我需要能够为每个用户保存我的数据,无论权限如何.那么我可以使用自定义配置部分实现这一点,还是需要不同的方法?我最好也将自定义部分保存到AppData配置文件中.我不想在我的安装程序中使用技巧来调整我的应用程序文件夹的权限以允许它写入.最重要的是,我不想在启动程序时需要管理员权限!

感谢您的回复,非常感谢.

c# configuration sections

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

带有部分的站点地图中的锚链接

我在网页中使用了很多锚链接,因为它只有一个通过单击菜单向下滚动的页面。我还把所有页面分成几部分。

现在我正忙于为 google 制作 sitemap.xml,但我不确定是否需要放入所有部分/锚链接。

我的菜单是这样的:

<nav id="nav" role="navigation">
            <ul class="clearfix">
                <li>
                    <a class="selected firstnav" href="#home" tabindex="-1">
                        Home
                    </a>
                </li>
                <li>
                    <a href="#watdoenwij" tabindex="-1">
                        Wat doen wij
                    </a>
                </li>
                <li>
                    <a href="#portfolio" tabindex="-1">
                        Portfolio
                    </a>
                </li>
                <li>
                    <a href="#werkwijze" tabindex="-1">
                        Werkwijze
                    </a>
                </li>
                <li>
                    <a href="#uwwebsite" tabindex="-1">
                        De Website
                    </a>
                </li>
                <li>
                    <a class="lastnav" href="#contact" tabindex="-1">
                        Offerte & Contact
                    </a>
                </li>
            </ul>
        </nav>
Run Code Online (Sandbox Code Playgroud)

如您所见,我只使用#contact/#portfolio 等链接。我是否必须将所有链接放入我的站点地图中?

http://www.domain.com/index.php#contact
http://www.domain.com/index.php#uwwebsite
http://www.domain.com/index.php#portfolio
Run Code Online (Sandbox Code Playgroud)

我觉得不合适吗?也许谷歌将其视为双重内容......

如果我必须将其添加到我的站点地图中,我必须使用什么链接?

http://www.domain.com/index.php#contact 
http://www.domain.com/#contact
Run Code Online (Sandbox Code Playgroud)

sitemap anchor sections

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

使用NSFetchedResultsController对描述符进行排序 - Swift

我有一个UITableView从美联储Core DataNSFetchedResultsController返回位置的实体.默认排序(和节标题)是通过实体名称的第一个字母.这是有效的(尽管我仍然试图将大小写合并到相同的部分.)用户可以选择按三个可选类别之一(实体的属性)对表进行排序,然后对这些类别进行排序按实体名称.

当我设置按类别排序时,我得到以下运行时错误:

[_TtCSs23_ContiguousArrayStorage00007F80513B59D0 key]: unrecognized selector sent to instance 0x7f80513b5720
Run Code Online (Sandbox Code Playgroud)

这是我的NSFetchedResultsController:

var sectionNameKeyPathString1: String?
var sectionNameKeyPathString2: String?

var fetchedResultsController: NSFetchedResultsController {
    if _fetchedResultsController != nil {
        return _fetchedResultsController!
    }

    let fetchRequest = NSFetchRequest()
    // Edit the entity name as appropriate.
    let entity = NSEntityDescription.entityForName("Location", inManagedObjectContext: self.managedObjectContext!)
    fetchRequest.entity = entity

    // Set the batch size to a suitable number.
    fetchRequest.fetchBatchSize = 20

    // Edit the sort key as appropriate.
    if sectionNameKeyPathString1 != …
Run Code Online (Sandbox Code Playgroud)

nssortdescriptor nsfetchedresultscontroller unrecognized-selector sections swift

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

exe文件的大小与可用内存的大小

我已经了解了PE文件如何映射到内存中?,这不是我要求的.

我想知道PE文件的哪些部分(数据,文本,代码......)总是被加载器完全加载到内存中,无论条件是什么?

根据我的理解,没有任何部分(代码,数据,资源,文本......)总是完全加载,它们在需要时逐页加载.如果几页代码(中间或末尾)不需要处理用户的请求,那么这些页面将不会总是被加载.

我已经尝试使用大量带有/不带资源的代码制作exe文件,这两种资源都没有被使用,但是,每次exe加载到内存中时,它需要的内存比文件大小多.(我可能一直在查看任务管理器中错误的内存列)

Matt Pietrek在这里写道

值得注意的是,PE文件不仅仅作为单个内存映射文件映射到内存中.相反,Windows加载程序查看PE文件并确定要映射的文件的哪些部分.

内存中的模块表示进程所需的可执行文件中的所有代码,数据和资源.可以读取PE文件的其他部分,但不映射(例如,重定位).某些部分可能根本没有映射,例如,当调试信息放在文件末尾时.

简而言之,

1-有一个大小为1 MB的exe,可用内存(物理+虚拟)小于1 MB,加载器总是拒绝加载是否一致,因为可用内存小于文件大小?

2-如果大小为1 MB的exe在加载时开始运行2 MB内存(开始运行第一行用户代码),而可用内存(物理+虚拟)为1.5 MB,则加载程序始终拒绝加载是否一致,因为没有足够的记忆?

3-有一个大小为50 MB的exe(大量的代码,数据和资源),但它需要500 KB来运行第一行用户代码,如果可用内存,这个exe将始终运行第一行代码是一致的(物理+虚拟)至少是500 KB?

memory windows portable-executable sections

5
推荐指数
0
解决办法
882
查看次数

PE 最多可以有多少个部分?

我正在用 C# 编写一个程序,在其中读取 PE 的字节。但为了获得 RVA,我需要使用节标题。我想知道节标题的最大数量是多少?

我尝试过谷歌,我也看过这里,但我没有找到任何可以指引我正确方向的东西

谢谢。

byte header portable-executable sections

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

App.config:自定义配置嵌套部分

我找到了自定义配置处理程序的一个很好的例子,并尝试将它用于我自己的实现.

我已经像这样设置了App.config:

<configSections>
  <section name="DocumentationSettings" type="ConfigHandler.DocumentationSettings,Settings"/>
</configSections>

<DocumentationSettings>
  <DocumentationSections>
    <DocumentationSection Id="AAA">
      <SectionDescription Value="SectionDescriptionAAA"/>
    </DocumentationSection>
    <DocumentationSection Id="BBB">
      <SectionDescription Value="SectionDescriptionBBB"/>
    </DocumentationSection>
    <DocumentationSection Id="CCC">
      <SectionDescription Value="SectionDescriptionCCC"/>
    </DocumentationSection>
  </DocumentationSections>
</DocumentationSettings>
Run Code Online (Sandbox Code Playgroud)

我使用此代码访问我的自定义配置:

DocumentationSettings documentationSettings = ConfigurationManager.GetSection("DocumentationSettings") as DocumentationSettings;

foreach (DocumentationSectionConfigElement section in (documentationSettings.DocumentationSections.Sections))
{
    Console.WriteLine(section.Id);
    Console.WriteLine(section.SectionDescription.Properties.Value);
}
Run Code Online (Sandbox Code Playgroud)

首先'Console.WriteLine'完美无缺.

所以我有以下问题和实施相关的问题:

  1. 第二个'Console.WriteLine'出错,错误:无法识别的属性'Value'.我已经放了"public SectionDescription SectionDescription",因为"DocumentationSectionConfigElement"类暴露了属性访问,但我可能错了,我先尝试将它放入"DocumentationSectionCollection",但我不知道如何在那里实现它,对我来说似乎是"DocumentationSectionCollection"仅实现"集合"逻辑.

  2. 我想要像这样访问"字段":

    section.Id section.SectionDescription.Value

或者像这样:

section.Properties.Id
section.SectionDescription.Properties.Value
Run Code Online (Sandbox Code Playgroud)

我看到"Collection"允许使用这样的索引器方法直接使用这些属性:

public DocumentationSectionConfigElement this[int index]
Run Code Online (Sandbox Code Playgroud)

但我不能在"SectionDescription"类上实现索引器方法,因为它是一个单独的部分而不是集合,所以当我访问字段时,这个"属性"名称仍然存在.

  1. 为了能够在这些配置对象上使用LINQ,我需要添加什么?我的意思是这样的:

    (documentationSettings.DocumentationSections.Sections).Select(x => x.Id)

  2. 复杂的XML结构配置处理程序是否有很好的例子?从我发现的那些大多数简单的结构,如:

但没有像这样的复杂结构的任何例子:

<section>
  <subSections>
    <subSection name="111">
      <Description Value="AAA"></Description>
      <Headers>
        <Header type="Main">
         <Properties>
           <Property name="Property1"/> …
Run Code Online (Sandbox Code Playgroud)

c# configuration app-config sections

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

不同表格视图部分中的不同布局

嗨,我想在 UITableView 的不同部分有不同的布局,我想使用动态原型单元格而不是使用静态单元格来做到这一点。我不知道如何创建它,请帮助。任何链接什么的。我想实现这样的,请看图片 请下载图片

如果有的话,请快速提供您的代码。

uitableview sections ios9 swift2

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

选择在ios swift中的数组中的uitableview部分中取消选择收音机

在tableview中有不同的部分。

要为所有部分添加单选按钮。

每个部分在表格视图中都有单独的选择和取消选择。

在第一部分的选择1中,[如图所示]

选中的奶酪表示要选择奶酪,如果用户单击培根,则表示奶酪自动取消选择。

[这里使用单选按钮SSRadioButton类进行单击操作。在表格视图单元格中创建一个单选按钮。如何编写单选按钮的按钮动作。或建议任何新方法]。

每个单选按钮都需要单独选择和取消选择。表格视图中所有部分的处理相同。怎么可能帮助我。谢谢前进。在此处输入图片说明

我的代码:

 var radioControllerChoice : SSRadioButtonsController = SSRadioButtonsController()
    var radioControllerDip : SSRadioButtonsController = SSRadioButtonsController()

func numberOfSections(in tableView: UITableView) -> Int {
        return table_data.count
    }

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        // Return the number of rows in the section.
        return table_data[section].menu_id.count
    }

 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
    {
        let cell:CustomiseTableViewCell = tableView.dequeueReusableCell(withIdentifier: "Customise") as! CustomiseTableViewCell
        cell.name.text?=table_data[indexPath.section].menu_name[indexPath.row]
        print(table_data[indexPath.section].customize[indexPath.row])

        switch indexPath.section {
        case 2:
            radioControllerChoice.addButton(cell.radioBtn)
            radioControllerChoice.shouldLetDeSelect = false …
Run Code Online (Sandbox Code Playgroud)

radio-button tableview sections swift

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

如何使用 OpenMP 为每个函数分配不同数量的线程

我有两个函数,第二个函数中有一个 for 循环。

fun1() {
    ...
}
fun2() {
    for(...) {
    }
}
Run Code Online (Sandbox Code Playgroud)

现在我想并行运行fun1fun2即每个函数使用单个线程)。在里面fun2我希望我可以用来omp parallel for执行 for 循环。

我尝试像这样实现它。

fun1() {
}

fun2() {
    #pragma omp for
    for() {
    }
}

int main() {
    #pragma omp parallel
    {
        #pragma omp single
        {
            fun1();
        }
        fun2();
    {
}
Run Code Online (Sandbox Code Playgroud)

但它会调用fun2多次。

那么有办法做到这一点吗?

parallel-processing multithreading for-loop openmp sections

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

X86 汇编:.text.startup 部分和 .text 部分有什么区别

    .file   "test-instr.c"
    .text
.Ltext0:
    .section    .rodata.str1.1,"aMS",@progbits,1
.LC0:
    .string "Hum?"
.LC1:
    .string "Looks like a zero to me!"
.LC2:
    .string "A non-zero value? How quaint!"
    .section    .text.startup,"ax",@progbits
    .p2align 4,,15
    .globl  main
    .type   main, @function
main:
/* --- trampoline malloc shm space begin --- */ 

.align 4 

.section .data 
shmSize: .quad 8 * 4 * 0x10000 
.global shmptr
shmptr: .quad 0
.section .text
.extern malloc 
movq (shmSize), %rdi 
call malloc 
movq %rax, (shmptr) 
/* --- trampoline malloc shm spacd end --- */ …
Run Code Online (Sandbox Code Playgroud)

x86 assembly gcc gnu-assembler sections

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