.net

How to reference shared assemblies that are still under development (.NET)

I am responsible for developing and maintaining a set of common, framework assemblies that are used to build our product applications. These assemblies are relatively new and in a state of flux as new features are implemented, etc. As a result, it is not unusual for them to be rebuilt and redistributed somewhat frequently. I would exp...

Creating two delegate instances to the same anonymous method are not equal

Consider the following example code: static void Main(string[] args) { bool same = CreateDelegate(1) == CreateDelegate(1); } private static Action CreateDelegate(int x) { return delegate { int z = x; }; } You would imagine that the two delegate instances would compare to be equal, just as they would when using the good old name...

.NET Regex: replacing links and img src

All, I need to write a regular expression to perform the following operations replace (A) src ="/folder/image.jpg" or src="http://www.mydomain.com/folder/image.jpg" with src="/cache/getCacheItem.aspx?source_url=http://www.mydomain.com/folder/image.jpg" (B) href="/folder/file.zip" or href="http://www.mydomain.com/folder/f...

EMF with forced antialiasing

Hello, Our program needs to generate vector graphics, and we chose EMF for that. However, it seems that other programs render these images non-antialiased. I found that SVG format does have a flag to indicate that some/all objects should be antialiased. Is there any kind of flag or command inside the EMF format to indicate that we want...

Can code be run when an object falls out of scope in .Net?

Is there any way to "automatically" run finalization / destructor code as soon as a variable loses scope in a .Net language? It appears to me that since the garbage collector runs at an indeterminate time, the destructor code is not run as soon as the variable loses scope. I realize I could inherit from IDisposable and explicitly call ...

Is it a bad idea to put frequent file I/O operations within a SyncLock block?

Say I have some code that does this: Public Function AppendToLogFile(ByVal s As String) As Boolean Dim success As Boolean = True Dim fs As IO.FileStream = Nothing Dim sw As IO.StreamWriter = Nothing Static LogFileLock As New Object() SyncLock LogFileLock Try fs = New IO.FileStream(LogFilePath) ...

What is the purpose of WCF Service Library?

What is the purpose of WCF Service Library? I understand if you build an IIS hosted service you create a web project, if self-hosted - create an .exe. What is a real life scenario to use WCF as DLL? Thank you ...

Is there a way to overwrite the dotted selection/ highlight rectangle for a LinkLabel?

There are certainly some advantages in having a selection rectangle highlighting the currently selected element which also has the focus. However an element with padding can cause the rectangle to be drawn on a totally unwanted position and therefore is hindering and not helpful. So without further ado my question is: Is there a way to h...

Fluent Nhibernate AutoMapping -- 2 foreign keys to same table?

Let say I'm doing a basic transaction system where I have the following objects. public class User { public virtual int Id{get; set;} } public class Transaction { public virtual int Id{get; set;} public virtual Item Item {get; set;} public virtual User Seller{get; set;} public virtual User Buyer{get; set;} } Notice how...

How do I read in a DataSetName from an XML File using ReadXML() in .Net?

I've written a DataSet to a XML file using .WriteXML(FileName), and the DataSetName property of the dataset is the top-level tag in the file. However, when I try to read the file into a different DataSet using .ReadXML(FileName), the DataSetName isn't changed to the value of the top-level tag. Am I doing something wrong, or is ReadXML no...

.NET assembly cache / ngen / jit image warm-up and cool-down behavior

Hi, I have an Input Method (IME) program built with C#.NET 2.0 DLL through C++/CLI. Since an IME is always attaching to another application, the C#.NET DLL seems not able to avoid image address rebasing. Although I have applied ngen to create a native image of that C#.NET 2.0 DLL and installed it into Global Assembly Cache, it didn't i...

Ignore ; and add to data table

Hello All, I have a SharePoint List as Data Source and the data in it is not cleansed. I want to display a column into a Drop down list. The data is like this: StackOverFlow StackOverFlow:XYZ StackOverFlow;123 StackOverFlow,ABC I want the "StackOverFlow" to be displayed in the dropdown. How can I ignore the text after any symbol an...

Visual Studio step into doesn't return

I have a multi threaded application. It also uses some unmanaged code, an ODBC driver. If I am in a specific thread, sometimes I hit step over, F10, however it doesn't stop on the next line, the program runs as though I have hit F5 to continue. Any ideas why this is? Update 1 When I say the program runs, I mean the thread I am in. I ha...

ASP/VB .NET Formatting every row of a gridview?

I have a Gridview that has a timestamp as one of the rows. When I read the data from the database the data is in the format( mm/dd/yyyy hh:mm:ss ). I've figured out how to format the way I want it which is just the ( mm/dd/yyyy ) and droping of the (hh:mm:ss) with the following code: Dim numrows2 = GridView1.Rows.Count For i = 0 To ...

How do you make a Ninject Provider when the constructor of type is not known?

I decided to try to conjure up a container assembly to interact with FubuMVC. Well the cool part is that it pass all the test that the FubuMVC.Container.StructureMap assembly does. However, when I dropped it into the FubuSample. I received an activation error. The error is because in the provider for the behaviors I'm only calling a par...

NameSpace/Ajax problem with WebApplication

I had an ajax enabled website project, which I converted to an web application. However now my ajax pages do not see the webservices anymore, because the webservice changed from SomeService to MyNameSpace.SomeService. Now if I remove the namespace from my project properties, then the project doesn't compile properly anymore, because VS i...

How to tell if a .NET assembly is dynamic?

When iterating through a set of assemblies, e.g. AppDomain.CurrentDomain.GetAssemblies(), dynamic assemblies will throw a NotSuportedException if you try to access properties like CodeBase. How can you tell that an assembly is dynamic without triggering and catching the NotSupportedException? ...

BaseOutputPath bug in Visual Studio 2008?

MSDN: BaseOutputPath: Specifies the base path for the output file. If it is set, MSBuild will use OutputPath = $(BaseOutputPath)\$(Configuration)\ I tried to use the MSBuild Project Property BaseOutputPath instead of specifying OutputPath for every configuration & platform combination but Visual Studio complains when I compile:...

Open source server application for exception handling?

Is there some open source alternative to Hoptoad and Exceptioneer? We would like to host the exception "aggregation" application at our site. We receive tens of .NET exceptions from users in the field each day. Thus we need a way to organize them, find duplicates and prioritize fixing the exceptions that happen most often. Hoptoad is ni...

Is there a log4net version for Silverlight?

Hi, Is there a log4net version built against Silverlight somewhere? Failing that, can someone suggest an alternative logging framework to use in Silverlight? ...