小编Pet*_*r B的帖子

Visual Studio 2017 错误无法打开“X”进行写入 - 对路径的访问被拒绝

抱歉,我似乎无法修复此错误:

在此处输入图片说明

严重性代码描述项目文件行抑制状态错误 CS2012 无法打开 'C:\Users\Usuario\source\repos\WindowsFormsApp1\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.exe' 进行写入 -- 'Access to the path 'C:\Users \Usuario\source\repos\WindowsFormsApp1\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.exe' 被拒绝。WindowsFormsApp1 C:\Users\Usuario\source\repos\WindowsFormsApp1\WindowsFormsApp1\CSC 1 Active

我想这与只读文件有关吗?我尝试更改它并恢复为只读,我尝试关闭并重新打开 VS,我尝试以管理员身份运行它,我更改了程序集名称和默认命名空间,现在它甚至无法运行调试器

我是 C# 的新手,我曾经做过 Java,从来没有遇到过这样的错误,对不起,如果它很简单。顺便说一句,我使用的是安装了 Bitdefender 的 Windows 10

c# visual-studio visual-studio-2017

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

AVAudioPlayer - 测量 - 想要构建波形(图形)

我需要构建一个可视图表来表示录制文件中的语音级别(dB).我试着这样做:

NSError *error = nil;
AVAudioPlayer *meterPlayer = [[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL fileURLWithPath:self.recording.fileName] error:&error];

if (error) {
    _lcl_logger(lcl_cEditRecording, lcl_vError, @"Cannot initialize AVAudioPlayer with file %@ due to: %@ (%@)", self.recording.fileName, error, error.userInfo);
} else {
    [meterPlayer prepareToPlay];
    meterPlayer.meteringEnabled = YES;

    for (NSTimeInterval i = 0; i <= meterPlayer.duration; ++i) {
        meterPlayer.currentTime = i;
        [meterPlayer updateMeters];
        float averagePower = [meterPlayer averagePowerForChannel:0];
        _lcl_logger(lcl_cEditRecording, lcl_vTrace, @"Second: %f, Level: %f dB", i, averagePower);
    }
}
[meterPlayer release];
Run Code Online (Sandbox Code Playgroud)

如果它解决了它会很酷,但事实并非如此.我总是得到-160分贝.关于如何实现的任何其他想法?

UPD:这是我最后得到的:

替代文字http://img22.imageshack.us/img22/5778/waveform.png

iphone avaudioplayer

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

HTML:在mailto?body中发送图片

我习惯使用mailto函数设置带有文本的电子邮件的正文和主题,例如:

href="mailto:?body=Thanks!"
Run Code Online (Sandbox Code Playgroud)

但有没有办法在身体中发送图像?例如:

href="mailto:?body=<img src='http://www.example.com/image.jpg'>"
Run Code Online (Sandbox Code Playgroud)

(显然上面不起作用 - 它只是将html添加为字符串)

任何建议赞赏!谢谢!

html mailto email

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

.NET .resx文件:为什么name属性通常以&gt;&gt;开头

在许多.resx文件中,我遇到过这样的事情:

<data name="&gt;&gt;OurLabel.Name" xml:space="preserve">
  <value>OurLabel</value>
</data>
Run Code Online (Sandbox Code Playgroud)

我的问题是:为什么属性name在很多情况下 - 但并非总是 - 从一开始&gt;&gt;

.net resx winforms

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

在 C# 中使用对象初始值设定项时无法识别抛出异常的属性

在下面的两个示例代码中,我试图通过使用 C# 普通方法和对象初始值设定项来实例化一个名为Test的类。

DateTime? nullDate = null; //this value will come from somewhere else
DateTime? notNullDate = DateTime.Now;
var test = new Test();
test.Date = nullDate.Value; //exception will throw here
test.Name = "String";
test.AnotherDate = notNullDate.Value;
Run Code Online (Sandbox Code Playgroud)

在上面的示例代码中,我可以清楚地了解调试时哪个属性显示异常。

DateTime? nullDate = null; //this value will come from somewhere else
DateTime? notNullDate = DateTime.Now;
var test = new Test
{
    Date = nullDate.Value,
    Name = "String",
    AnotherDate = notNullDate.Value
};
Run Code Online (Sandbox Code Playgroud)

