.net

Load a .NET assembly from a COM ProgID without creating a COM object

A bit of an odd question and probably backwards from what most people want to do, but I'm trying to work around a legacy COM issue. I have two components, both of which are actually .NET assemblies, but for historical reasons one is loading the other as a COM object (the assembly is registered for COM Interop). It's a plug-in architectu...

Read and Step into .Net Framework Source Code with VS 2005

I did ask whether this was possible in VS 2008 which was answered in http://stackoverflow.com/questions/1296840/read-and-step-into-net-framework-source-code. However my problem is that I am using 2005 and not 2008. Does anyone know whether this is possible please?? The reason I want to do this is to better understand C# paradigms. Wit...

How do I create a queue browser (preview not consume) in C# for an ActiveMQ queue?

I'm using the NMS API for reading/writing ActiveMQ in C#, and I cannot find a way to preview the messages on a queue. I could read and rollback - but that'll make them DLQ eventually. In my previous life, TIBCO had a QueueBrowser object that could be used, and I think JMS had IQueueBrowser as well. I cannot find an ActiveMQ .NET equiv...

System.Diagnostics.Debug.WriteLine in production code

I should probably know this already, but I'm not sure and I don't see it documented. I use System.Diagnostics.Debug.WriteLine quite often during the development process to be able to track changes to variables or exceptions as I'm debugging the code. This is meant to make development and understanding what's happening easier only durin...

AJAX change in .NET 4: Sys.Services.AuthenticationService

I'm testing my existing apps in VS 2010, and ran into my first break. ASP.NET AJAX authentication support has changed. Sys.Services.AuthenticationService.set_defaultLogoutCompletedCallback(OnLogoutCompleted); This no longer works. "Sys" is defined, but "Sys.Services" is an undefined object. Does anyone have a quick pointer to the repl...

Why does my ASP.Net custom control render two id attributes on my first child control?

I'm writing a small ASP.Net custom control inheriting from CompositeControl. The control is just a panel containing two subpanels with a label in each subpanel. When rendered, I am seeing in the HTML source that the first child control of my custom control gets two id attributes - the first being the id of the custom control itself and...

Casting woes with generic class which needs to know the specific value of T (out of a possible 30 different types) - is this scalable?

I am working with a 3rd party web testing API which has a Src property for image. What I need to do is say: if (t is HtmlImage) { // Do cast here. } // t is a variable of type T (my generic). However, my cast does not work. The cast is as follows: Controls.HtmlImage img = (Controls.HtmlImage)t; This gives an error stating that I c...

Discard Chars After Space In C# String

I would like to discard the remaining characters (which can be any characters) in my string after I encounter a space. Eg. I would like the string "10 1/2" to become "10"; Currently I'm using Split, but this seems like overkill: string TrimMe = "10 1/2"; string[] cleaned = TrimMe.Split(new char[] {' '}); return string[0]; I feel the...

How to get server domain name

Can anybody tell me how to get servers domain name in asp.net? (Environment.UserDomainName returns "IIS APPPOOL" string) Thanks for replays, but mostly they are about DNS name of the server, what I need is the domain name. For example when I login via windows authentication I type domain\user and I need this "domain" ...

Winforms for a java swing guy [Applying MVC]

I am developing a GUI application in C# using the design mode in VS2008. Now that I am finished with the looks of the application I am ready to add some functionality to it. What really confuses me though, is that VS2008 designer only uses the empty constructor. When developing applications in Java I normally pass around a model and con...

LinqToSql giving 'Specified cast is not valid'

Hi- I'm running a stored procedure through L2S and it's returning 'Specified cast is not valid'. The stored proc is returning data when ran manually and when I step thru it, everything is fine until it tries to create the row object in "foreach (var row in result)". var q = new db(); var result = q.GetNearbyLocations(latitude, longitude...

Script arguments and Embedded IronPython

I have an embedded scripting engine in my C# application that uses IronPython 2. I create the Python runtime and add a few classes to the global namespace so that the script can import them as modules. However, one (pretty basic) thing I can't figure out is how to send script arguments. I realize that I could just create a variable with...

how to send data over network fast?

i have lots of data like this 1:0x00a4c7d9fb3849... 2:0x79821309bd789c7689c97... 3:0x0178dce67fe898... they are more than 100 per second and speed is the most important thing(network is always busy). what should i use to transfer my data(tcp/ip, pipes, via, etc)? how should i serialize it(BinaryFormatter,Xml,User defined or any better ...

How do I enable visual style backgrounds in a property page?

When a Control is shown in a TabControl, it can set the UseVisualStyleBackColor property of the TabPage to true in order to show properly in the tab control rather than just a solid colour fill. However, when a Control is shown in the management console as part of a PropertyPage, its parent is a PropertyPageContainerControl rather than ...

Casting problems with connected Generic classes.

Here's a thinned out version of the classes I have. public abstract class BaseParent { } public abstract class ChildCollectionItem<T> where T : BaseParent { // References a third-party object that acts as the parent to both the collection // items and the collection itself. public T parent; // References the collection to w...

How can I design a class to receive a delegate having an unknown number of parameters?

I continuously find myself having to write timed windows services that poll outside queues or run timed processes. I consequently have a fairly robust template by which to do this, but I find that every time I write a service to do this, I start with the same template and then write the process inside it. This morning I find myself won...

can't understand these xml encoding woes

The following hunk of code (snipped for brevity) generates an xml doc, and spits it out to a file. If I open the file in Visual Studio it appears to be in chinese characters. If I open it in Notepad it looks as expected. If I Console.WriteLine it look correct. I know it's related to encoding, but I though I had all the encoding ducks ...

Java and .NET interop on (RSA) signatures

Hello, I'm signing some data on a .net-based smartcard and trying to verify that signature in a java environment - but without success. Smartcard (c#): RSACryptoServiceProvider rsaProvider = new RSACryptoServiceProvider(1024); // In a different method, rsaParams.Exponent and rsaParams.Modulus are set rsaProvider.ImportParameters(rsaPa...

Question about modal forms and threads

Hey, In the main thread I need to do the following: Create a second thread where I'll show a modal form that will act as an "activity indicator" Start a task (this task MUST be executed from the main thread) Close the modal form created in the second thread. The question is that I don't know how to show a modal form and not stop the...

How to check if two DateTime's occur on the same day

Is there a better .net way to check if a DateTime has occured 'today' then the code below? if ( newsStory.WhenAdded.Day == DateTime.Now.Day && newsStory.WhenAdded.Month == DateTime.Now.Month && newsStory.WhenAdded.Year == DateTime.Now.Year ) { // Story happened today } else { // Story didn't happen today } ...