.net

SmtpClient Sending bad MessageIDs

I've written an automated e-mailer for my company's invoices. Things are all fine and dandy till I ran across a couple emails that weren't getting delivered. Upon further inspection our IT Guru found that the messages sent by the emailer have incorrect MessageID headers. Message-ID: <98bcd4e6-be30-4b22-8026-6047c8231b1f> Where they sh...

Ho to use the correct unmanaged dll according CPU architecure? (32 / 64bits)

I have to use a c++ dll from an asp .net site. The site will be hosted on both 32 and 64bits environments. I have a 32 and 64 bits version of the unmanaged dll. How do I import the methods from the correct one according the current server architecture? EDIT Like some one posted, this could be handled as a deployment problem. My concern...

How can I read/write app.config settings at runtime without using user settings?

I'm looking for a way to store application or machine level settings that can be written to at runtime using Application Settings. User settings allow read/write but application settings do not. I have been using user settings for saving settings like this at runtime but this has really proven to be impractical for the following reasons:...

How to manipulate .dbf files using c#?

I am trying to something like this: string pathFiles = Path.Combine(Application.StartupPath, "DB"); string strconn = "Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;" + "Dbq="+pathFiles+";"; OdbcConnection odbconn = new OdbcConnection(strconn); odbconn.Open(); ...

Expose an enumeration from a wrapped COM component

I'm writing a class library in .NET that wraps a COM dll and exposes specific functionality to be consumed by other .NET code. The COM library has several enumerations defined and I've used some of the enum types as parameters like so: //C# public void TransactionTypeSetByEnum(COMComponent.TransactionType transType) { this.Transact...

I'm wondering if somebody can help me improve my T-SQL query so that i can retrieve the SUMs of the money columns from an additional table... :)

First of all, thank you very much in advance for any attempt at helping me with this. My current query (below) works the way i want it to save the requirement mentioned in the title: I need to retrieve the SUM's of the money columns in my 'expenses' table AND each of these values must correspond to a period_ending value that is greater t...

Issue with AutoMapper and mapping IEnumerable collections

Here is the code for the mapper: public IEnumerable<GetQuestionsContract> Map(IEnumerable<XmlNode> nodes, XmlNamespaceManager namespaceManager) { Mapper.CreateMap<XmlNode, GetQuestionsContract>() .ForMember( dest => dest.Id, options => options.ResolveUsing<XmlNodeR...

SharpSSH's Scp object can't copy files bigger than 2GB

Whenever I try to copy a file that's bigger than 2GB, I get an array index out of bounds exception in the Get method: Scp myScp = new Scp("remotehost", "joe", "mypassword"); myScp.OnTransferProgress += new FileTransferEvent(scpProg); myScp.Connect(22); myScp.Get("/home/joe/bigfile.bin", "/tmp/bigfile.bin"); myScp.Close(); ...

Why does StreamReader.ReadLine throw OutOfMemoryException?

Can anyone tell me why the last line here throws OOM exception? byte[] buffer = new byte[1]; buffer[0] = 239; MemoryStream ms = new MemoryStream(buffer); StreamReader sr = new StreamReader(ms); string l1 = sr.ReadLine(); string l2 = sr.ReadLine(); ...

Possible to have multiple SAME WCF window service on same machine

Kind of like the named instanced sql server. I'd like to install the same wcf window service on the same machine so having multiple instances of it. I'd like each of them to connect to a different Databases (different environment) ...

Additional partial classes for a Form

We have a big Form class that we like to split into peaces using partial class approach That could be done by manually modifying a project file, and adding MainFormPN.vb entry <Compile Include="MainForm.vb"> <SubType>Form</SubType> </Compile> <Compile Include="MainForm.Designer.vb"> <DependentUpon>MainForm.vb</DependentUpon> ...

Improving DataTable performance

I have a DataTable populated with 250,000 records with 5 columns, I am iterating over this at least 500,000 times. The difference in performance between a table with 1000 records is massive and I can understand and appreciate why - however is there is a way to improve the performance? ...

File extension from System.Drawing.Image

I'm writing a method that needs to save a System.Drawing.Image to a file. Without knowing the original file the Image was created from, is there anyway to determine what file extension it should have? The best solution I've come up with is to use a Switch/Case statement with the value of Image.RawFormat. Does it even matter that I save...

.net, c# post to php page...

Hi, I have a website that is primarily PHP but we have built some new pages in c# .net. I need to be able to post (i think) to the PHP page. The PHP page has a login that takes the login name and password. I am trying to allow my .net page to have a login that directs to the PHP page and once there the user is already logged in. I ...

XmlSerializer and embedded WhiteSpace

I have the following xml that contains a white space Field1Value . When I deserialize that xml I lose the single space character. The value of Request.Field2 is "". Is this a bug in the xml serializer? Can anyone recommend a solution/ workaround to keep this space? ... var encoding = new System.Text.UTF8Encoding(); ...

EntityFramework - Strategies to load childs objects

I got the 2 following entity : User and Post Simple version of user : public virtual int Id { get; set; } public virtual IList<Post> Posts { get; set; } Posts aren't load by default. In certain condition, I need to load the Posts (for example, I want to count the number of posts for that user). For now, I've add a method call LoadPo...

Java MessageDigest and .NET SHA1Managed - hashes not matching

I have some .net code that generates a SHA1 hash on an xml document and need it to match a SHA1 hash generated on the same xml document in java code. The xml doc is sent to the java system and they generate a hash and match against the one i send to verify they are getting the document I intended them to. Below are the snippets in use ...

System.Diagnostics.Process in F# - how to use it?

Can someone give me a very simple example of how one would, say, write an F# program to open Notepad? I keep running into a "File Not Found" exception, but there doesn't seem to be any reason for it - the StartInfo property is correctly set. ...

Finding names to songs in .NET

I have a collection of mp3, wma's etc that may or may not have the correct song information. Is there a service or an API that I can use in .NET to find the correct song title / artist for each file? ...

.NET DLLs and threads / distinct instances

Suppose I have a .NET dll with class 'B' and function 'C'. I then have a multithreaded .NET program that references the dll. Each thread instances the class 'B' and calls the function 'C'. Upon instantiation the class 'B' allocates all of its own variables on the heap. These variables are used by the function 'C'. Does this create a...