.net

How can I restrict/prevent .net code execution on internet?

I develop a series of .NET class libraries and I don't want them to run from a web site. That is, users could only use/call my libraries through windows desktop applications. For example I don't want the users to be able to use these libraries in an ASP.NET web application, on a web site. Is there a way to achieve this? ...

Is File.Delete() atomic under .NET

Target OS: Win2003 As posted in other SO questions about file operation atomicity, Win32 was simply not designed for transactions. Still I wonder whether file deletion could be non-atomic. After all, it is either get deleted or not. Or can a file remain in any other intermediate state on NTFS file system caused by a system crash or som...

Unit Testing or Functional Testing?

I have recently heard of Functional Testing over Unit Testing. I understand that Unit Testing tests each of the possibilities of a given piece of code from its most atomic form. But what about Functional Testing? This sounds to me like only testing if the code works, but is it as reliable as Unit Testing? I've been told there was two ...

Binding 2-dimensional collection to DataGridView

There is a two-dimensional array of double: private double[,] RecipesMatrix; I want to bind it to DataGridView. How can I do this? If it is better, I can change array to some other collection. ...

I'm attempting to write a .NET compiler using System.Reflection.Emit how do I do type resolution?

I've got a strategy for resolving types from referenced dlls. I'm stuck on trying to resolve types that are defined in the assembly that is being compiled. I'm using the System.Reflection.Emit apis with no 3rd party libraries. For instance: class A {} class B { public A AnInstanceOfA {get; private set;} } What's the best way to r...

C#/.Net: Returning a file to the browser?

Following this question it was recommend that I should create a server side file that can return a file from the file system. How would I go about doing this in c# and .net. I imagine I pass the filename as a query string, this is read by the page and the file returned. Not really sure where to start on this from a codding point. ...

Is there a reliable way to discern IOexceptions caused by locked files other than parsing the .message attribute?

As an example, assume the following snippet of VB.NET code to delete a directory. Try Dim SomeFolder="c:\somefolder" System.IO.Directory.Delete(SomeFolder, True) Catch ioex As System.IO.IOException 'What went wrong? 'File locked by another process? 'File not found? 'something else? End Try...

How do you add user account policies programmatically?

I was using the APIs NetUserAdd and NetUserSetGroups to add a user account and associate it with a group to a computer. Not much later I found an example capable of doing the same thing (adding a user, associating him with a group) using System.DirectoryServices namespace and DirectoryEntry object. Now I need to add policies to that ne...

Code protection and code weaving in .net

Hi! I tried to use code protection (code is encrypted and can't be reflected) made by clisecure with postsharp but secured dlls won't compile when post sharp is used in solution. I use just PostSharp.Laos and PostSharp.Public Have You ever tried such combination? Did you manage to make it work. If so please tell what obfuscation tool an...

Using Interlocked

Is this code thread-safe? or put it this way: Is there anyway to call GetIt() and that GetIt() will return the same number to 2 different threads Private Shared hitCount As Long = 1 Public Shared Function GetIt() As Long Threading.Interlocked.Increment(hitCount) DoSomethingQuick(hitCount) Return hitCount End Function ...

C# .Net - deployment "very" custom application

We are working on deploying a very custom application. The application is the main program (and only program) that will run on the PC, but it depends on multiple 3rd party installers that must be installed via separate setup programs. Some of these are standard MSI, install shield, other outdated setups, etc. On top of that we must de...

Administer asp.net website (create new users, assign users to roles, etc.) from a windows app

I have an asp.net web app that uses forms-based authentication, a SqlMembershipProvider (using an encrypted password format), and a SqlRoleProvider. I need to know if it's possible to administer the users (create new users, assign them to roles, etc.) from a windows application - the powers that be don't want any administrative functiona...

C# - Entity Framework - Doing a reverse CONTAINS?

I am using VS2008 (no option for VS2010 right now) and am doing a (reverse) Contains to try to match a partial string to a whole string. For instance, the urlRef = http://www2.rivworks.com/feed-test-1/?SSScrollPosition=0 and the defaultUrlDomain = www2.rivworks.com. IList<vwCompanyDetails> efMatchingUrlCompanyList = null; ... efMatchin...

How do I iterate "between" items in an array / collection / list?

This problem has bugged me for years, and I always feel like I'm coming up with a hack when there's a much better solution. The issue at hand occurs when you want to do something to all items in a list and then add something inbetween those items. In short, I want to: Do something to every item in the list. Do something else to all b...

VS 2008 Bootstrapper. Download Some Prerequisites and Package Some Prerequisites?

I have an install that uses the bootstrapper that requires a few different packages. One is the .Net 3.5 installer, and the others are important but not as large. I'd like the .Net 3.5 installer to be downloaded when needed, but I want the other packages to be included. Is there a way to do this? I want some to download from the vend...

using microsoft enterprise library logging in c++/cli

I am trying to use microsoft enterprise library logging framework in a c++/cli dll. I tested it in a c++ application, and it worked beatifully. it is compiling in the dll, but does not work when I try to run it, and the error is not getting caught in my catch clause. I have all the correct import and using statements in place - as it c...

Import 60mb XML file to SQL

I have a 60mb XML file that has a list of products, approx 8k of them. I need to get all the products from this xml file to a SQL table. The xml file has a static name so i know what to look for. I guess i want to know about the process, what makes the most sense and least overhead. How?What? is the best way to do this? When do i pa...

If compiler can perform implicit narrowing conversion on an integer literal, then it should also ...

If compiler is able to implicitly convert integer literal into byte type and assign the result to b ( b = 100; ), why can’t it also implicitly assign the result of an expression a+100 ( result is of type integer ) to b? byte a = 10; byte b = a; //ok b = 100; //ok b = a + 100;//error - explicit cast needed...

Programmatically modify Firewall rules in Windows Server 2008 R2

I want be able to programmatically enable, disable, create firewall rules in Windows Server 2008 R2. What is the object model to modify the firewall rules from .Net/PowerShell? ...

Heap class in .NET

Possible Duplicate: Fibonacci, Binary, or Binomial heap in c#? Is there any class like heap in .NET? I need some kind of collection from which I can retrieve min. element. I just want 3 methods: -add -removeMinElement -getMinElement I can't use sorted list because there keys has to be unique, and I might have several identica...