.net-4.0

Can a C# program read a text file into memory and then pass that object to a method that requires a filename?

痴心易碎 提交于 2019-12-06 14:21:37
In a C# program I am importing a large text file (300mb) into a MySQL database via the MySqlBulkLoader function of the MySql .Net Connector. The import takes quite a long time and results in almost 100% disk usage on the Windows 2003 Server it is running on. In an attempt to speed up the import the program nows splits the big file into smaller chunks. Would it be possible to read the small file chunk (8mb) into memory (ie array) and then pass it to the MySQLBulkLoader as a file? The bulk loader looks for a filename path: MySql.Data.MySqlClient.MySqlBulkLoader myBulk = new MySql.Data

Make Parallel.ForEach wait to get work until a slot opens

北战南征 提交于 2019-12-06 14:06:23
I'm using Parallel.ForEach to work a bunch of items. The problem is, I want to prioritize which items get worked depending on the number of workers (slots) that are open. E.g. if I am working 8 parallel things and a slot opens between task 1-4, I want to assign easy work to those slots. The bottom half of the slots will get the hard work. This way, I won't get all 8 slots tied up doing hard/long-running work, easy/quick items will be run first. I've implemented this as follows: The Code const int workers = 8; List<Thing> thingsToDo = ...; //Get the things that need to be done. Thing[]

CS0012: The type 'System.Xml.IXmlLineInfo'

我的梦境 提交于 2019-12-06 13:55:38
问题 I have an .aspx page (using MVC 2) When i'm trying to make an actionlink i get an error (you can see below). This code worked already, but since i updated my project (it's a silverlight project) to .net 4.0 it gives me that error.. Error: CS0012: The type 'System.Xml.IXmlLineInfo' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Xml, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'. Code: <ul> <% foreach (var item in dossier

Replace relative urls to absolute

安稳与你 提交于 2019-12-06 13:45:59
问题 I have the html source of a page in a form of string with me: <html> <head> <link rel="stylesheet" type="text/css" href="/css/all.css" /> </head> <body> <a href="/test.aspx">Test</a> <a href="http://mysite.com">Test</a> <img src="/images/test.jpg"/> <img src="http://mysite.com/images/test.jpg"/> </body> </html> I want to convert all the relative paths to absolute. I want the output be: <html> <head> <link rel="stylesheet" type="text/css" href="http://mysite.com/css/all.css" /> </head> <body>

C# - .NET 4.0 - That Assembly does not allow partially trusted callers

我的梦境 提交于 2019-12-06 13:32:23
问题 When running from a network share, my application throws the following exception: That assembly does not allow partially trusted callers. My application references two DLL files: BitFactory.Logging.dll FileHelpers.dll I'm not sure which one it is having problems with. AllowPartiallyTrustedCallersAttribute : Read up on it, but I do not have the source for either of the DLL files, so I'm not able to add the attribute to those DLL files. CASPOL.EXE : added my network share using a few variations

Reading .NET 4.0 dump files in WinDBG

限于喜欢 提交于 2019-12-06 13:24:56
问题 I'm familiar with the WinDBG paradigm. Been reviewing a lot of dump files using WinDBG x64 version. For the most part dump files were .NET 2.0 applications and psscor2.dll. Current WinDBG version I am using is 6.12.0002.633. Recently, I've been trying to open x64 dump IIS dump files generated from a .NET 4.0 application pool using psscor4.dll. Any command I run returns, "Failed to request information" I've mscordacwks.dll from c:\Windows\Microsoft.NET\Framework64\v4.0.30319 on the server

How to make reading this instance primitive thread-safe without locking?

女生的网名这么多〃 提交于 2019-12-06 13:18:40
The problem with the below class is when reading myThreadSafe.Value it may not return the most up-to-date value. public class ThreadSafe { private int value; public int Value { get { return value; } } public void Update() { Interlocked.Add(ref value, 47); // UPDATE: use interlocked to not distract from the question being asked. } } I realise I could lock when reading it and writing it: public int Value { get { lock(locker) return value; } } public void Update() { lock(locker) { value += 47; } } And I have followed this pattern of using locks always. However I am trying to reduce the number of

How big is the risk when testing a .net 3.5 Assembly using a .net 4.0 test assembly

时光毁灭记忆、已成空白 提交于 2019-12-06 13:17:35
I realise that Visual Studio 2010 sp1 allows test projects to target 3.5 now. However, for various reasons I don't fully appreciate, our test projects still target dot net 4.0. The general question is in the title. How big is the risk? Specifically, this presumably means that the tests will run in the CLR v4, whereas many of our clients will be using CLR v2. Also, the tests seem to use v4 of library components (such as System.Data), even though the application is built against v2. One method (System.Data.SqlClient.SqlBulkCopy) contains a bug in v2 which has been fixed in v4. Our testing missed

Is it Possible to Query Multiple Databases with WCF Data Services?

ぐ巨炮叔叔 提交于 2019-12-06 12:52:14
I have data being inserted into multiple databases with the same schema. The multiple databases exist for performance reasons. I need to create a WCF service that a client can use to query the databases. However from the client's point of view, there is only 1 database. By this I mean when a client performs a query, it should query all databases and return the combined results. I also need to provide the flexibility for the client to define its own queries. Therefore I am looking into WCF Data Services, which provides the very nice functionality for client specified queries. So far, it seems

Have multiple calls wait on the same internal async task

好久不见. 提交于 2019-12-06 12:17:05
(Note: this is an over-simplified scenario to demonstrate my coding issue.) I have the following class interface: public class CustomerService { Task<IEnumerable<Customer>> FindCustomersInArea(String areaName); Task<Customer> GetCustomerByName(String name); : } This is the client-side of a RESTful API which loads a list of Customer objects from the server then exposes methods that allows client code to consume and work against that list. Both of these methods work against the internal list of Customers retrieved from the server as follows: private Task<IEnumerable<Customer>> LoadCustomersAsync