.net-4.0

How can I upgrade multiple projects (same solution) that's targeting 3.5 to 4.0 in one go?

时间秒杀一切 提交于 2019-12-05 03:52:49
In one big solution we have about 100~ projects all targeting 3.5 and currently in VS.NET 2010. Now we want to upgrade it to .NET 4.0, do I have to go one by one and change their target? or is there any way to automate this process? When upgrading many projects and similar operation I usually use Find and replace in files. First I upgrade one project and diff the result, then I search and replace relevant parts in my .csproj files. The Target Framework Migrator extension works great. After you install it simply go to Tools -> Target Framework Migrator Yes. You will have to change them each to

WrapPanel: Trying to make the ItemWidth equal to the max width of any one element

≯℡__Kan透↙ 提交于 2019-12-05 03:37:59
Hopefully no one else has already asked this question, but I have searched and cannot find any mention. Feel free to point me in the right direction if I missed another question that explains this. I have a WrapPanel with data-bound items that essentially contain an icon and some variable length text (this is a legend for a chart). I really like the fact that the items appear in neat columns when I set the ItemWidth to some set value. However, due to the high variability in length of the text in each item, I cannot easily choose a specific value that will work for all cases. That is, in some

How to exclude specific types from serialization?

我只是一个虾纸丫 提交于 2019-12-05 03:29:17
I run sgen against my assembly with a metric ton of types. I want to exclude 2 types from serialization. I don't seem to be able to find a way to do it. I see that sgen has a /type switch to specify a specific type, but nothing to exclude a specific type. Is there a way to exclude specific types from serialization? Apart from putting the types you wish to exclude in a different assembly, you cannot exclude types from the serializer generation. Update Other posters have come up with additional possibilities to exclude specific types, with varying applicability based on your use case. You can

Cleanly interrupt HttpListener's BeginGetContext method

烈酒焚心 提交于 2019-12-05 03:29:15
I am using a HttpListener and using BeginGetContext to get my context object. I want to cleanly shut down my HttpListener but if I attempt to do a Close on the listener I get a exception and it causes my program to exit. using System; using System.Net; namespace Sandbox_Console { class Program { public static void Main() { if (!HttpListener.IsSupported) { Console.WriteLine("Windows XP SP2 or Server 2003 is required to use the HttpListener class."); return; } // Create a listener. HttpListener listener = new HttpListener(); listener.Prefixes.Add("http://vwdev.vw.local:8081/BitsTest/"); listener

IIS 7.0 / Windows Server 2008 - DLL not found in ASP.NET application

你离开我真会死。 提交于 2019-12-05 03:21:19
问题 I try to run an ASPX page hosted on a Windows Server 2008 x86 through IIS 7.0, with .NET 4.0. I added an application, app1 , to the Default Web Site of IIS, mapped to dir C:\toto\app1 which contains the Web.config file. The error I have is: Could not load file or assembly 'xxx.dll' or one of its dependencies , etc and xxx.dll is a .NET DLL that wraps native C++ DLLs ( they are the dependencies that fail to be loaded), all of them are located in C:\toto\app1\bin . I tried to modify the PATH

Issue with x:TypeArguments and generic List class in XAML

守給你的承諾、 提交于 2019-12-05 03:05:32
I created the following markup for a loose XAML file. <StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib"> <scg:List x:TypeArguments="sys:String"> HelloWorld </scg:List> </StackPanel> But I get this error when I run the loose XAML in IE: The tag 'List' does not exist in XML namespace 'clr-namespace:System.Collections.Generic;assembly=mscorlib'. Line '7' Position 2'. As you would know, generics

How do I test for typeof(dynamic)?

被刻印的时光 ゝ 提交于 2019-12-05 03:02:43
I've got a generic method TResult Foo<TSource, TResult>(IEnumerable<TSource> source) and if TResult is declared as dynamic I want to execute a different code path than for other type declarations. For regular types you can do stuff like: if (typeof(TResult) == typeof(int)) return ExpressionFactory.CreateExpandoFunction<TSource, TResult>(); But if (typeof(TResult) == typeof(dynamic)) does not compile. Is there anyway to make this sort of determination at runtime when the method is called with the declaration: dyanmic x = Foo<int, dynamic>(list); Since dynamic itself isn't a type what should I

URL Encoding in c# and Asp.net web api

北慕城南 提交于 2019-12-05 02:56:50
问题 I have an ASP.NET web api that receives web requests and returns Json data. browsing to this URL: http://1.2.3.4/api1/api/values/mypartname will return the following json string: { \"PartName\": \"mypartname\", \"PartDes\": \"53.6X53.6APA/ALIM1NOTPAK\", \"PartLocation\": \"A36\" } but when sending a part name that contains spaces or quotes like this: http://1.2.3.4/api1/api/values/my part na"me i get a 404 - File or directory not found. error. I'm consuming the json with a .NET 4 Console

Is there any function or tool (free) to auto complete any .Net type name to fully qualified one?

廉价感情. 提交于 2019-12-05 02:55:52
问题 I'm using VB.NET with Visual Studio 2010. Is there any function or tool to auto complete any .Net type name to fully qualified one? I mean a tool/function that actually changing the source code from short hand to fully qualified name like following: From String to System.String From Process.Start to this System.Diagnostics.Process.Start UPDATE: Thanks for ReSharper suggestion. But I'm not prepared to buy it or award bounty for a commercial product suggestion. Sorry about that . I should make

The '?' character cannot be used here

无人久伴 提交于 2019-12-05 02:37:22
With these variables: Dim d1 As Date? = Nothing Dim d2 As DateTime? = Nothing Dim i1 As Integer? = Nothing Dim i2 As Int32? = Nothing Why am I allowed to do this?: Dim flag1 As Boolean = Date?.Equals(d1, d2) Dim flag2 As Boolean = Integer?.Equals(i1, i2) ...but not allowed to do this?: Dim flag3 As Boolean = DateTime?.Equals(d2, d1) Dim flag4 As Boolean = Int32?.Equals(i2, i1) The last code will fail with an error saying: The '?' character cannot be used here. VB.NET developers are not supposed to be using C# keywords (religion, you know). Seriously though, I agree with @Konrad this looks like