.net-4.0

What is point of SSL if fiddler 2 can decrypt all calls over HTTPS?

不羁岁月 提交于 2019-12-17 03:36:03
问题 I asked a question here a while back on how to hide my http request calls and make them more secure in my application. I did not want people to use fiddler 2 to see the call and set up an auto responder. Everyone told me to go SSL and calls will be hidden and information kept safe. I bought and installed an SSL Certificate and got everything set up. I booted up fiddler 2 and ran a test application that connect to an https web service as well as connected to an https php script. Fiddler 2 was

Working example of CreateJobObject/SetInformationJobObject pinvoke in .net?

蹲街弑〆低调 提交于 2019-12-17 02:31:27
问题 I'm struggling to put together a working example of pinvoke'ing CreateJobObject and SetInformationJobObject. Through various google searches (including Russian and Chinese posts!) I've cobbled together the following code. I think the definition of JOBOBJECT_BASIC_LIMIT_INFORMATION changes based on platform (32/64-bit). The CreateJobObject/AssignProcessToJobObject seems to work. SetInformationJobObject fails - either with error 24 or 87. Process myProcess // POPULATED SOMEWHERE ELSE // Create

How to set Json.Net as the default serializer for WCF REST service

余生颓废 提交于 2019-12-17 02:13:04
问题 Is it possible to override the default WCF DataContractSerializer behaviour when Serialize/DeSerialize entities and use JSON.NET instead? I have the following service contract for handling the City entity. For design reasons the City entity has IsReference=true, and therefore the default DataContractSerializer raise errors. For the "GET" methods I can handle the situation with JsonConvert.DeserializeObject, but with "PUT,POST,DELETE" methods DataContractSerializer takes precedence and fails

Casting a result to float in method returning float changes result

試著忘記壹切 提交于 2019-12-17 02:11:37
问题 Why does this code print False in .NET 4? It seems some unexpected behavior is being caused by the explicit cast. I'd like an answer beyond "floating point is inaccurate" or "don't do that". float a(float x, float y) { return ( x * y ); } float b(float x, float y) { return (float)( x * y ); } void Main() { Console.WriteLine( a( 10f, 1f/10f ) == b( 10f, 1f/10f ) ); } PS: This code came from a unit test, not release code. The code was written this way deliberately. I suspected it would fail

Using async-await on .net 4

梦想的初衷 提交于 2019-12-16 20:12:14
问题 I'm currently starting to create an application that would profit a lot from C# 5's async-await feature. But I'm not sure which version of VS and of the async runtime to use. Looking at OS popularity charts, I'll need to support Windows XP for another three years or so. It looks like .net 4.5 runs only on newer versions of Windows, so I need to target .net 4.0. The development machines use Windows 7, so using a newer version of VS is not a problem. Now I need to first choose a compiler for

Getting around base64 encoding with WCF

纵然是瞬间 提交于 2019-12-14 03:58:31
问题 I'm using WCF, REST and "pretty URI's" as shown in this blog post with the Online Template for VS 2010 .NET 4.0: http://christopherdeweese.com/blog2/post/drop-the-soap-wcf-rest-and-pretty-uris-in-net-4 I have one problem though. I want to return a a raw byte[] array but it automatically gets base64 encoded. Unfortunately for my program base64 encoding is not acceptable because it will be too computationally intensive. Is there a way for me to tell WCF NOT to base64 encode? [WebGet(UriTemplate

ObjectDisposedExecption after closing a .NET SerialPort

我们两清 提交于 2019-12-14 03:40:06
问题 I am using a .NET 4 SerialPort object to talk to a device attached to COM1. When I am done with the device, I call Close on the SerialPort. I do not call Dispose, but I believe that Close and Dispose are synonymous here. Usually this works just fine. Sometimes, however, I get the following exception some time later (The times I've seen range from 5 ms to 175 ms): System.ObjectDisposedException: Safe handle has been closed at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean&

Stange Behavior of the Serial Port Input Buffer

二次信任 提交于 2019-12-14 03:14:10
问题 Using a virtual serial port w/usbser.sys as driver; I get some strange behavior of the buffers. I use Win32 calls (CreateFile, ReadFile, etc) rather than the SerialPort class in .NET for performance reasons. After opening the COM port, I use SetupComm(hFile, dwInQueue, dwOutQueue) to set the input buffer to 32768. I've tried with other sizes, eg. 4096, 8192, etc. Then I read the buffer size back with GetCommProperties(hFile, lpCommProp) and read the COMMPROP.dwCurrentRxQueue to check if the

Name resolution in connection string fails from network share

让人想犯罪 __ 提交于 2019-12-14 03:10:02
问题 I need to go sit together with the network infrastructure guys to see why suddenly SQL connection errors like below occur. As a preparation, please provide input why this error can occur, and which things we could try at the application and/or infrastructure side to circumvent it. The error occurs when starting an application from a network share. The error does not occur when copying the files locally and starting it locally. The error is always reproducible. A couple of weeks ago (before I

Using async BCL with async function

点点圈 提交于 2019-12-14 03:05:10
问题 I've flagged this as .NET 4, as I am using the async BCL. I have the following code: using System.Threading.Tasks; public static async Task<ObservableCollection<MyResult>> GetMyData(Params p) { DoStuffClass stuff = new DoStuffClass(); ObservableCollection<MyResults> results = null; await Task.Factory.StartNew(() => { results = stuff.LongDrawnOutProcess(p); }); return results; } Which I have refactored from a previous version that looked something like this: static void GetMyDataAsync(Params p