.net

.Net CCW no events with registration-free COM!

I have a COM Callable Wrapper that I'm using from a VB6 program, but the program won't receive COM events unless the CCW is registered. Otherwise, the CCW works fine, just no events until I remove the program's manifest file and register the CCW using "regasm /tlb /codebase theccw.dll". This is in WinXP SP3. What could be the problem? ...

IoC/DI Container that supports Compact Framework

Hi, Is their any IoC controllers available that will work on .NET Compact Framework? ...

How do I get the widths of the borders drawn by ControlPaint?

I'm drawing a border with System.Windows.ControlPaint.DrawBorder3D, and want to draw into the rectangle inside the border. How do I get the width of the border, so that I can find the rectangle inside it? UPDATE: With the default theme, the borders are 2px top and left, but only 1px bottom and right, so SystemInformation.Border3DSize i...

Manually generate ActiveX wrapper after TLBIMP-ed dlls?

I have several ActiveX components that needed to be accessed from a C# project. I can import them via Visual Studio's add reference dialog, which will also automatically generate wrappers class. (i.e. ABCLib and AxABCLib) I know that I can generate the primary interop assembly manually by running TLBIMP /primary on each individual OCX ...

Default button hit in windows forms (trying to find the best solution)

The question is: How to make default button be focused on form focus and response on "Enter" hit, but not focused when the caret is in textbox with multiline property set to true for example?..I know that i can do some exceptions in code, but maybe there is some "best practices" i dont know for now :( thank you ...

Can I avoid JIT in .net

Say if my code is always going to be run on a particular processor and if I have this information during installation - is there any chance I can avoid JIT? ...

Binding IDataErrorInfo to window IsEnabled button property

I have a WPF sub window with some input controls that the user has to correctly fill before pressing Ok button. I have already implemented the interface IDataErrorInfo to validate all properties bound to UI Controls. Now I would like that the IsEnabled property of Ok button is True only if ALL controls are valid, otherwise it has to be...

Send files to Symantec AV Scan Engine from a C# Application

Hi, We need to scan files as they are being uploaded using the Symantec AV Scan Engine from our .Net Application, which supports ICAP Any pointers on how to go about this would be very helpful. Kind regards, ...

How do I replace the contents of an existing XML file in C#.NET?

When trying to replace the content of an XML file in C#.NET with a snippet like this: string file = Path.GetTempFileName(); // pretend this is a real file string tmpFile = Path.GetTempFileName(); using (var writer = XmlWriter.Create(File.Create(tmpFile))) { writer.WriteStartElement("root"); for (int i = 0; i < 100; i++) { ...

System.Net.Mail.MailMessage Raw Content / Spam Assassin

Hey everyone, What I am trying to do is pass the raw content of an outgoing email to spamassassin in order to calculate a spam score. I am stuck in how I might get the raw content of the email. My C# code currently just constructs the MailMessage and passes it the SmtpClient's Send() method. Before sending, is there a way to get a raw ...

.NET resources hierarchy unrelated to culture

I have some string resources, e.g. a user welcome string. By default it should be "Hello", but for customer X it should be "Greetings". I'd like to use .NET's resources implementation, and have the strings sit in constants or in files or wherever I like, plus the hierarchy model fits my needs: customer X's resources override the user we...

What is the status of runat="server" tags in ASP.NET MVC?

Some texts on ASP.NET MVC state that "there are no runat server tags", even this MSDN article says this, when, right above that statement there is a code example with a runat server tag in the HEAD element: http://msdn.microsoft.com/en-us/magazine/cc337884.aspx And on StackOverflow conversations I read "The fact that you want to...

Ftp GetFileSize randomly throws FTP error 503 (Bad Sequence of Commands)

To get the file size for every file in a list of files, I'm using the following code: foreach (String f in files) { UriBuilder ftpUri = new UriBuilder("ftp", ftpServer, -1, ftpPfadZuLogDateien + "/" + f); FtpWebRequest ftpclientRequest1 = (FtpWebRequest)WebRequest.Create(ftpUri.Uri); ftpclientRequest1.Method = WebRequestMethods.Ft...

Repository Pattern without LINQ or other ORM?

Does it makes sense to use the Repository pattern without the use of LINQ or some other ORM? I am writing an application in MONO and using MySQL, was thinking of using the repositoy pattern but not going to be able to deal with IQueryable. I was thinking of just exposing more methods on the repository to make it obvious that filtering ...

Microsoft Enterprise Library 3.1 - Validation - Message From resx

Hi, I am trying to use the Enterprise Library 3.1 Validation Block for validating my objects in a new project. This application is to be multi-lingual and as such need to be able to put my error messages into resx files. How would you go about doing this? Would you use the config section or Attributes on the objects themselves and how d...

How to identify reorderable code? Code reordering problems (.NET)

This MSDN article stated that: processors are free to reorder this code internal static volatile int s_x = 0; internal static volatile int s_y = 0; internal static volatile int s_ya = 0; void ThreadA() { s_x = 1; s_ya = s_y; } I am worried if any code could be reordered, and I know how to identify reorderable code. Speci...

.NET/C# - Sort DataTable, then manually process the rows

In C#/ASP.NET 3.5, I have a DataTable which pulls rows from the database. I want to dynamically apply a sort filter to the datatable (could be a dataview), and then do a loop through the "rows" of the sorted data to use each row for some metrics. I would greatly prefer not to hit the database each time to do custom sorting, but I'm not ...

Best book to get intimately familiar with the .NET framework?

In my spare time, I do a bit of home development primarily using free tools (Eclipse, Java, PHP, Ruby, Rails, etc.) as they are with what I'm most familiar; however, for my 9-to-5, I work as a developer in the .NET environment using all Microsoft tools. Our product is built using a framework that sits on top of .NET and that was develope...

Is there any Anti Virus product which provides a .Net (or COM) API?

Hi, We need to send uploaded files from our CMS website to any antivirus product as a POC. Are there any AV products out there that provide a .Net/COM API. Kind regards, ...

What is the WPF XAML Data Binding equivalent of String.Format?

Or, to be more clear, how can I format a block of text (in my case, to be included within a tooltip) such that some portions of the text come from bound values. In plain C# I would use: _toolTip.Text = string.Format("{1:#0}% up, {2:#0}% down", Environment.NewLine, percentageOne, percentage2); However the WPF XAML markup for a Tex...