We have a lot of code that passes about “Ids” of data rows; these are mostly ints or guids. I could make this code safer by creating a different struct for the id of each database table. Then the type checker will help to find cases when the wrong ID is passed.
E.g the Person table has a column calls PersonId and we have code like:
...
In my application I have been asked to send error codes via SNMP traps. I believe that this will need to be done using version 3 because of the security issues with versions 1 and 2. Is there anything in the .net framework to do this or should I be looking to buy a third party library.
...
Hello,
I must add some Dispose code to a class that inherits from a class that already implements IDisposable so I tried to do an Override of the Dispose method but I have not available the disposedValue because it is declared as private.
How can I add the new Dispose statements?
Protected Overridable Sub Dispose(ByVal disposing As Bo...
Is there a way to use a static property of a class as the factory-method for a object definition?
<object id="MyObject" type="MyNamespace.Factory, MyAssembly" factory-method="FactoryObject" />
<!-- "FactoryObject" is a Property (with getter) of the class "Factory" -->
Using this config a exception is thrown:
Error creating cont...
I am trying to return an XMLReader from a data access class that calls a stored proc to run a FOR XML query. The problem is, I can't call close() on the sql connection when I return the xmlreader or the reading will terminate. The class that calls for the xmlreader doesn't know anything about a sql connection so it can't be in charge of ...
I'm wrestling with a weird, at least for me, method overloading resolution of .net. I've written a small sample to reproduce the issue:
class Program
{
static void Main(string[] args)
{
var test = new OverloadTest();
test.Execute(0);
test.Execute(1);
Console.ReadLine();
}
}
public class Over...
It may be a subjective question but I want to know what people feel is the best pattern for behavior of an object's save or delete methods?
When you setup a class that will contain Db record information I usualy end up declaring the objects Delete() and Save() methods as void. As these methods usualy take direct action on other properti...
I was asked to write a database and it's GUI frontend for some non-profit organization I am member of.
The decision was to use .NET as I know C# fariy good and writing GUI is quite easy. I though of implementing local SQL Server database (as I worked earlier with MySQL) and connect to it via SqlClient interface. But then I discover some...
I have a class:
public class class1
{
public string Property1 {get;set;}
public int Property2 {get;set;}
}
Which will be instantiated:
var c = new class1();
c.Property1 = "blah";
c.Property2 = 666;
So bear with me (I am new to generics), I need another class with a property of a generic type so that Property1 or Property2 can be us...
Whats the best way to create the multi language installer for Office Addin Deployment Setup?
Is it possible using VS.NET 2008, C# or do I need to use any 3rd party tool or like install shield 2009 ??
...
I have a client side app (WPF) that hits my web services.
When I am running in dev I want to hit the Dev version of these web services. When I am running in the Test environment I want to hit the test version of the services. Like wise for production.
Since these values are in my app.config file what is the best way to switch between...
Is it possible to do this? I need to use:
this.ControlName.DataBindings.Add (...)
so I can't define logic other than bind my enum value to a bool.
For example:
(DataClass) Data.Type (enum)
EDIT:
I need to bind Data.Type which is an enum to a checkbox's Checked property. So if the Data.Type is Secure, I want the SecureCheckbox to ...
My application has just leaked 1.5GB of memory. I guess since I don't have a ton of data available to me, I'm assuming that it's leaked the memory, but it could also just be holding onto it.
I'm currently using perfmon to gather as much information as I can, to try to understand what could be causing the problem. I don't have a whole ...
I'd like to know what is the serialization format of the BinaryFormatter. I found this site which give some good informations, but it was obtained by reverse engineering and it is not complete.
Where can I find the official specification of the BinaryFormatter serialization format?
...
I have a whole bunch of pairs of files that have subtle differences. We use subversion for a source control, and I like the Merge/Diff utility that comes with TortoiseSVN for windows. And I can use this utility to manually compare/merge two files together. My question is this: How can I programmatically merge two files together the s...
We publish a class library that must remain compatible with .NET 2.0. However, we would also like to use this class library internally for WCF-based projects.
Reading e.g. expose-object-from-class-library-using-wcf brings up an approach for using 2.0 class libraries by creating DataContractSurrogate objects to map 2.0 classes. Howev...
Hello I am working on something, and I need to be able to be able to add text into a .txt file. Although I have this completed I have a small problem. I need to write the string in the middle of the file more or less. Example:
Hello my name is Brandon,
I hope someone can help, //I want the string under this line.
Thank you.
Hopefully ...
In EF is there a way to specify a relationship between two tables when there is no relationship defined in the database and one of the related columns is a specific string/hard-coded value?
Lets say I have a Document object and it can have various stages of approval and a category. My table might look like
DocumentID, DocumentName,...
I'm using the facebook developer's toolkit for a facebook connect website. The website posts content to the stream for a page - which I have working fine.
I'd like to also get the stream from the page to show users who visit the website - regardless if they are logged in to facebook or not. Facebook provides a handy fan box (fbml) for t...
Is there a way to send ZPL (Zebra Programming Language) to a printer in .NET?
I have the code to do this in Delphi, but it is not pretty and I would rather not try to recreate it in .NET as it is.
Answer from the post in the accepted answer:
[DllImport("kernel32.dll", SetLastError = true)]
static extern SafeFileHandle Create...