Questions tagged [.net-4.5]
Version 4.5 of the Microsoft .NET Framework. Use for questions specifically related to .NET Framework 4.5. For questions on .NET Framework generally, use the .net tag.
                                	
	.net-4.5
    
                            
                        
                    
            3,925
            questions
        
        
            22
            votes
        
        
            5
            answers
        
        
            12k
            views
        
    What does the portable class library actually solve?
                I was wondering, what does the PCL actually solve? If all it does is limit me to what types are cross-platform, then why didn't Microsoft just make this as a feature in a standard .NET library through ...
            
        
       
    
            22
            votes
        
        
            2
            answers
        
        
            5k
            views
        
    Target 4.5.1 and Any CPU runs as 32 bit on x64, 4.5 runs as 64 bit, Why?
                Visual Studio target 4.5.1 and Any CPU runs as 32 bit on x64, but when targeting 4.5 and Any CPU it will run as 64 bit on x64 system. What has changed in 4.5.1 to make it run in WOW mode?
Hope this ...
            
        
       
    
            22
            votes
        
        
            3
            answers
        
        
            18k
            views
        
    Reference could not be added because of same name
                Since the update to VS 2013 I have the behaviour that I cannot add a reference to 2 projects with the same name. I did the following:
Added 3 solution folders A, B and C.
Added a project of type ...
            
        
       
    
            22
            votes
        
        
            1
            answer
        
        
            28k
            views
        
    How do I timeout Regex operations to prevent hanging in .NET 4.5?
                There are times when being able to limit the pattern matching duration of regex operations could be useful. In particular, when working with user supplied patterns to match data, the pattern might ...
            
        
       
    
            22
            votes
        
        
            2
            answers
        
        
            29k
            views
        
    Set HTTP protocol version in HttpClient
                I need to make a request to a webservice that uses HTTP version 1.0. Im using HttpClient , But I cant see any option to set HTTP version.
Where can i set the request version?
            
        
       
    
            22
            votes
        
        
            1
            answer
        
        
            28k
            views
        
    Error - could not find al.exe using sdkToolsPath [duplicate]
                I migrated a Visual Studio 2012 solution to Visual Studio 2015. I'm working on Windows 10. The target .NET Framework of my solution is 4.5. I want to continue using that version. So I thought I have ...
            
        
       
    
            22
            votes
        
        
            2
            answers
        
        
            32k
            views
        
    Using async / await with DataReader ? ( without middle buffers!)
                My goal is simple , I want to do Asynchronous I/O calls (using async await)  - but : 
Without using DataFlow dependency ( like in this answer)
Without middle buffers( not like this answer)
The ...
            
        
       
    
            21
            votes
        
        
            2
            answers
        
        
            37k
            views
        
    IObserver and IObservable in C# for Observer vs Delegates, Events
                All I am trying to do is implementing the observer pattern.
So, I came up with this solution:
We have a  PoliceHeadQuarters whose primary job is to send notifications to all those who are subscribed ...
            
        
       
    
            21
            votes
        
        
            3
            answers
        
        
            16k
            views
        
    What Are Some Options To Convert Url-Encoded Form Data to JSON in .Net
                I have a web request that is sending the server data that is in the format application/x-www-form-urlencoded.  I would like to convert it to application/json.
Example:
URL-encoded form data:
...
            
        
       
    
            21
            votes
        
        
            2
            answers
        
        
            32k
            views
        
    Is System.Web.Optimization part of .Net Framework 4.5?
                I've been using Microsoft.Web.Optimization package for some time via the Visual Studio 2012 trial.  I was thinking that the Optimization Namespace would be part of .NET 4.5 as stated here.
However, I ...
            
        
       
    
            21
            votes
        
        
            8
            answers
        
        
            4k
            views
        
    .NET 4.5 RTM on Azure?
                Now that .NET 4.5 and Visual Studio 2012 has RTM, is there a way to use it on Windows Azure yet? I'm aware of the hacks people used for .NET 4.5 RC, but I'm looking for a clean solution.
