.net

Can this code be optimised?

I have some image processing code that loops through 2 multi-dimensional byte arrays (of the same size). It takes a value from the source array, performs a calculation on it and then stores the result in another array. int xSize = ResultImageData.GetLength(0); int ySize = ResultImageData.GetLength(1); for (int x = 0; x < xSize; x++) { ...

WPF Component Obscures Subcomponents in Designer

Some components like the viewbox are displayed in the visual designer as solid boxes. However, they can contain subcomponents. To view the subcomponents I comment out the viewbox. When I'm done I have to remove the comments to restore the functionality. It's rather annoying. Is there any way to permanently make the viewbox invisible ...

Store a collection of values in a config file

In a .Net 3.5 (Windows) service, I would like to store a small collection of values in the config file. Basically, I need to allow admins to add and remove values from this small collection. What do I need to add to the config file to store a collection of small values, and how can I read the collection in C#? To clarify, the collect...

Is there a built in check-in policy for TFS 2008 requiring comments?

I am trying to force users to enter comments when checking code into TFS 2008. I found this post from Jeff Atwood explaining how to add a new policy enforcing this behavior, but the post is dated. Has this been added to TFS? Thanks ...

When do you add a new project for a nested namespace?

I have many projects that are named after namespaces types are under When adding a new sub-namespace, how do you decide whether to • create a new folder in a project -- or -- • create a new project in a solution? What are some of dis/advantages I should consider for each scenario? ...

Best practice: What is the best way to store exception/error or informational messages in C#.net for internationalization?

Hello gurus, When throwing custom exceptions or issuing messages to the end user, one could use hard-coded the strings (including string constants), use resource-only assemblies or get strings from a table in a database. I would like my application to be able to switch to a different language easily without having to recompile. While ...

Convert Generic Dictionary to different type

Is there a quick way to convert a Generic Dictionary from one type to another I have this IDictionary<string, string> _commands; and need to pass it to a function that takes a slightly different typed Dictionary public void Handle(IDictionary<string, Object> _commands); ...

WPF: "Value of type 'String' cannot be converted to 'System.Windows.Media.ImageSource'."

I'm trying to set a WPF Image's source. XAML works: <Image Name="ImageThing" Source="images/Thing.png"/> Visual Basic fails: ImageThing.Source = "images/Thing.png" with this exception: Value of type 'String' cannot be converted to 'System.Windows.Media.ImageSource'. How do I create the System.Windows.Media.ImageSo...

Highlighting labels Windows Forms

Is there any way to make a label on a .NET Windows form to be highlightable to allow for the text to be copied. I have attempted to do this with a text box that was made to look like a label, but this results in a flashing cursor. ...

How can I display some text when an embedded object fails to display?

We have some html that looks like this: <form id="MyUserControl" runat="server" method="post"> <script language="javascript" src="javascript.js"></script> The javascript file contains something like this: document.write('<object id="MyUserControl" '); document.write('classid="MyUserControl.dll#MyNamespace.MyUserControl"'); documen...

Switching from .NET to Java?

For the past few years, I've been working on a team that does .NET and SQL Server. I'll soon be joining a team that is Java and Oracle. What can I read/do to get up-to-speed. ...

Looking for Recommendation on Windows Forms .Net Resizing Component

By default windows forms resize logic is limited--anchoring and docking. In the past I've rolled my own custom resize logic when required. However, I'm getting started on a project that has a large number of very complex forms that must auto-resize to different resolutions. I don't care to invest a ton of time in resize logic. I see th...

Will an empty delegate eat up memory?

public sealed class FtpManager { public event EventHandler LoggingIn = delegate { }; private void OnLoggingIn(object sender, EventArgs e) { var handler = LoggingIn; handler(sender, e); } // ... } In the above code, I have initialized LoggingIn event handler with an empty delegate. Will that affect memory...

On a deployed ASP.NET web site project, can I update a .resx file without recompiling?

I'm deploying an ASP.NET application to a locked down Production environment. Pushing assemblies (satellite resource assemblies included) into this environment has process associated with it, but copying non-assemblies to the environment does not. On an ASP.NET web site project, can I update a .resx file without recompiling? ...

What are the deficiencies of the built-in BinaryFormatter based .Net serialization?

What are the deficiencies of the built-in BinaryFormatter based .Net serialization? (Performance, flexibility, restrictions) Please accompany your answer with some code if possible. Example: Custom objects being serialized must be decorated with the [Serializable] attribute or implement the ISerializable interface. Less obvious e...

Undo get latest version with Sourcesafe

Real urgent... is there a way to undo a get-latest-version from a project? I've been working on a project for a week, and never checked in the files I was working on. A colleague had to upload a version from my computer, so he used the get-latest-version (recursive) command on the whole solution. It seems my Visual Studio has a problem, ...

What are my options for adding and removing IPSec policies on Windows Server with C#?

I want to be able to add or remove IP Security Policies on Windows Server 2003 programmatically with C#. Normally you'd manipulate these policies manaully through the gpedit.msc snap-in (under Windows Settings -> Local Policies -> IP Security Policies on Local Computer). But I need to be able to add IP filter policies through code. An...

Could not establish trust relationship for SSL/TLS secure channel -- SOAP

I have a simple web service call, generated by a .NET (C#) 2.0 windows app, via the web service proxy generated by Visual Studio, for a web service also written in C# (2.0). This has worked for several years, and continues to do so at the dozen or so places where it is running. A new installation at a new site is running into a problem....

WIX add new file to shared component

I have a shared dll, we’ll call it Utility.dll that is installed by multiple products. In my WIX file I install Utility.dll as a separate component. Now version 2.0 of the Utility.dll references an additional dll, UtilityUtility.dll which will need to be installed alongside. For my first attempt integrating UtilityUtility.dll I created ...

Creating memory stream from ResponseStream Out of Memory Exception

I am making a call to a httprequest which returns a pdf file in the responsestream. This works well for smaller pdf's, but not the file is up around 25-30MB, it is returning an out of memory exception. MemoryStream memStream = new MemoryStream(); byte[] buffer = new byte[2048]; int bytesRead = 0; do ...