.net

Do I still write String^ const in C++/CLI

In C++ it's recommended to have const-correctness everywhere. But since in .Net world, the string content cannot be changed, (new string will be created), do I still write String^ const? ...

Calling a running C# application from VBA

I have some VBA code that needs to talk to a running c# application. For what it's worth, the c# application runs as a service, and exposes an interface via .net remoting. I posted a question regarding a specific problem I'm having already (http://stackoverflow.com/questions/2556163/from-vb6-to-net-via-com-and-remoting-what-a-mess) but ...

Creating transparent background in WPF

I have a button with a backgroun image of color white. My button is sitting on the toolbar which has a bacground color of Blue. When the button is sitting on the toolbar, the button looks white, however I want it to look like blue as the the background color of toolbar is Blue. How should I achieve this in WPF.. Please let me know. ...

VS2008: File creation fails randomly in unit testing?

I'm working on implementing a reasonably simple XML serializer/deserializer (log file parser) application in C# .NET with VS 2008. I have about 50 unit tests right now for various parts of the code (mostly for the various serialization operations), and some of them seem to be failing mostly at random when they deal with file I/O. The wa...

Why does adding a reference to project targeting .NET Framework 4.0 fail?

We have two projects that are both class libraries. Project 1 is a VS 2008 project and targets the .NET Framework 3.5. Project 2 is a VS 2010 (release candidate) project that targets the .NET Framework 4.0. When I try to add a reference to Project 2 in Project 1, it fails with a less than informative error message. I know that if I chang...

An error has occurred opening extern DTD (w3.org, xhtml1-transitional.dtd). 503 Server Unavailable

I'm trying to do xpath queries over an xhtml document. Using .NET 3.5. The document looks like this: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; <html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> .... </head> <body> ...

Event handling C# / Registering a callback

Events can only return void and recieve object sender/eventargs right? If so then craptastic.... how can I pass a function pointer to another obj, like: public bool ACallBackFunc(int n) { return n > 0; } public void RegisterCallback(Something s) { s.GiveCallBack(this.ACallBackFunc); } Something::GiveCallBack(Action? funcPtr...

folder and files selection in .net

I want the control component which can provide access to all file sistem like a folder browser dialog but with supprot of which i can select many folders and file. whether there is already such a component in VS 2008 or made by third parties or should I create it myself? ...

Performance Counters in Server Development

Dear Gurus, All of you agree with the value of using Performance Counters for server applications. I would like to know how to implement these using C#. Usually performance counters have the following attributes: They are shared/global Writing requires locks to ensure synchronization Reading sometimes requires locks too Is it bett...

Multiple Service Address Configs in WCF Silverlight App

My team is building our first significant Silverlight application, using a 3 layered architecture and WCF. We have developed about 10 separate WCF services in the middle layer so far, and this number is only going to grow. Generally, the presentation layer (ie. the Silverlight app) is pointing to the services as hosted on our dev serve...

Solving a cyclical dependency in Ninject (Compact Framework)

I'm trying to use Ninject for dependency injection in my MVP application. However, I have a problem because I have two types that depend on each other, thus creating a cyclic dependency. At first, I understand that it was a problem, because I had both types require each other in their constructors. Therefore, I moved one of the dependenc...

How to make the MaskedTextBox only accept HEX value?

I need a control that only accept HEX value in the following format: xxxx-xxxx and x is in 0-9, a-f, A-F So I add a MaskedTextBox and try to edit its Mask property, but did not succeed. ...

C#/.NET: TextBox is not 'focused' after a process was initiated

Hi, I am having a problem after opening the notepad once I click the button "btnSearch". The idea is that once I clicked the button 'btnSearch', the textbox 'txtSearch' should be 'focused' even after a process was initiated/opened outside the main window. Here's my code: private void btnSearch_Click(object sender, RoutedEventArg...

cancel update in datacontext = LInq

Hi, I would like to know if its possible to discard changes of only one record of only one table in datacontext. I use databind to bind my controls on a form. I modify one record at a time. after the modification, the user have to hit save button to validate. But he can hit cancel. I would like that the cancel button discard all the ch...

Unless I start Management Studio with "Run as administrator", I get a Login Failure (Error 18456)

I cannot connect to the SQL Server instance if I do not start management studio as a administrator. I am running windows 7, SQL Server 2008, and Management Studio 10.0. If I run as a normal user, the error I get is: Cannot connect to .. Additional information: login failed for user 'COMPUTERNAME\MyUserName'. (Microsoft SQL Server, E...

Windows Live Writer plugin with .NET 4

Has anyone written a plugin for Windows Live Writer that runs against .NET 4? I've read the .NET 4 introduces side-by-side running, so one part of the app can target .NET x and another part can target .NET 4. I thought WLW would be a good starting point to try this as previously it only supported plugins up to .NET 2. But my .NET 4 pl...

Is there a way of recover from an Exception in Directory.EnumerateFiles ?

In .NET 4, there's this Directory.EnumerateFiles() method with recursion that seems handy. However, if an Exception occurs within a recursion, how can I continue/recover from that and continuing enumerate the rest of the files? try { var files = from file in Directory.EnumerateFiles("c:\\", "*.*", SearchOpti...

How to do comment and document on Window Workflow Foundation

I am working with few simple xoml workflow (.NET 3.5), and I want to add few simple comment and note on the xoml file. I can find a "Description" property on activity, but that not easy to read. ...

Why isn't ValidateRequest="true" enough for XSS prevention?

In the notes for Step 1 in the "How To: Prevent Cross-Site Scripting in ASP.NET" it is stated that you should "not rely on ASP.NET request validation. Treat it as an extra precautionary measure in addition to your own input validation." Why isn't it enough? ...

Cannot take the address of, get the size of, or declare a pointer to a managed type ('type name')

this error stops compiling if i have one or more System.String in my structs is there any other way to store strings? i have tried things like this: private long _B_ID; private byte[] _C_Name; private byte[] _C_Address; private byte[] _C_Telephone; but it is not seeming to work. ...