我注意到VS 2010中的即时窗口在调试C#项目和VB.NET项目时表现不同,尽管我还没有找到任何关于这种差异的具体文档.
对于C#项目,我只需输入任何表达式,它就会被评估和显示,即输入
foo.bar =="baz"
将输出
假
然而,在VB.NET中,做同样的事情什么都不输出.
我必须在表达式前加一个问号才能使它工作.
?foo.bar ="baz"
假
编辑为清晰起见,上面我的坏例子:
所有其他表达式都表现出相同的行为,包括简单的数学运算,例如'1 + 2'.有时错误信息是不同的,因为1 + 2会导致错误'数字标签必须后面跟冒号'.
有没有办法'修复'这种行为并使VB.NET立即窗口的行为更像C#?不得不输入?在经常使用它时,在每个声明面前都会很痛苦.
根据Apple的ARC文档,使用ARC时开发软件的方式发生了相当大的变化.
作为Objective-C的完全初学者,开始使用ARC禁用会不会更好,因为它会让我对幕后发生的事情有更好的低级理解?或者,ARC基本上不赞成做事的"旧方式",以至于不值得花时间学习?
我找了醒目的数据绑定属性获取抛出的异常的应用程序范围内的方法(和setter方法,但是这是没有尽可能多的困难是可行的).
这些事件都不会捕获getter抛出的异常:
AppDomain.CurrentDomain.UnhandledException
Application.Current.DispatcherUnhandledException
Application.Current.Dispatcher.UnhandledException
Run Code Online (Sandbox Code Playgroud)
另一个想法是使用自定义绑定类和UpdateSourceExceptionFilter,如此线程中所述.不幸的是,这种方法只捕获属性设置器中的异常,而不是getter.
我看到的最后一个选项是使用PresentationTraceSources跟踪侦听器:
PresentationTraceSources.Refresh();
PresentationTraceSources.DataBindingSource.Listeners.Add(new PresentationLoggingTraceListener());
PresentationTraceSources.DataBindingSource.Switch.Level = SourceLevels.Error;
Run Code Online (Sandbox Code Playgroud)
这个方法似乎基本上可以做我想要的.不幸的是,它只给了我一个字符串,而不是Exception,这意味着我必须做一些解析工作才能得到实际的错误.
TraceListener方法最终可能会起作用,但它似乎有点hackish.还有其他我缺少的选项,还是我几乎坚持使用TraceListener?
在Visual Studio 2012中使用F#,此代码编译:
let ``foo.bar`` = 5
Run Code Online (Sandbox Code Playgroud)
但是这段代码没有:
type ``foo.bar`` = class end
Invalid namespace, module, type or union case name
Run Code Online (Sandbox Code Playgroud)
根据F#语言规范的第3.4节:
Any sequence of characters that is enclosed in double-backtick marks (````),
excluding newlines, tabs, and double-backtick pairs themselves, is treated
as an identifier.
token ident =
| ident-text
| `` [^ '\n' '\r' '\t']+ | [^ '\n' '\r' '\t'] ``
Run Code Online (Sandbox Code Playgroud)
第5节将类型定义为:
type :=
( type )
type -> type -- function type
type * ... * …
Run Code Online (Sandbox Code Playgroud) 我想在我的Silverlight应用程序中使用数据注释来处理验证.内置的验证属性(主要是StringLength和Required)非常棒,让生活变得非常简单.然而,他们似乎有一个严重的缺陷.例如,如果我的语言环境设置为fr-CA,则验证例外仍为英语 - "名称字段是必需的","字段名称必须是最大长度为20的字符串"等.
这是一个主要问题.这意味着如果我想要内置验证属性的本地化错误消息,我必须手动将ErrorMessage/ErrorMessageResourceType添加到业务层中每个validatable属性的每个验证属性,并为每个错误消息手动添加已翻译的字符串.
所以......我在这里错过了一些东西吗?有没有办法自动将内置验证属性本地化?还是其他一些更简单的方法呢?或者我完全没有运气,并坚持手动路线?
任何意见或想法将不胜感激.
当您创建表单或用户控件时,WinForms设计器生成一个如下所示的dispose方法:
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
Run Code Online (Sandbox Code Playgroud)
此代码的问题在于,如果编辑它以处理其他对象,则可能导致错误的行为.我见过带有dispose方法的.designer.cs文件,如下所示:
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
if (_myDisposable != null)
_myDisposable.Dispose();
if (_myOtherDisposable != null)
_myOtherDisposable.Dispose();
}
base.Dispose(disposing);
}
Run Code Online (Sandbox Code Playgroud)
...这是不正确的,因为_myDisposable和_myOtherDisposable的处理不应该取决于组件是否为空.
所以,忽略关于编辑这个设计器生成的代码是否是一个好习惯的争论,并忽略了你可以通过编辑模板来改变它的事实,我的问题是:为什么设计师不会生成看起来更像的代码这个?
protected override void Dispose(bool disposing)
{
if (disposing)
{
if(components != null)
components.Dispose();
}
base.Dispose(disposing);
}
Run Code Online (Sandbox Code Playgroud)
此代码具有相同的最终结果,但更安全且在修改期间不易出错.
我在我的Windows 7机器上使用git,推送到Server 2008机器上的共享文件夹.这在过去6个月里一直运作良好.但是,截至昨天,我再也无法推送到远程仓库了.每次我尝试,我得到以下内容:
$ git push
Counting objects: 39, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (23/23), done.
Writing objects: 100% (23/23), 8.42 KiB, done.
Total 23 (delta 15), reused 0 (delta 0)
Unpacking objects: 100% (23/23), done.
error: Couldn't set refs/heads/my-branch
To //my-server/Code/my-project.git
! [remote rejected] my-branch -> my-branch (failed to write)
error: failed to push some refs to '//my-server/Code/my-project.git
Run Code Online (Sandbox Code Playgroud)
谷歌搜索'未能推送一些参考'错误给出了关于没有先拉(我完全是最新的),没有正确的权限(我可以完全访问所有内容,并且可以创建/删除/编辑文件)的各种结果在远程仓库通过资源管理器).
然后我偶然发现了这篇博客文章http://henke.ws/post.cfm/error-failed-to-push-some-refs,其中提到您可能必须在远程存储库上运行一些清理命令.所以我在远程存储库上运行git gc:
$ git gc
Counting objects: 3960, done.
Compressing objects: 100% …
Run Code Online (Sandbox Code Playgroud)