.net

If .net sha1 hash expects a byte array, and php sha1() wants a string, can I match the results?

I have a set of bytes I want to apply an sha1 hash to. One hash will be in .net, the other in PHP. Then I'll test to see if they match. In .net, you can create a byte array and use sha.ComputeHash(). byte[] data = new byte[DATA_SIZE]; byte[] result; SHA1 sha = new SHA1CryptoServiceProvider(); // This is one implementation of the abs...

IConvertible Vs. implicit/explicit operator type conversions?

I have created a class of type Base36, and am coding the type conversion functions. Is there a benifit to implementing IConvertible, or should I define out my type conversions using static implicit/explicit operators? public static implicit operator long(Base36 value) { return value.NumericValue; } Edit: I guess I am ...

Remove empty xmlns="" after Xml Serialization

So I am still asking questions about this topic :-( So I create an object, decorate it with the Xml Serialization Attributes, from what I have seen I add an empty namespace to the xml serialization namepsace collections so as not to get the superfluous attributes I did not intend to have. EDIT: The attribute I mean are these: <url...

.Net - Detect if desired identifier is a keyword

Is there a way, in .net, to detect if a word is a keyword in a given .net language? I am using a fairly simple code generator for this project, and I would like to start automating it. Right now I do each one by hand, so fixing any issues that arise is pretty easy. However, once this starts happening automatically I am going to need...

What is the best way to enforce properties that must be implemented at each subclass in *different* fields?

I am trying to come up with the "best" way to implement SQL Data Services flexible entity model where each class could be stored as an entity, even derrived classes. Example: Every subclass has different string Id string Kind Dictionary<string, object> Properties So far, I'm heading in the direction of having both an Entity class (wi...

Windows chooses wrong icon from multi-icon file and self renders to correct size

I have an .ico file with 5 icon sizes embedded in it being used as the main application icon and the System Tray icon. When it shows up in the task bar the icon is using the 16x16 format which is desired. When the icon shows up in the Notification Area/System tray, it is using the 32x32 format and Windows is rendering it down to a 16x16...

Is reflection really THAT slow that I shouldn't use it when it makes sense to?

The "elegant" solution to a problem I am having is to use attributes to associate a class and its properties with another's. The problem is, to convert it to the other, I'd have to use reflection. I am considering it for a server-side app that will be hosted on the cloud. I've heard many rumblings of "reflection is slow, don't use it,...

.NET & COM - Class_Terminate/Disposing of an object when it goes out of scope

Hi, It is my understanding that for a VB6 COM object when it goes out of scope Class_Terminate is immediately called on the object to allow it to clean up. Is it possible to have that same functionality for a .NET object that is being called by COM? The background to the question is based on the MSDN article: http://msdn.microsoft.com...

Benefits of using data source controls for binding

hi I've started learning data source controls To my understanding, the only benefits of using data source controls instead of using regular data binding are the following: you don’t have to write data access logic (thus you don’t have to create SqlCommand, SqlConnection etc, and you also don’t have to create Datareader or DataSet) y...

Display "Wait" screen in WPF

I am trying to display a please wait dialog for a long running operation. The problem is since this is single threaded even though I tell the WaitScreen to display it never does. Is there a way I can change the visibility of that screen and make it display immediately? I included the Cursor call as an example. Right after I call this.Cu...

How do I get common file type icons in C#?

As seen in This SO question on getting icons for common file types, it's quite possible for a windows program to get the icons for a registered file type using the C++ Shell API. These icons may or may not exist on disk - for example, we wanted to make our own custom file browser and want to display the system-associated icon with the f...

Abstract base class or Interface? Neither seem right.

Given the following code: using System.Collections.Generic; static class Program { static void Main() { bar Bar = new bar(); baz Baz = new baz(); System.Console.WriteLine( "We have {0} bars, rejoice!", bar.Cache.Count); } } public abstract class foo { public static List<foo> Cache = new List<foo>(); } public class bar : f...

How do I extract data from an XML file with Visual Basic?

I've not used XML too much and I need a little help. My .NET application gets this XML response from the W3C's public validation server: <?xml version="1.0" encoding="UTF-8" ?> <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"&gt; <env:Body> <m:markupvalidationresponse env:encodingStyle="http://www.w3.org/2...

How can I make a Pink Noise generator?

((Answer selected - see Edit 5 below.)) I need to write a simple pink-noise generator in C#. The problem is, I've never done any audio work before, so I don't know how to interact with the sound card, etc. I do know that I want to stay away from using DirectX, mostly because I don't want to download a massive SDK just for this tiny proj...

Dealing with user-defined data structures

Does anyone have any recommendations for dealing with user-defined data structures? i.e. your users have to be able to define extra fields, and sometimes tables, to associate with the 'fixed' entities in your system. I always seem to be unlucky enough to end up working on projects where this is a major component. Normally the solution...

.net: Where is System.Design.NativeMethods?

I'm finding references to this namespace but it is not actually in System.Design. If I add the line LOGFONT lf; to my code, the editors dropdown suggestions include: System.Design.NativeMethods.LOGFONT Do you know where to pick it up? I'm having trouble tracking it down. Is it some sort of a 3rd party add-on? It's not in the add refe...

Can I convert a WPF page path to a class name

I have an application which pulls xaml page paths from a database. I can then use a navigationservice to navigate to the relevant page when need be. However, I have run into a scenario where I would like to instantiate the page with a specific constructor before navigating to that page. Is it possible to take a string value such as "\Pa...

Unmanaged x64 assemblies in mixed .NET development environment

What do we do if we have some devs working on 64 bit machines and some on 32 bit machines, but we need to reference unmanaged assemblies that need to be in x86 for half the team and x64 for the other half? Is there a solution besides manually updating the references every time someone on a 64 bit rig gets latest? ...

Delphi and .NET. Using Visual Studio

Hi, I've got an old project written in Delphi 4. I'm looking for a way to: use that code with minimal changes from within .NET use other .NET assemblies from that Delphi code use Visual Studio to work on the solution which will contain Delphi project and C# projects. Is that possible? What will i need for that? Thanks ...

System.Drawing: how to control font weight?

I find I can't change the font weight even though I am creating it via win32 pinvoke. I'm using Graphics.DrawString to use the font. I'm stumped and can't find anything on this. [DllImport("gdi32.dll")] static extern IntPtr CreateFont(int nHeight, int nWidth, int nEscapement, int nOrientation, int fnWeight, uint fdwItalic, uint fdwU...