在上面的代码中,当我使用对象初始值设定项时,我无法理解抛出异常的属性。在这里,我无法逐行调试。如果我初始化了很多属性,则很难识别。

这是我的问题:如何从异常窗口识别哪个属性显示异常?现在内部异常为空。

在此处输入图片说明

c# exception object-initializers

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

阻止提交通过ajax加载的表单

我有一个jquery ajax调用,在div中加载一个表单,我想阻止提交这个表单,但如果我使用jquery提交函数与

$("form").submit(function(e){
  e.preventDefault(e);
  alert('submit intercept');
});
Run Code Online (Sandbox Code Playgroud)

如果我放在外部js文件中它不起作用,但如果我在通过ajax调用加载的表单后放入脚本标记,则无效.

javascript ajax jquery

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

迁移到 .NET 5 后,输出参数显示错误“使用未分配的局部变量”

public bool TryGetCustomerId(out Guid customerId)
{
    customerId = Guid.Empty;
    if (_contextAccessor.HttpContext?.Request.Headers.TryGetValue(CustomKnownHeaders.CustomerId,
        out var values) ?? false)
    {
        return Guid.TryParse(values.FirstOrDefault(), out customerId);
    }

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

从 .NET Core 3.1 迁移到 .NET 5 后,输出参数变量显示错误“使用未分配的局部变量”。

错误显示在“值”变量中。错误 - “使用未分配的局部变量‘值’”

.net c# asp.net .net-5

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

Bootstrap - 4列网格

我无法在页面上获取这些行.我总是将页面减半分成两个水平部分,我想要四个垂直部分.

这是图片: 图片:

这是我的代码的小提琴,你可以很容易地知道我想要的东西FIDDLE.

我只需要那些中间内容就像在图片上一样.. 4个垂直列,在那个列中我有2个块.

这是我的尝试:

<div class="col-md-12">
<div class="pane border-right">
<div>
<div style="float: left;">
</div>
</div>
<div class="col-md-6 specifica ">
<div class="col-sm-3 border-right-dotted">

a

</div>
<div class="col-sm-3 border-right-dotted">

b

</div>

</div>
<div class="col-md-3 specifica ">
<div class="col-sm-3 border-right-dotted">

c

</div>
<div class="col-sm-3 ">

d

</div>
</div>
Run Code Online (Sandbox Code Playgroud)

html css twitter-bootstrap

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

可选参数必须是引用类型,可空类型,或者声明为可选参数.参数名称:参数`

我正在.net MVC中创建一个演示应用程序.

下面是我的StudentController的代码片段.

public ActionResult Edit(int studentId)
{
    var std = studentList.Where(s => s.StudentId == studentId).FirstOrDefault();
    return View(std);
}

[HttpPost]
public ActionResult Edit(Student std)
{
    //write code to update student 

    return RedirectToAction("Index");
}
Run Code Online (Sandbox Code Playgroud)

来自RouteConfig的代码片段:

routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

routes.MapRoute(
    name: "Default",
    url: "{controller}/{action}/{id}",
    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
Run Code Online (Sandbox Code Playgroud)

当我点击url时,http://localhost:54977/student/Edit/1我会遇到异常.

The parameters dictionary contains a null entry for parameter 'studentId' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Edit(Int32)' in 'MVC1.Controllers.StudentController'. An optional parameter …

c# asp.net-mvc

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

使用javascript检查用户是否是第一次访问

我正在尝试构建一个系统,如果用户第一次登陆某个页面,则不会发生任何事情,但如果同一用户再次访问,则该页面不应加载,而是应该转到不同的 URL。

function session() {
    if (document.cookie.indexOf("visited") > 0) {
        window.location.href = "www.google.com";
    } else {
        document.cookie = "visited";
    }
}
Run Code Online (Sandbox Code Playgroud)

这是完整的 html 只是为了测试它的工作情况

<html>
<head>
</head>
<body>
    1st visit
    <script type="text/javascript">
    function session() {
        if (document.cookie.indexOf("visited") > 0) {
            window.location.href = "www.google.com";
        } else {
            document.cookie = "visited";
        }
    }
    </script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

javascript

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