.net

Create custom driver for System.Data.Common

Background: Our C# application generates and executes queries to several types of databases (Oracle, SQL Server, MySQL), but a requirement came up to also apply them to a proprietary file format. The namespace used until now is System.Data.Common. The queries we need to apply are non-trivial (nested SELECTs, aliases in FROM, substring...

Clearing up large fields from memory in long lived objects

.NET 3.5, I've got some classes which stores up to 1MB of strings. Even though I need the object for a really long time I don't need to store the string for a long time. How can I truly remove the string from memory without disposing the parent object. Is it a good practice to use "myString = null" in this case? or shall wrap it in a ...

How can I specify T4 (Text Templates) to use C# 4.0, in VS2010?

I need to specify my T4 to use C# 4.0, to render my tt files? I tried using <#@ template language="C#v4.0" debug="true" #> But when I use a dynamic variable, like this dynamic x=10; Write(x.ToString()); I'm getting these errors Error 2 Compiling transformation: Predefined type 'Microsoft.CSharp.RuntimeBinder.CSharpSetMemberBind...

How to measure desktop applicaton usage by users?

I've wrote a app in c# .NET 3.5. People download it and use. I would like to know how many users do this and how many installed it. How to do this? ...

C# - ActiveX control without a form

We are required to use a 3rd party ActiveX control. The only issue is, the layer in our software is a business layer and has no access to a window or form. It also runs on separate threads (and should work from any thread) that are not STA. Rather than breaking our separation of UI from business logic, we used this workaround to make ...

.NET: Is it possible to retrieve NetworkCredentials from Current.Request?

i don´t think so.. but is it possible to retrieve the NetworkCredentials from HttpContext.Current.Request (e.g. in a WebService-method) which where used to call the web-site hosting my webservice? ...

Performance problem Loading Dataset inside a virtual.

Host Configuration: HP EliteBook 8530w 4G Ram Win7 Ultimate 64Bit RC SQL Server 2005 64bit Developer Edition Virtual: Windows Virtual PC 1G Ram allocated Integration Services installed Windows XP 64bit Up to date service packs and .Net framework through 3.5 SP1 Sharing the Gigabit network adapter of the Host I have a simple .Net ...

Windowless ActiveX controls are not supported

I have a C# .NET 2.0 application that loads legacy VB6 modules (which we have not converted yet) which are ActiveX controls (.ocx files) the application loads these from the main C# .NET form via interops. Since service pack 2 for .NET 2.0 our users have been getting random errors where the application will throw a "Windowless ActiveX c...

Find Non Used Functions?

I know you can perform a 'Find All References' on a function and you can determine if it is being used anywhere, but is there a tool that will go through all of my functions and highlight any that are not called anywhere in the code? ...

What pros and cons are there using linq to sql vs creating my own datalayer?

I just started playing with Linq to SQL the other day and was curious if I should use it in up coming projects. I know it will save me tons of developement time. I have seen many similar questions out there on the subject but I have a few more specific questions. Is there anything wrong with inheriting the classes generated in the ...

How to count the elements of a list in a list in a list using LINQ?

Imagine the following list: List<List<List<String>>> listRoot = new List<List<List<String>>>(); I want to count the elements of the first and the second list and return the accumulated value: int iFirstListCounter = 0; int iSecondListCounter = 0; foreach (List<List<String>> listFirst in listRoot) { iFirstLis...

Open Worksheet of Excel File in URL

I want to open a particular worksheet on a Excel file through URL. Googling suggested to use this format for the path "http://ags.mydomain.com/MyPMReports/Files/Doc33_HighwaySafety.xls#FreewayCrashRates" Where Exce File name : Doc33_HighwaySafety.xls Worksheet inside it : FreewayCrashRates But this doesn't seem to work. Any help wo...

Business logic in a data object vs. coupling vs. DTO (vs. ?)

I've got a set of business/domain classes (for a calendar) that are going to be exposed in an internally-public API. In the same API, there are data objects that directly mirror the underlying database structure (NHibernate mapping, but that's unimportant). What I need to do is build typed collections of those objects, so the days on th...

If statement using a class within a repeater

Hello All, I am using c#.net I have a repeater and a ObjectDataSource (ObjectDataSource is created within the code behind). Within the repeater are two buttons (edit/delete). I need to system to either hide/remove these buttons if the user doesn’t have permissions to edit/delete. Repeater Code <ItemTemplate> ...

Obfuscating multiple related .NET assemblies with babel obfuscator

Hi I have two assemblies, A and B, where A depends on B. I'm trying to obfuscate both of them together, i.e. in a way it doesn't break the app with the babel obfuscator. Is there a way to do that? Apparently this obfuscator doesn't handle multiple assemblies. If that's an issue, which other .NET obfuscator- that handles multiple assem...

Setting Word's printer through Office automation

I'm looking to do the same as in this question here, however I am developing in a .NET class library, referencing the Primary Interop Assemblies. The item returned from the dialog box collection when I do this wordApp.Dialogs[WdWordDialog.wdDialogFilePrintSetup] does not expose properties such as Printer and DoNotSetAsSysDefault. Doe...

Problem with Random and Threads in .NET

I'm having trouble with the Random class in .NET, I'm implementing a threaded collection which is working fine, except for one smaller detail. The collection is a Skip list and those of you familiar with it know that for every node inserted I need to generate a new height that is <= CurrentMaxHeight+1, here's the code that I'm using to d...

Is it a good idea to use T4 to code-gen mock objects for interfaces?

I'm familiar with unit testing, but am still learning about mocks and mocking frameworks. I get the ideas (I think), but the syntax still seems a little foreign. I'm considering creating some T4 templates that automatically generate mock implementations of interfaces and classes. Using a combination of generics and extension methods, thi...

How can I write an XML on my hard drive to GetRequestStream

I need to post raw xml to a site and read the response. With the following code I keep getting an "Unknown File Format" error and I'm not sure why. XmlDocument sampleRequest = new XmlDocument(); sampleRequest.Load(@"C:\SampleRequest.xml"); byte[] bytes = Encoding.UTF8.GetBytes(sampleRequest.ToString(...

C#: Convert FreeImage FIBITMAP to byte[]

Hello, I am having some trouble using the FreeImage .NET wrapper - I can successfully create an FIBITMAP, but I haven't figured out how to get a byte[] or Stream from the FIBITMAP. If anyone has some experience with FreeImage and knows =how to do this, please let me know! Thanks y'all, -Charles ...