If it isn't ...
            
        
       
    
            21
            votes
        
        
            6
            answers
        
        
            14k
            views
        
    Cannot have two operations in the same contract with the same name (Async & Non)
                I get the following exception (Cannot have two operations in the same contract with the same name, methods ExecuteAsync and Execute) when the following service is activated.
    [ServiceContract]
    ...
            
        
       
    
            21
            votes
        
        
            2
            answers
        
        
            12k
            views
        
    Is MVC4 baked into .NET 4.5?
                A lot of release notes for Visual Studio 2012 talk about .NET 4.5 and MVC4, but I can't tell if MVC4 is actually part of the .NET 4.5 release. Anybody know for sure? I would love not to have to ...
            
        
       
    
            21
            votes
        
        
            5
            answers
        
        
            94k
            views
        
    MVC 4 Connectionstring to SQL Server 2012
                I've created a brand new MVC 4 application in C# using Visual Studio 2012. I'm trying to connect to a brand new SQL Server 2012 (Standard) instance but I can't seem to get my connection string set ...
            
        
       
    
            20
            votes
        
        
            13
            answers
        
        
            87k
            views
        
    Failed to load viewstate. The control tree into which viewstate is being loaded
                I am receiving the following error message after an HTTP POST on an ASP.NET form hosted inside a UserControl:
  Failed to load viewstate.  The control tree into which viewstate is being loaded must ...
            
        
       
    
            20
            votes
        
        
            3
            answers
        
        
            4k
            views
        
    Mock HostingEnvironment.QueueBackgroundWorkItem in xunit test
                I have a method using 
HostingEnvironment.QueueBackgroundWorkItem which I wish to unit test some behaviour before this call, however, the test is failing with System.InvalidOperationException : ...
            
        
       
    
            20
            votes
        
        
            6
            answers
        
        
            26k
            views
        
    C#.net identify zip file
                I am currently using the SharpZip api to handle my zip file entries. It works splendid for zipping and unzipping. Though, I am having trouble identifying if a file is a zip or not. I need to know if ...
            
        
       
    
            20
            votes
        
        
            1
            answer
        
        
            58k
            views
        
    Unable to connect to localDB in VS2012 – "A network-related or instance-specific error occurred while establishing a connection to SQL Server..."
                This is strange as I'm able to connect to localDB through SSMS 2008R2 with the same connection string ("Data Source=(LocalDB)\v11.0;Integrated Security=true")
Only C# code is unable to connect, I ...
            
        
       
    
            20
            votes
        
        
            4
            answers
        
        
            32k
            views
        
    How to make WebSecurity.Login to login using username or email?
                WebSecurity.Login in simplemembership take username and password, how to make it to login the user using username or email instead of just username?, to make the user free to enter his email or ...
            
        
       
    
            20
            votes
        
        
            9
            answers
        
        
            21k
            views
        
    SignalR: $.connection is undefined
                I'm using Visual Studio 2012 Ultimate RC, SignalR 0.5.1 and Jquery 1.7.2 in an MVC4 application.
I have looked at: MVC4 SignalR "signalr/hubs" 501 Not Implemented Error
But it does not ...
            
        
       
    
            20
            votes
        
        
            4
            answers
        
        
            19k
            views
        
    Task.WaitAll not waiting for task to complete
                While trying to figure out the new (maybe not so new now, but new to me, anyway) Task asynchronous programming in C#, I ran into a problem that took me a bit to figure out, and I'm not sure why.
I ...
            
        
       
    
            20
            votes
        
        
            3
            answers
        
        
            6k
            views
        
    How to attach CancellationTokenSource to DownloadStringTaskAsync method and cancel the async call?
                I an creating a sample example to call link using WebClient using async and await method now I want to attach cancel async call functionality also. But I am not able to get  CancellationTokenSource ...
            
        
       
    
            20
            votes
        
        
            1
            answer
        
        
            11k
            views
        
    How to target .net 4.5 with CSharpCodeProvider? [duplicate]
                Possible Duplicate:
  Using CSharpCodeProvider with .net 4.5 beta  
For .net 3.5 I pass v3.5 to CSharpCodeProvider, when I pass v4.5 to CSharpCodeProvider in a v4.5 app I get ...
            
        
       
    
            20
            votes
        
        
            2
            answers
        
        
            9k
            views
        
    Simple claims transformation and caching w/ windows authentication
                For the past few days I've been reading about the windows identity foundation and how it's so good and flexible and built right into .net 4.5. Despite going over dozens of apis, blog posts, how-to's ...
            
        
       
    
            20
            votes
        
        
            4
            answers
        
        
            24k
            views
        
    Installing Visual Studio 2012 Ultimate on Windows 8
                While trying to install the Visual Studio 2012 ultimate trial on Windows 8 Release Preview I got the following error message
