我在Windows 8.1上安装了.NET Framework 4.5.2.但在Visual Studio 2013中,我没有看到.NET Framework 4.5.2选项(参见屏幕截图).如何定位.NET 4.5.2的项目?
如果我运行声明
Math.Exp(113.62826122038274).ToString("R")
Run Code Online (Sandbox Code Playgroud)
在安装了.net 4.5.1的机器上,然后我得到答案
2.2290860617259248E+49
Run Code Online (Sandbox Code Playgroud)
但是,如果我在安装了.net framework 4.5.2的机器上运行相同的命令,那么我得到答案
2.2290860617259246E+49
Run Code Online (Sandbox Code Playgroud)
(即最后的数字变化)
我意识到这在纯数字术语中是无关紧要的,但有没有人知道在.net 4.5.2中所做的任何可以解释变化的变化?
(我不喜欢另一个结果,我只是想了解它为什么会改变)
如果我输出
The input in roundtrip format
The input converted to a long via BitConverter.DoubleToInt64Bits
Math.Exp in roundtrip format
Math.Exp converted to a long via BitConverter.DoubleToInt64Bits
Run Code Online (Sandbox Code Playgroud)
然后在4.5.1我得到
113.62826122038274
4637696294982039780
2.2290860617259248E+49
5345351685623826106
Run Code Online (Sandbox Code Playgroud)
在4.5.2我得到:
113.62826122038274
4637696294982039780
2.2290860617259246E+49
5345351685623826105
Run Code Online (Sandbox Code Playgroud)
所以对于完全相同的输入,我得到一个不同的输出(从位可以看出,因此不涉及往返格式)
更多细节:
使用VS2015编译一次
我运行二进制文件的两台机器都是64位
一个安装了.net 4.5.1,另一个安装了4.5.2
为了清楚起见:字符串转换无关紧要......无论是否涉及字符串转换,我都会得到结果的更改.我提到这纯粹是为了证明这种变化.
我有以下对象:
public class ProjectInfo
{
public string ConnectionStringName { get; set; }
public string DefaultEntityNamespace { get; set; }
public string DefaultSharedNamespace { get; set; }
public string DefaultTestNamespace { get; set; }
public string SqlProviderName { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我尝试做一个简单的序列化(在VSIX项目中):
var settings = new ProjectInfo { ConnectionStringName = "SomeName" };
var json = JsonConvert.SerializeObject(settings);
Run Code Online (Sandbox Code Playgroud)
这给了我:
An exception of type 'System.IO.FileNotFoundException' occurred in Newtonsoft.Json.dll but was not handled in user code
Additional information: Could not load file or assembly …
Run Code Online (Sandbox Code Playgroud) c# json.net visual-studio-extensions .net-4.5.2 visual-studio-2015
我正在尝试将EF7 rc1安装到现有项目中:
PM> Install-Package EntityFramework.MicrosoftSqlServer -Pre
但是我收到以下错误:
安装失败.回滚...
项目'XYZ'中不存在包'Microsoft.Extensions.Logging 1.0.0-rc1-final'
在跟踪的最后,我得到了另一条消息:
Install-Package:无法添加对'System.Collections.Concurrent'的引用.请确保它在全局程序集缓存中.
我用google搜索并且可以看到Concurrent集合已经在dotnet中存在了一段时间,但我在开发框中没有这样的汇编.
更新:
在查询gac之后gacutil
我意识到组件确实存在:
全局程序集缓存包含以下程序集:
System.Collections.Concurrent,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a,processorArchitecture = MSIL
我尝试将我的应用程序上的目标框架最近从.NET Framework 4.5更改为4.5.2,但如果我这样做,在尝试构建时会出现以下错误:"'Forms'不是'Windows'的成员"(是,System.Windows.Forms
).更改为4.5.1正常工作.我正在使用Visual Studio 2013 Ultimate.
我有一个方法
HostingEnvironment.QueueBackgroundWorkItem
,我希望在这个调用之前对一些行为进行单元测试,但是,测试失败了System.InvalidOperationException : Operation is not valid due to the current state of the object.
我怀疑这需要模拟HostingEnvironment但不知道如何.
我发现一个针对4.5的应用程序可以加载并运行一个针对4.5.2的程序集 - 但我无法编译这样的设置!
问题:如何编译.NET 4.5应用程序并引用.NET 4.5.2程序集?
实验细节:
在Visual Studio或MSBuild中进行编译失败:
警告MSB3274:无法解析主要引用"(...)\ MyLib.dll",因为它是针对".NETFramework,Version = v4.5.2"框架构建的.这是比当前目标框架".NETFramework,Version = v4.5"更高的版本.
错误CS0246:找不到类型或命名空间名称"MyLib"(您是否缺少using指令或程序集引用?)
我试图单独编译MyLib并引用它的DLL,但得到了相同的编译错误.
但是,我设法让两者都运行:
背景:我正在准备将我们的大型NuGet管理的多项目从.NET 4.5过渡到4.5.2.该公告称It is a highly compatible, in-place update to the .NET Framework 4, 4.5 and 4.5.1
,所以,我想,如果我们升级我们的一些(的NuGet管理)裁判对4.5.2会发生什么,未升级的项目,试图使用它们.
我下载了.NET 4.5.2开发人员包,并且一直在努力将其安装在一台特定的64位Windows 7计算机上,这样我就可以在成功安装的Visual Studio 2013中使用它.(在我安装框架的所有其他机器上工作得很好)
它在第一个提取阶段结束时失败并显示"遇到错误.未指定错误"并立即删除它刚提取的所有文件.我一直在寻找错误日志或任何导致问题的迹象 - 无法对任何事情进行细微处理.
关于如何安装它的任何想法?
我们获得了一个Windows窗体应用程序,它是从Microsoft Visual Studio的模板(PasteBin 1 2 3 4上的设计器代码)创建的,带有默认的ListBox exampleListBox
和Button exampleButton
.
我们使用1到10之间的数字填充ListBox.
for (int i = 0; i < 10; ++i)
{
exampleListBox.Items.Add(i);
}
Run Code Online (Sandbox Code Playgroud)
然后我们添加两个事件处理程序.
exampleListBox_SelectedIndexChanged
将只是向控制台写入当前选定的索引.
private void exampleListBox_SelectedIndexChanged(object sender, EventArgs e)
{
Console.WriteLine(exampleListBox.SelectedIndex);
}
Run Code Online (Sandbox Code Playgroud)
exampleButton_Click
将当前所选索引的项目设置为自身.如此有效,这应该绝对没有改变.
private void exampleButton_Click(object sender, EventArgs e)
{
exampleListBox.Items[exampleListBox.SelectedIndex] = exampleListBox.Items[exampleListBox.SelectedIndex];
}
Run Code Online (Sandbox Code Playgroud)
单击按钮时,我预计不会发生任何事情.然而,这种情况并非如此.exampleListBox_SelectedIndexChanged
即使SelectedIndex
没有更改,单击该按钮也会触发事件.
例如,如果我单击索引2中的项目exampleListBox
,那么exampleListBox.SelectedIndex
将变为2.如果我按exampleButton
,则exampleListBox.SelectedIndex
仍然是2.然而,exampleListBox_SelectedIndexChanged
事件触发.
为什么即使所选索引未更改,事件也会触发?
此外,还有什么可以防止这种行为发生?