刚刚下载了VS2019并创建了一个控制台应用程序以尝试新的C#8空引用类型。将项目切换为使用lang ver C#8进行构建(当前显示为beta)
然后,以下代码将产生警告。
class Program
{
static void Main(string[] args)
{
string? message = "Hello World";
string message2 = null;
Console.WriteLine(message);
Console.WriteLine(message2);
// The annotation for nullable reference types should only be used in code within a '#nullable' context
}
}
Run Code Online (Sandbox Code Playgroud)
这到底是什么意思?
当我在LINQ中使用sum函数时出现此错误:
转换为值类型'Decimal'失败,因为具体化值为null.结果类型的泛型参数或查询必须使用可空类型.
GroupProduct.Where(a => a.Product.ProductID==1).Sum(Content => Content.Amount==null?0:Content.Amount),
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用mc.exe为我的事件日志编写程序创建消息文件.但即使是Microsoft提供的示例消息文件也无法编译.谁知道如何编写可以由mc.exe编译的消息文件?
编辑:我得到的错误信息是:
msgs.mc(1) : error : expected keyword
- ??
Run Code Online (Sandbox Code Playgroud)
编辑2:问题解决了.mc.exe只能支持Unicode或ANSI编码的源文件.我的文件编码为UTF8.而已.
谢谢.
person.Name = "Joe Bloggs"通过使用表达式树动态创建方法来执行简单的属性赋值以下代码失败了NullReferenceException- 就像person我创建的参数没有被传入一样.
有任何想法吗?
class Person
{
public string Name { get; set; }
}
static void ExpressionTest()
{
var personParam = Expression.Parameter(typeof(Person), "person");
var block = Expression.Block(new[] { personParam },
Expression.Assign(
Expression.Property(personParam, "Name"), Expression.Constant("Joe Bloggs"))
);
/*
* block.DebugView in debugger shows:
*
* .Block(MyProject.MyNamepace.Person $person) {
* $person.Name = "Joe Bloggs"
* }
*
*/
var method = Expression.Lambda<Action<Person>>(block, personParam).Compile();
var person = new Person();
method(person); // **throws** System.NullReferenceException: ... at …Run Code Online (Sandbox Code Playgroud) 我经常使用Visual Studio F12 来反编译源功能。当我针对.NET Core项目中的框架类执行此操作时,我经常最终查看某种没有实现代码的参考程序集,只有存根,例如
有没有办法让它直接转到实际的实现代码?
我已将我的svn客户端和repo升级到V 1.7,现在cc.net生成的更新源代码的命令不再有效.
失败的命令是:
C:\Program Files (x86)\CollabNet\Subversion Client\svn.exe log
svn://localhost/ev_ac/trunk -r "{2011-10-21T09:18:06Z}:{2011-10-21T09:46:56Z}"
--verbose --xml --username ***** --password ******** --no-auth-cache --non-interactive
Run Code Online (Sandbox Code Playgroud)
当我在命令行手动运行时,我收到一条错误消息:
无法在libsvn_diff-1.dll中找到过程入口点svn_diff_mem_string_output_unified2
还有其他人有这个问题吗?这是svn客户端的问题还是生成的cc.net命令不再与当前的svn客户端兼容?
任何有关此问题的帮助或亮点都会很棒,因为这意味着我们的CI /构建服务器无法构建和部署.
理想情况下,.deployment当我的代码被推送到scm Kudu站点时,我想在我的应用程序中声明代码或文件,以便安装或更新特定的Site Extensions.这可能吗?
具体来说,我希望将Microsoft.ApplicationInsights.AzureWebSites站点扩展作为我部署的所有站点的一部分自动安装,而无需手动浏览到scm站点并从库中安装它.