The .Net Framework installed on this machine does not meet the minimum
...
            
        
       
    
            20
            votes
        
        
            1
            answer
        
        
            6k
            views
        
    How to access a security critical field from an anonymous delegate or lambda?
                Scenario
Let's say we've the next code:
[SecuritySafeCritical]
public void SomeMethod()
{
    SomeCriticalClass critical = new SomeCriticalClass();
    Action someDelegate = () => 
    {
        ...
            
        
       
    
            20
            votes
        
        
            3
            answers
        
        
            10k
            views
        
    WPF WindowChrome: Edges of maximized Window are out of the screen
                I use WindowChrome to customize a Window. When I maximize the Window, then the edges are out of the screen. I use the following code to fix this:
<Window x:Class="WpfApplication1.MainWindow"
      ...
            
        
       
    
            20
            votes
        
        
            1
            answer
        
        
            10k
            views
        
    Window style with WPF Ribbon from Microsoft doesn't match Windows 8 style
                I'm using the release Version of Windows 8 and Visual Studio 2012 to create a WPF application with a Ribbon control. I choose the ribbon control that comes with WPF in .Net Framework 4.5.
My code to ...
            
        
       
    
            20
            votes
        
        
            1
            answer
        
        
            382
            views
        
    Odd debugger behavior with Interface and Generics on 64bit OS when toggling 'Prefer 32-Bit
                I have come across this odd behaviour: when my projects settings are set to Any CPU and Prefer 32-bit on a 64bit Windows 7 OS the .Net 4.5program below works as expected. If however I turn off Prefer ...
            
        
       
    
            19
            votes
        
        
            3
            answers
        
        
            38k
            views
        
    Shortest way to deserialize XmlDocument
                I am looking for a clean and short way to deserialize a XmlDocument object. The closest thing I found was this but I am really wondering if there is no nicer way to do this (in .NET 4.5 or even 4.6) ...
            
        
       
    
            19
            votes
        
        
            2
            answers
        
        
            14k
            views
        
    .NET 4.5 project not compiling in Visual Studio 2022
                I have installed Visual Studio 2022 on my PC today.  I have an old app, which targets .NET 4.5.  I see this error when attempting to build/compile the project:
"Error  MSB3644 The reference ...
            
        
       
    
            19
            votes
        
        
            3
            answers
        
        
            17k
            views
        
    Timeout.InfiniteTimespan in .Net 4.0?
                I actually do know that Timeout.InfiniteTimespan does not exist in .NET 4.0.
Noticed, there's also Timeout.Infinite which does exist in .NET 4.0
I am calling those two methods:
// the Change-Method
...
            
        
       
    
            19
            votes
        
        
            5
            answers
        
        
            14k
            views
        
    Does Entity Framework 5 support unique constraints?
                Wondering if Entity Framework 5 supports unique constraints on entity properties? If so, how can I specify that a property should be unique?
            
        
       
    
            19
            votes
        
        
            1
            answer
        
        
            8k
            views
        
    Parse enum when string is lowered
                I have a pretty fun problem, which I am not sure you can even solve using this approach.
I have some string, which is all lowercase. Let's just call it businesslaw. Now, I have an enum type, where ...
            
        
       
    
            19
            votes
        
        
            1
            answer
        
        
            12k
            views
        
    New .NET feature bundle and minification {version} wildcard doesn't work with directories?
                I have the following pice of code which runs perfectly:
bundles.Add
(
    new ScriptBundle("~/bundles/scripts")
    .Include
    (
        "~/Scripts/jquery-{version}.js"
        ,"~/Scripts/jquery-...
            
        
       
    
            19
            votes
        
        
            4
            answers
        
        
            36k
            views
        
    HttpClient: Conditionally set AcceptEncoding compression at runtime
                We are trying to implement user-determined (on a settings screen) optional gzip compression in our client which uses HttpClient, so we can log and compare performance across a number of different ...
            
        
       
    
            19
            votes
        
        
            1
            answer
        
        
            52k
            views
        
    Programmatically add control to Grid RowDefition in WPF 4.5
                I've been through this site (and many others) trying to figure out what is going on and why this does not work. I am running VS2012 and have created a WPF C# app (target .NET 4.5). I am new to WPF, ...
            
        
       
    
            19
            votes
        
        
            5
            answers
        
        
            11k
            views
        
    Visual Studio 2012 Randomly reporting: "The referenced component X could not be found"
                I recently migrated and re-tartgeted a solution from VS 2010 and .NET 4.0 to VS 2012 and .NET 4.5. However now all of a sudden and randomly VS 2012 reports almost all cross-project references as:
"...
            
        
       
    
            19
            votes
        
        
            3
            answers
        
        
            4k
            views
        
    Is LogicalOperationStack incompatible with async in .Net 4.5
                Trace.CorrelationManager.LogicalOperationStack enables having nested logical operation identifiers where the most common case is logging (NDC). Should it still work with async-await?
Here's a simple ...
            
        
       
    
            19
            votes
        
        
            1
            answer
        
        
            12k
            views
        
    Large Object Heap Compaction, when is it good?
                First off, how big is considered large? Is there anyway to determine how large an object is in heap?
.Net 4.5.1 comes with this LargeObjectHeapCompactionMode:
  After the ...
            
        
       
    
            19
            votes
        
        
            5
            answers
        
        
            344
            views
        
    Is there an elegant LINQ solution for SomeButNotAll()?
                Here is what I'm trying to do overall. Just to be clear, this isn't homework or for a contest or anything. Hopefully, I've made the wording clear enough:
Problem
Given a set of strings in the same ...
            
        
       
    
            18
            votes
        
        
            2
            answers
        
        
            36k
            views
        
    How to setup Request.Header in FakeHttpContext for Unit Testing
                I have a FakeHttpContext I have been trying to modify to include some headers for testing purposes
public static HttpContext FakeHttpContext()
{
    var httpRequest = new HttpRequest("", "http://...
            
        
       
    
            18
            votes
        
        
            4
            answers
        
        
            65k
            views
        
    The ADO.NET provider 'Oracle.ManagedDataAccess.Client' is either not registered in the machine or application config file, or could not be loaded
                I am using .NET4.5.1, MVC5, EF6, with Oracle.ManagedDataAccess 4.121.1.0 and
Oracle.ManagedDataAccess.EntityFramework 6.121.2.0
I was able to generate Model from existing database (part of it adding ...
            
        
       
    
            18
            votes
        
        
            2
            answers
        
        
            6k
            views
        
    Does ProfileOptimization actually work?
                One of the new performance enhanchements for .NET 4.5 is the introduction of the 'MultiCode JIT'. 
See here for more details.
I have tried this, but it seems to have no effect on my application.
...
            
        
       
    
            18
            votes
        
        
            1
            answer
        
        
            25k
            views
        
    Store String Array with Values in Application Settings [duplicate]
                I've modified my Settings.settings file in order to have system_Filters be a System.String[].
I would like to populate this variable within the Visual Studio designer and not from within the code. I ...
            
        
       
    
            18
            votes
        
        
            2
            answers
        
        
            8k
            views
        
    How do I print WebView content in a Windows Store App?
                I have a Metro App and I am attempting to Print the Content of a WebView control. Using the MSDN Print Sample as my source reference. I simply change the XAML in the printableArea as follows:
    <...
            
        
       
    
            18
            votes
        
        
            4
            answers
        
        
            11k
            views
        
    Run async method 8 times in parallel
                How do I turn the following into a Parallel.ForEach?
public async void getThreadContents(String[] threads)
{
    HttpClient client = new HttpClient();
    List<String> usernames = new List<...
            
        
       
    
            18
            votes
        
        
            2
            answers
        
        
            12k
            views
        
    Building .NET 4.5 Projects with Nant
                I'm curious if it's possible to use Nant to target the .NET 4.5 using the C# 5.0 compiler. As of right now, the latest version only states support for .NET 4.0.
I tried downloading the source and ...
            
        
       
    
            18
            votes
        
        
            5
            answers
        
        
            34k
            views
        
    Get Type by Name
                In my code I am trying to get a type by name. When I was using a string argument I failed. Then I have tried to do the follwing in the Quick watch window: 
Type.GetType(typeof(System.ServiceModel....
            
        
       
    
            18
            votes
        
        
            1
            answer
        
        
            12k
            views
        
    Interface implementation with optional arguments
                Take this interface:
interface ILogger
{
    void Store(string payload);
}
And this class implementation of ILogger:
class Logger : ILogger
{
    void Store(string payload, bool swallowException = ...