.net

XmlDocument and the Formal Public Identifier

Why is my GetEntity function in my overloaded XmlResolver being passed the Formal Public Identifier when I load an xml file into an XmlDocument? Is this a bug or am I supposed to deal with this some how? edit: Here's some code. Say for example I do this: XmlDocument myXmlDoc = new XmlDocument(); myXmlDoc.XmlResolver = new MyXmlResolv...

How to edit application configuration settings? App.config best way to go?

For my project I have settings that I added through the Settings in the project properties. I quickly discovered that editing the app.config file directly seems to no really update the settings value. Seems I have to view the project properties when I make a change and then recompile. I'm wondering ... what is the best and easies...

In a multithreaded (Java or .Net) program, can I assume that copying a variable is atomic?

I was worrying about race conditions in an application I'm designing, when I was wondering about this question. Let's say I have a large array or collection of some sort that is managed by one component of my program, let's call that component Monitor. Its job is to regularly check if the collection is "dirty", i. e. has changed recentl...

TreeView double-click behaviour in .net / C#

Hi, I have a regular .net windows forms treeview control. The nodes are setup like this: Group ---child ---child If I double-click a collapsed Group node, it expands (as you'd expect) and the NodeMouseDoubleClick event is fired off, where my code does something if the selected node is NOT a group node. The problem arises when the ...

Maintain object references through Serialize/Deserialize

When serializing, I would like to serialize an object only once, then any references to that object should be serialized as a reference to the object. This is because, when I later deserialize the objects, I would like to maintain those references. To illustrate my goal, the code below should output "After Serialization: true". class Pr...

Is it better to use the column name or column index on .Net DataSets?

When retrieving values from a DataRow is it better to use the column name or column index? The column name is more readable and easier to maintain: int price = (int)dr["Price"]; While column index is just faster (I think): int price = (int)dr[3]; Would using column names break if you decide to obfuscate the database? ...

ScreenShot of WebBrowser Control blank on 301/302 redirects

I'm using some code from SmallSharpTools Web Preview to get screen shots of websites but i get a blank screen shot if the url returns a 301/302 redirect. WebBrowser wb = new WebBrowser(); wb.ScrollBarsEnabled = false; wb.Size = new Size(1024, 768); wb.ScriptErrorsSuppressed = true; wb.AllowNavig...

How can I use Record/Playback syntax with StructureMap AutoMocker?

Is it possible to use the syntax using(_mocks.Record()) { //... } using(_mocks.Playback()) { //... } with StructureMap RhinoAutoMocker? In Jeremy Millers original post AutoMocker in StructureMap 2.5 this seems possible since RhinoAutoMocker inherits MockRepository, but in version 2.5.2 of StructureMap this seems to be implemen...

Client certs without using the keystore

I'm trying to figure out if there is any way to have a .NET client use a client certificate without involving the Windows keystore in any way. I have a code snippet like this: test1.Service s = new test1.Service(); X509Certificate c = X509Certificate.CreateFromCertFile(@"C:\test.pem"); s.ClientCertificates.Add(c); int result = s.TestMe...

Using the .NET collection editor without using a property grid control

I have a PropertyGrid on my form. My boss thinks it's ugly. Uncouth. Unsophisticated. He wants a nice, neat, clean form. Here's the catch: One of the properties is a collection of our home-grown objects. He likes the collection editor for this collection. I know I can build my own collection editor. But is there a clean, simple solutio...

Problem invoking Web service using WS-Security

I am invoking a webservice form my .net web application a getting the following com.ibm.wsspi.wssecurity.SoapSecurityException on invocation. WSEC5048E: One of "SOAP Header" elements required. The SOAP request seems to be valid so I guess the problem is something to do with the webservice using WS-Securty. I had to install a certific...

Unity framework DependencyAttribute only works for public properties?

I was trying to clean up some accessability stuff in my code, and inadvertently broke Unity dependency injection. After a while I realized that I marked some public properties that I didn't really want exposed outside my DLLs to internal. Then I started getting exceptions. So it seems that using the [Dependency] attribute in Unity only...

Simple SQL statement builder for .Net

I've jumped into an ongoing .Net 2.0 web app project for a larger company as a freelancer. Their DAL has lots of functions that manually construct and execute SQL statements -- many of them are long, messy and as a result difficult to understand and debug. I wrote a simple "sql helper" that lets me write things like this: sqlh.addValue...

Export Excel range/sheet to formatted text file

Hello, I have been tasked with creating a reusable process for our Finance Dept to upload our payroll to the State(WI) for reporting. I need to create something that takes a sheet or range in Excel and creates a specifically formatted text file. THE FORMAT Column 1 - A Static Number, never changes, position 1-10 Column 2 - A Dynamic ...

Tool for diagnosing memory leaks in .NET (ASP.NET Application)

Hi, we need a tool to detect easily memory leaks in an ASP.NET Application. We have an application, which consumes lot of memory. Thanks ...

What are the pros and cons of OleDB versus SQLClient?

Some context: one of the systems I'm working on is a .net 2.0 web application. VB.net for the front end, and SQL Server 2005 for the backend. For a variety of reasons that have been lost to time, the original designer decided to use the .Net OleDB connection rather than the SQLClient connection. After a few years of development, this ...

Generic enforcement

I have a generic class public MyClass<TContext, T> where TContext : DataContext that effectively acts on an instance of another public class MyOtherClass<T> : IEnumerable<T> I want to enforce that the TContext has a Table<T>. Is there a clean way to enforce this? ...

starting a program on a remote machine in wmi, but also opening the apps window (in c#)

I've browsed page after page after page of data on the web and everyone seems to say that you cannot have an executable remotely execute an application on another machine via WMI and have the window of that application display. Does anyone know a way around this? I have tried created 2 executables. 1 executable uses the Process class a...

.NET Library to access the COM Port?

Is there a library that would allow me to send and receive data on a Serial COM port? ...

What is the best way to store configuration values for several dozen columns?

I've got ~20 columns in a grid each of which can be shown or hidden via a checkbox in another dialog. The visibility state of any given column will be stored inside an XML file which is accessed via an Options class. I'm trying to decide how best to represent those Boolean visibility values inside the Options class. I'm fairly sure I'l...