.net

Strange behaivour of process counters

Hi, All! We have web application in which we are using some performance counters. For cases when there are more then one application run simultaneously we have code for determining current instance name: int processId = GetProcessID(); PerformanceCounterCategory processCategory = new PerformanceCounterCategory("Process"); string...

Where can you release eensy weensy helpful little .NET classes?

I find myself writing a lot of reusable code because I couldn't find reusable code that other people wrote. Tiny stuff, like little winforms components, among other things. I am looking for a website where I could release this sort of stuff to the public with licensing on it. I don't need something like Google Code/Sourceforge/Codeplex,...

Is it possible to create a generic bitwise enumeration 'IsOptionSet()' method?

The below code makes it easy to pass in a set HtmlParserOptions and then check against a single option to see if it's been selected. [Flags] public enum HtmlParserOptions { NotifyOpeningTags = 1, NotifyClosingTags = 2, NotifyText = 4, NotifyEmptyText = 8 } private bool IsOptionSet(HtmlParserOptions options, HtmlParserOp...

C# Inserting Rows from DataTable to Excel Spreadsheet

Is there a way to add rows from a DataTable to a Excel spreadsheet without interating through a SQL Insert Statement as so? Are there any alternative methods? foreach (DataRow drow in DataTable DT) { cmd.CommandText = "INSERT INTO [LHOME$]([Date], [Owner], [MAKE], [BUY], [OVERAGE], [SUM]) " + "VALUES(" + "'" + drr.ItemArray[0].ToStri...

C# - writing a COM server - Properties mapped to methods

We are trying to replace a COM server originally written for a VB6 application We have no access to source code. For some reason, the VB6 app can call our constructor, but then it gets: System Error &H80004002. No such interface supported. I assume when it tries to get the interface with QueryInterface. We have our assembly p...

How to import DSA signature in ASN.1 format using BouncyCastle (C#)

OpenSSL, as well as most other DSA implementations, outputs signatures in ASN.1 format. Thus, the 40-byte signature (two 20-byte integers) becomes 46 bytes due to the ASN.1 structure headers. (See this forum post for details.) My question is, how does one handle this format in C#? (or elsewhere, for that matter) I spent a while trying...

best use of MID and INSTR in vb.net

i have a string that looks like this "Patient Name, Doc Name, Patient ID, something else" i want to extract each one of these and put it in a variable. such that var1 will equal "Patient Name" var2 will equal "Doc name" etc.. using instr and mid. what is the best way to do it? ...

Is invalid user input a valid reason for throwing an exception?

According to the .NET Framework General Reference: Error Raising and Handling Guidelines exceptions should not be thrown during 'normal' operations. Is invalid user input to a web form, say the user enters a duplicate name, considered normal? !! IMPORTANT !!: I'm sure we pretty much all have an opinion on this, please include a reference...

How do I find javac.exe programmatically?

I'm calling javac from C# code. Originally I found its location only as follows: protected static string JavaHome { get { return Environment.GetEnvironmentVariable("JAVA_HOME"); } } However, I just installed the JDK on a new computer and found that it didn't automatically set the JAVA_HOME environment variable. Req...

Blocks to Fixed document/Fixed Page

Can any one help me to add Blocks(System.Windows.Documents.Block/ Section / BlockUIContainer) to the Fixed Document. Thanking for your attention, regards, kuman ...

Silverlight DataGrid cells disappearing

I've got a DataGrid in a Silverlight application with data in it. There's also a button on our app that can change the layout such that the DataGrid changes width. The problem is when you are in the "small" mode and scroll around, for columns that you can't see, their DataGridCell elements get Visibility=Collapsed. Now this is fine when...

How to mock a web service

Do I have to rewrite my code to do this into an interface? Or is there an easier way? I am using Moq ...

Problems using ListBox and observable collection as a debug log

I have a listbox bound to a view model observable collection: This works fine, minus one little hitch... assuming that the observable collection contains strings, the whole thing breaks down when entries with identical values get added to the collection, what is the best way to handle this? Custom struct instead of strings and then a ...

Reload a reference on the fly (C# .NET)

Ok, heres the rundown... I have a service that is running and it references a dll that is changed a lot. This service is hopefully going to have multiple clients hitting it at once so it would be inefficient to shut it down and recomplile/reload with a new reference. I was wondering if there was anyway the program could pretty much au...

Does ASP.NET support C++?

When I go to New -> Web site, in the drop-down menu "Language" there are only 2 languages: Visual C# and Visual Basic. No Visual C++. Maybe, I'm using wrong version of Visual Studio? (mine is 9.0.21022) I tried to google this problem. I found a topic which tells that using C++ in ASP.NET is impossible. But it was posted in 2002 and I ho...

DateTimePicker displays today's date instead of displaying its actual Value

We have a couple of DateTimePickers on a custom UserControl, on a Form. They are visible, but not enabled (for display purposes only). When the UserControl is loading, the DateTimePickers are assigned values from a DataRow that came from a DataSet which stores a single record returned from a SQL Server stored procedure. There is an inco...

SQL Server instance name with IP address

I have a very strange situation happening and I'm hoping someone here knows why. I have TCP/IP enabled for all ports on the default port 1433. All tests are consistent with SQL Server Management Studio and my program. This works: ComputerName\InstanceName 127.0.0.1 127.0.0.1,1433 192.168.1.100 192.168.1.100,1433 This does NOT wor...

Regex: How to not match the last character of a word?

I am trying to create a regex that does not match a word (a-z only) if the word has a : on the end but otherwise matches it. However, this word is in the middle of a larger regex and so I (don't think) you can use a negative lookbehind and the $ metacharacter. I tried this negative lookahead instead: ([a-z]+)(?!:) but this test case ...

Throw a warning in WiX

I am running into a complex situation where I have two install packages. One depends on the install of the other. And uninstall must be done in the correct order as well. I am having a lot of trouble getting the conditions to work to prevent one from being uninstalled if the other is still installed. I keep making conditions that preven...

How to set default datetime values in an XSD element

I am currently stuck at this point where I need to set an xsd element's default attribute to have a valid current date as default. I looked around (googled) but did not find anything convincing. I need to do this in declaratively. <xs:element name="UpdatedDate" type="xs: dateTime" msdata:Caption="Updat...