.net

Can Ruby import a .NET dll ?

I am interested in using/learning RoR in a project where I have to use a .NET dll. Is Ruby capable of importing a .NET dll? ...

How do I delete a read-only file?

I've got a junk directory where I toss downloads, one-off projects, email drafts, and other various things that might be useful for a few days but don't need to be saved forever. To stop this directory from taking over my machine, I wrote a program that will delete all files older than a specified number of days and logs some statistics...

Why doesn't multithreading in c# reach 100% CPU?

I'm working on a program that processes many requests, none of them reaching more than 50% of CPU (currently I'm working on a dual core). So I created a thread for each request, the whole process is faster. Processing 9 requests, a single thread lasts 02min08s, while with 3 threads working simultaneously the time decreased to 01min37s, b...

how can you easily check if access is denied for a file in .NET?

Basically, I would like to check if I have rights to open the file before I actually try to open it; I do not want to use a try/catch for this check unless I have to. Is there a file access property I can check before hand? ...

How to get a DIB implemented in a C++/COM library into a .NET client using that COM object

We have a COM object implemented with C++/ATL that includes a method which will return a DIB. We are also writing a .NET application that will use this COM object. Since we are writing both, we have the liberty of deciding how best to return this DIB from the COM object. To clarify, would it be best to return a native windows handle t...

IIS API - Create virtual directories?

Just looking for the relevant documentation. An example is not necessary, but would be appreciated. We have a situation where we are having to create 100s of virtual directories manually, and it seems like automating this would be a good way to make the process more efficient for now. Perhaps next year we can rework the server env...

HowTo: Detect .Net Configuration Section instance without Loading into memory?

Does anyone know how to detect if an instance of a configuration section exists in a .net configuration file without actually having to load the configuration section into memory, and without having to parse the xml file manually - ie, using the System.Configuration namespace. I have tried using System.Configuration.ConfigurationManager...

Pass An Instantiated System.Type as a Type Parameter for a Generic Class

The title is kind of obscure. What I want to know is if this is possible: string typeName = <read type name from somwhere>; Type myType = Type.GetType(typeName); MyGenericClass<myType> myGenericClass = new MyGenericClass<myType>(); Obviously, MyGenericClass is described as: public class MyGenericClass<T> Right now, the compiler co...

How to get a screen capture of a .Net control programmatically?

How do you programmatically obtain a picture of a .Net control? ...

.NET - Users and different databases

Hello all, I'm looking at having certain users access one database and other users accessing another database based on the company they belong to. What would be the best way to handle the connection strings and make sure the user connects to the right db when they login? Thanks for any ideas. ...

Unified way to scrape HTML from any type of browser process?

Is there a unified way to do this? Browsers usually don't respond as expected to user32's GetWindowText and SendMessage, which you can use to scrape the text out of most win32 applications. I'd like to get the equivalent of "View Source" on the open web page. Currently, I'm using the API for screen readers to scrape from IE, but tha...

FileNotFoundException with the SPSite constructor. What's the problem?

I try to instantiate a instance of SPSite on the farm server in a custom software (MyApp.exe) and I give in parameter the whole website (http://mysite:80/). I also made sure that the account running MyApp.exe is Site Collection Administrator. However, I can't make an instance of SPSite whatever I am trying to do. I always gives back "Fi...

C# Collection Data Structure With 1:1 Key/Value Mapping

Are there any built-in C# data structures that are like a hash table but requires both the Keys and the Values to be unique among each other? I basically want a way to look up my Key object in a table via a unique Value and vice-versa. Next to maintaining two hash tables or iterating over each key in the hash table (which is slow), I can...

MSHTML: How can you clear the undo / redo buffer of MSHTML

I'm using a C# wrapper control similar to the WebBrowser control that contains the COM / unmanaged MSHTML control. I'm using this control in the edit mode which allows the user of the application to edit a a HTML document in a WYSIWYG manner. This control manages it's own undo / redo stack. How can I reset / clear it so that user will ...

MEF, creating Import's tree when a branch is requested

==Update== I have found a solution and I blogged about it here: link However I'd be more than happy if someone came up with a better one.** Using MEF I want to do the following. I have a WPF Shell. To the shell I want to Import from another DLL a UserControl that is also a View of my MVP triad. The way the MVP triad works, is that in...

C#, return statement in a lock procedure, inside or outside?

I just realized that in some place in my code I have the return statement inside the lock and sometime outside. Which one is the best? 1) void example() { lock (mutex) { //... } return myData; } 2) void example() { lock (mutex) { //... return myData; } } Which one should I use? ...

Mock File methods in .NET (like File.Copy("1.txt", "2.txt"))

We have some methods that call File.Copy, File.Delete, File.Exists, etc. How can we test these methods without actually hitting the file system? I consider myself a unit testing n00b, so any advice is appreciated. ...

ThreadPool causing GUI to freeze (?)

I'm noticing that, if the ThreadPool max thread count for my IO-intensive app is set too low (16), then my GUI will freeze. But if I set it considerable higher (250), it works just fine. Can anyone explain this phenomenon? ...

Change return signature via inheritance – Polymorphism

Hi guys Just wondering if there is any way to do the following: public Interface IDataField { object GetValue(); } public Interface IComplexDataField : IDataField { object GetDefaultValue(); } public class MyBase { private IDataField _DataField; public MyBase() { this._DataField = this.CreateDataField();...

Passing AD authentication credentials via IE browser in C# Windows Form

We have a Windows Form application which hosts an IE browser control. Our users run the application and open links to documents stored in MOSS. We are trying to set the application up to pass in credentials of a service account so that we can avoid giving all users access to the MOSS site. We have used code found here which seems to work...