.net-4.0

Move UIElement in Visual Tree without recalculating layout

We have a WPF application (.Net 4.0) using a Docking Control (Actipro). We can dock out the docking windows. In that case, a "real" Window is created and the content is assigned to that window. Of course, moving stuff in the Visual Tree will re-trigger the complete layouting. This is problematic, because in one of these docking windows,...

Does the NHibernate Query Analyzer work when targeting dlls that are built using .NET 4.0?

Is there a version of the NH Query Analyzer out there that can handle .NET 4.0 built dlls? ...

Problem with sorting list

I have a problem with sorting collection. User saves few values and he sorts it. At next launch program must order a new collection. Values which have been saved by user can be in new collection, but It can be situation , when those values aren't in new collection. I wrote some code, and I want your feedback If it has sense var ol...

is this a bug in .Net4? HTTP POST on XP and windows 7

using the following code in win7 and vista all is ok: WebClient client = new WebClient(); //specify an encoding for uploading. client.Encoding = System.Text.Encoding.ASCII; // Upload the data. var myReply = client.UploadValues(address, data); reply = System.Text.ASCIIEncoding.ASCII.GetString(myReply); however when running the...

Getting Dictionary<K,V> from ConcurrentDictionary<K,V> in .NET 4.0

I'm parallelizing some back-end code and trying not to break interfaces. We have several methods that return Dictionary and internally, I'm using ConcurrentDictionary to perform Parallel operations on. What's the best way to return Dictionary from these? This feels almost too simple: return myConcurrentDictionary.ToDictionary(kvp => ...

Does the following generic method already exist in the .NET 4.0 framework?

Does the following generic function exist anywhere in the .NET 4.0 framework? I would like to reuse it if it does rather than writing it myself: public static class Lambda { public static U Wrap<U>(Func<U> f) { return f(); } } It allows for the following construct (i.e., lambda expressions embedded in the select claus...

How to change target of Asp.net mvc Project in Visual Web Developer Express

I want to use DataContractJsonSerializ class inside my Asp.net MVC Application. To be able to use it I found out that Im supposed to target a different the .NET 4.0 Framework. But how can I change the target? ...

Replacing an MDB file at runtime

My application reads an Access database file that can be updated at runtime by downloading a replacement MDB file (with the same schema) and overwriting the existing file. This is all well and good during development, but it breaks during deployment. The main problem is that the connection string for the data adapters is "Provider=Mic...

c# binding to fields on a nested object

I can't seem to find a simple, concrete explanation of how to bind controls in a WinForms app to nested objects using data binding. For example: class MyObject : INotifyPropertyChanged { private string _Name; public string Name { get { return _Name; } set { _Name = value; OnPropertyChanged("Name"); } } private MyInner _Inn...

MEF metadata dictionary from object

Hi, I would like to manually create exports for composition, but the Export constructor only accepts a dictionary for metadata, while I should directly create it from the metadata object (IMyMetadata). Isn't there a way to create the dictionary from the object? Something like this: IDictionary<string, object> metadata = AttributedModel...

Is it possible to put a "Clickable Link" inside of a Systray Notification Bubble?

Not much to add to this. Have an example? ...

Why does .NET 4.0 give a "CRT not initialized" error when loading an unmanaged DLL?

I have a DLL supplied by a 3rd party along with an accompanying .NET 2.0 assembly that wraps it. If I create a .NET 3.5 project with VS2008 I am able to call into the DLL via the wrapper assembly and it works OK. However, if I create an equivalent .NET 4.0 project with VS2010 then I get a R6030 - CRT not initialized error in a message bo...

Porting a security sandbox from .NET 2.0 to .NET 4.0

I have working .NET 2.0 addin that takes an AppDomain created by an external application and applies user-defined security policy (PolicyLevel) by using AppDomain.SetAppDomainPolicy() method. However, this method is obsolete in .NET 4.0 and fails at runtime. Here is a sample code:   AppDomain domain = ExternalApplication.GetAppDomain...

Crystal Reports .Net 4 Beta 2 Production Exception

Hey guys, I have an application that generates some pretty basic reports. I have installed the crystal reports .net 4 beta 2 for visual studio 2010 and copied the DLLs into my web site's bin folder. Everything works fine when running locally but when I try to create a report on my production server I get the following exception thrown. ...

ASP.NET <%= %> vs <%: %>

It seems I am missing something. But ever since .Net 4.0 came out I have been seeing reference to <%: %> syntax for ASP.NET. It seems like it is similar to <%= %> but clearly there is a reason for the new syntax. I tried google but searching <%: %> doesn't seem to return anything. What does the <%: %> syntax do? Was it introduced i...

What's new in Linq to SQL in .NET 4.0

Does anyone know if there is anything new in LINQ to SQL in the 4.0 Framework? I know they said LINQ to SQL was not going to be supported anymore in favor of pushing the Entity Framework, but maybe they added new features or fixed some bugs. ...

Run NUnit 2.5.5 tests from within Visual Studio 2010 Ultimate and using .NET 4.0 code?

How can I do it? All the test runners seem to work for VS2008 but not 2010 and if they do, not for .NET 4. Thanks ...

Microsoft.WebApplication.targets was not found, on the build server. What's your solution?

Trying to build my project on the build server gives me the following error: Microsoft (R) Build Engine Version 4.0.30319.1 error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\TeamData\Microsoft.Data.Schema.SqlTasks.targets" was not found. Confirm that the path in the <Import> declaration is ...

Can a class property/field be of anonymous type in C# 4.0?

As in: public class MyClass { private static var MyProp = new {item1 = "a", item2 = "b"}; } Note: The above doesn't compile nor work (the var cannot be used there), it's only to show my point. Update: Just to clarify the question, I had already tried using private static dynamic MyProp = new {item1 = "a", item2 = "b"}; and thi...

how to use ICLRStrongName in .NET 4?

Related to my previous posts I'm moving to .NET 4. I've found that using the previous StrongName.h to get my assembly signing key in unmanaged code is now deprecated, and I need to use MetaHost.h and ICLRStrongName::StrongNameTokenFromAssembly. The previous StrongNameTokenFromAssembly(..) was very straight forward, now this new one has ...