小编Joe*_*uer的帖子

GetObject("winmgmts:...使 Excel 2016 崩溃,没有错误

我正在调试我在 Excel 2016 中编写的一些 VBA 代码,该子程序使 Windows Server 上的 Excel 2016 崩溃,没有错误。

它正在崩溃Set RegObj = GetObject...

Sub TestPrinter()
    On Error GoTo e
    Dim RegObj As Object
    'This next line is where the crash occurs...
    Set RegObj = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
Exit Sub
e:
    MsgBox "Error number " & Err & " in TestPrinter" & vbCrLf & "Error: " & Error$(Err)
End Sub
Run Code Online (Sandbox Code Playgroud)

我的最终目标是枚举计算机上连接的打印机,然后Application.ActivePrinter根据我从注册表中提取的字符串进行设置。这段代码在我尝试过的所有其他机器上都运行良好 - 但在这台服务器上失败了。

我该如何调试这个?错误处理程序永远不会被命中。

excel wmi vba windows-server excel-2016

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

绑定到静态类属性和 StringFormat

我能够将静态类属性绑定到 MenuItem 标头,但我无法确定如何包含 StringFormat 以便我可以显示除该属性之外的硬编码文本。

这可能吗?

当前:(显示“SQLSERVER1”)

Header="{x:Static settings:Settings.CurrentServer}"
Run Code Online (Sandbox Code Playgroud)

所需:(显示“连接:SQLSERVER1”)

Header="{Binding Source={x:Static Settings:Settings.CurrentServer},StringFormat='Connection: {0}'}"
Run Code Online (Sandbox Code Playgroud)

当我尝试 XAML 中的“Desired”行时,StringFormat 被完全忽略。我究竟做错了什么?

c# data-binding wpf user-interface xaml

6
推荐指数
2
解决办法
1895
查看次数

如何复制具有不同名称的工作表 - C#和Excel Interop

我想简单地在工作簿中复制一张表并给它一个不同的名称.

var pointName1 = workbook.Worksheets["PointName1"] as Worksheet;
pointName1.Copy(); // How do I access this newly created sheet?
Run Code Online (Sandbox Code Playgroud)

理想情况下,我希望能够编写这样的方法

pointName1.CopyTo("New Sheet");

其中"新工作表"是"PointName1"的重命名副本.

有时,PointName1将是工作簿中唯一的工作表,有时则会有其他工作表.

c# excel interop excel-interop

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

如何调试 AWS S3“拒绝访问”

我有一个在 Heroku 上托管的带有 Paperclip 的 rails 应用程序(虽然我现在只是在本地测试)

我已经创建了一个存储桶和一个AmazonS3FullAccess直接附加了策略的用户。

我有以下开发 .rb

  config.paperclip_defaults = {
   storage: :s3,
   s3_credentials: {
    bucket: ENV.fetch('S3_BUCKET_NAME'),
    access_key_id: ENV.fetch('AWS_ACCESS_KEY_ID'),
    secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY'),
    s3_region: ENV.fetch('AWS_REGION'),
   }
 }
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试将个人资料图片附加到我的模型时,我只是得到: Aws::S3::Errors::AccessDenied (Access Denied):

我该如何去调试这个问题?我已经删除并重新创建了我的 IAM 用户和我的存储桶,但我无法弄清楚我哪里出错了。

关于如何找出我遗漏的任何见解?

ruby-on-rails amazon-s3 paperclip amazon-web-services

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

Linq查询从多个List <string>中选择单个字符串

我很难理解为什么我会得到我的结果.

我有两个字符串列表:

var list1 = new List<String> {"item 1", "item 2"};
var list2 = new List<String> { "item 3", "item 4" };
Run Code Online (Sandbox Code Playgroud)

版本1 - 输出:"第2项"

var item =
            from x in (list1.Concat(list2))
            where x.EndsWith("2")
            select x;

        Console.WriteLine(item.First());
Run Code Online (Sandbox Code Playgroud)

版本2 - 输出:"i"

var item =
            from x in (list1.Concat(list2))
            where x.EndsWith("2")
            select x.First();

        Console.WriteLine(item.First());
Run Code Online (Sandbox Code Playgroud)

版本3 - 输出:"System.Linq.Enumerable + WhereEnumerableIterator`1 [System.String]"

var item =
            from x in (list1.Concat(list2))
            where x.EndsWith("2")
            select x;

        Console.WriteLine(item);
Run Code Online (Sandbox Code Playgroud)

鉴于版本2输出"i",我希望版本3输出"第2项".为什么会出现这种情况?

c# linq string

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

Nuxt:以模态形式打开组件/页面,使用专用 url,如 dribble.com

在我的 Nuxt 应用程序中,我有一个属性列表,单击时我想(/properties/_slug.vue)在用户所在的任何页面前面打开相应的属性页面作为模式。

dribble.com是我正在尝试重新创建的功能的一个确切示例。

如果从 中单击属性链接/,则 url 应该是/properties/slug-of-prop,当我点击关闭按钮或后退按钮时,它应该关闭模式并将 url 返回到单击前的状态。此外,我希望能够访问localhost:3000/properties/slug-of-prop并让它向我显示properties前面带有模态的列表。

我的文件结构是:

/pages
--index.vue
--/properties
----index.vue
----_slug.vue
Run Code Online (Sandbox Code Playgroud)

我已经尝试过这里列出的解决方案:https : //stackoverflow.com/a/60793173/2232797但是,它不会在点击后退按钮时删除模态。此外,我还尝试在此处通过使用中间件添加showModal为我的路由的参数来实现此 vue.js 解决方案,但它正在使用router-view我很难理解它是如何工作的。

这是我的/properties/index.vue样子:

<template>
  <section class="container-fluid">
    <!-- property cards -->
    <div class="info-row scroll-row border-bottom">
      <nuxt-link
        v-for="property in properties"
        :key="property"
        :to="`properties/${property.uid}`"
        tag="div"
      >
        {{ property.uid }}
      </nuxt-link>
    </div>
    <div v-if="showModal" class="modal-route">
      <div class="modal-content">
        <router-view></router-view>
      </div>
    </div>
  </section>
</template>

<script>
import { …
Run Code Online (Sandbox Code Playgroud)

vue.js vue-router nuxt.js

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