.net-4.0

How come you cannot catch Code Contract exceptions?

家住魔仙堡 提交于 2019-12-28 08:11:52
问题 System.Diagnostics.Contracts.ContractException is not accessible in my test project. Note this code is purely myself messing around with my shiney new copy of Visual Studio, but I'd like to know what I'm doing wrong. I'm using the professional edition of VS, therefore I do not have static checking. In order to still use code contracts (which I like) I figured the only way my method can work is to catch the exception that is thrown at runtime, but I'm not finding this possible. TestMethod

Does Entity Framework 6 support .NET 4.0?

主宰稳场 提交于 2019-12-28 05:56:08
问题 I believe Entity Framework 6 is intended for .NET 4.5. I'm wanting to use it for a Visual Studio 2010 project, so .NET 4.5 isn't available. Does it support .NET 4.0 and hence Visual Studio 2010? 回答1: Entity Framework 6 does support .NET 4.0. You should update your version of NuGet then try again. You can find the download at http://www.nuget.org/. I successfully downloaded EntityFramework 6.0.0-rc1 from the main nuget.org feed from an application targeting .NET 4.0 回答2: Entity Framework

Very High Memory Usage in .NET 4.0

喜你入骨 提交于 2019-12-28 05:02:32
问题 I have a C# Windows Service that I recently moved from .NET 3.5 to .NET 4.0. No other code changes were made. When running on 3.5, memory utilzation for a given work load was roughly 1.5 GB of memory and throughput was 20 X per second. (The X doesn't matter in the context of this question.) The exact same service running on 4.0 uses between 3GB and 5GB+ of memory, and gets less than 4 X per second. In fact, the service will typically end up stalling out as memory usage continue to climb until

How to check if a byte array is a valid image?

和自甴很熟 提交于 2019-12-28 04:01:10
问题 I know there is no .Net function that exists for checking, but is there an algorithm or easy and effective way of checking if a byte is a valid image before I use the byte array. I need this because I'm sending different commands to a server who is constantly listening to the client and one of the commands is to get the screenshot of the server's computer. 回答1: You can try to generate an image from the byte array and check for the ArgumentException if its not. public static bool IsValidImage

.NET 4.0 build server reference assemblies warnings MSB3644

断了今生、忘了曾经 提交于 2019-12-28 03:45:09
问题 I'm getting a bunch of errors on my build server: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(847,9): warning MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.0" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC)

Using multiple instances of MemoryCache

梦想的初衷 提交于 2019-12-28 03:33:05
问题 I'd like to add caching capabilities to my application using the System.Runtime.Caching namespace, and would probably want to use caching in several places and in different contexts. To do so, I want to use several MemoryCache instances. However, I see here that using more than one instance of MemoryCache is discouraged: MemoryCache is not a singleton, but you should create only a few or potentially only one MemoryCache instance and code that caches items should use those instances. How would

How to reference .NET 4.0 assembly within .NET 3.5 projects

為{幸葍}努か 提交于 2019-12-28 03:04:26
问题 I would like to do some Office Interop stuff using .NET 4.0, but developing the rest of my project using VS2008 and .NET3.5. How can I now use the functionality from the .NET 4.0 assembly within my other solution. Loading CLR 4.0 assemblies into a 2.0 AppDomain won't work, will it? 回答1: In short: you can't. .NET 4.0 is a totally new CLR (4.0) and as far as I know, cannot be intermixed with .NET 3.5 and/or used from VS 2008, sorry. You could use .NET 2.0 assemblies from your .NET 4.0 code, if

How do I restart a WPF application?

老子叫甜甜 提交于 2019-12-27 11:39:29
问题 How can I restart a WPF Application? In windows Forms I used System.Windows.Forms.Application.Restart(); How to do it in WPF? 回答1: I found this: It works. But. Is there any better way? System.Diagnostics.Process.Start(Application.ResourceAssembly.Location); Application.Current.Shutdown(); 回答2: I've used this in WPF, successfully: System.Windows.Forms.Application.Restart(); System.Windows.Application.Current.Shutdown(); 回答3: Application.Restart(); or System.Diagnostics.Process.Start

why .net framework conflicts with its own generated file

青春壹個敷衍的年華 提交于 2019-12-26 23:12:45
问题 I face with an error many times I need some guide to solve it for ever: Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS0433: The type 'ASP.controls_sites_linkbox_ascx' exists in both 'd:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\marja\8d9a6443\9cb45dad\App_Web_1hpsmwqz.dll' and

why .net framework conflicts with its own generated file

£可爱£侵袭症+ 提交于 2019-12-26 23:12:17
问题 I face with an error many times I need some guide to solve it for ever: Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS0433: The type 'ASP.controls_sites_linkbox_ascx' exists in both 'd:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\marja\8d9a6443\9cb45dad\App_Web_1hpsmwqz.dll' and