.net

How to distribute keys securely with binaries in .NET?

Can I distribute a .NET app that uses a key that the user can't access, but the app can? Note that I am using the word distribute in the sense that the application is delivered to run in the user's computer, not in a cloud or cluster. ...

Resize tiff and maintain transparency and c#

I'm trying to resize an RGB 8-Bit Tif and maintain it's transparency in c#. I've tried the following code. using (Image thumbnail = new Bitmap(1500, 1500)) { using (Bitmap source = new Bitmap(@"c:\trans.tif")) { using (Graphics g = Graphics.FromImage(thumbnail)) { g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMod...

Asp.net MVC Binding

If for example you have a Car class and that Car class contains a car type which is reflected by a table in the database. How do I get MVC to bind to car type when I create a new car? public class Car { public string Name { get; set; } public CarType Type { get; set; } } public class CarType { public int CarTypeId { get; ...

Collections vs. IEnumerable

What are the advantages/disadvantages of inheriting collection vs. implementing iEnumerable() ...

how to make html page detect enter key pressed?

Hello everyone, I am using VSTS 2008 + C# + .Net 3.5 + IIS 7.0 + ASP.Net to develop a web application. The web application has an aspx page called default.aspx. And I want to implement the effect that when user press the enter key of keyboard, it is the same effect of press button "Action". Any ideas how to implement? Here is the defau...

dot net namespace error in XSLT 2.0

I get below error on calling dot net code within my XSLT file error: The type or namespace name 'com' could not be found in the global namespace (are you missing an assembly reference?) This is code snippet- <msxsl:script language="C#" implements-prefix="callCode"> <msxsl:using namespace="global::com.myassembly.crs.app.services.conten...

Having an IAsyncResult fire a "completed" event

I'm using Remoting to perform some IPC communication, and have the following question: When I invoke delegates to gather data server-side, it is possible to have an event fired on the client when an IAsyncResult is gathered? The following code is in VC++, but .net code is .net code. GetFileTextDelegate ^svd = gcnew GetFileTextDelega...

Copy pdf annotations via C#

I have a stream (PDF file with annotations) and another stream (the same PDF file without annotations). I use streams because I need to execute this operations in memory. I need to copy annotations from first document to another. Annotations can be different: comments, highlighting and other. So it is better to copy annotations without p...

Is there any way to reduce the amount of boilerplate code for IDisposable?

My project has many reader and writer classes. I started implementing IDisposable, but I believe that it adds many boilerplate code to my classes. For each of the classes, I need to implement: A destructor. A Dispose() method. A Dispose(bool disposing) method. A "bool disposed" field. A check to see if the object is already disposed on...

Switch SOA Server Address based on Build Mode (Debug, etc)?

I have an app that uses a couple of SOA calls to get some information from a database. For now we have been sending these calls to a test server, but in the near future the QA team will be using this, and they have their own QA database, and then of course we have the production server. Normally I would do an #if #define type of deal, ...

improve temporary data store

I need your idead to improve our implementation. we have about 10MB data need to be processed in our application for each analysis. that data is transferred from another application packet by packet. there are about 24000 pakcets for each analysis because the data is created packet by packet in that application and then sent to us immed...

Compact LINQ syntax for float ranges?

Is there a compact, built-in way to generate a range of floats from min to max with a given step? E.g.: range(10, 20, 0.1) [but built-in]. ...

How does the FederationMetadata.xml get created on the STS

I'm trying to set up a Relying Party web application to use the newly set up ADFS 2.0, but when I run the FedUtil.exe, it cannot locate the Federationmetadata.xml file on the STS. I've searched the server for this document, but it doesn't seem to exist. How does this file get initially created? I'm assuming that if you make any change...

DataContractSerializer Error using Entity Framework 4.0 with WCF 4.0

I am attempting to retrieve a list of objects from Entity Framework via WCF, but am receiving the following exception: There was an error while trying to serialize parameter http://tempuri.org/:GetAllResult. The InnerException message was 'Type 'System.Data.Entity.DynamicProxies.TestObject_240F2B681A782799F3A0C3AFBE4A67A7E86083C3CC4A393...

Why has this particular TimeSpan format string stopped working in .NET 4?

Consider this code (prestuffed with an example): DateTime dt1 = DateTime.Parse("7/30/2010 9:33:29.1234567 AM"); DateTime dt2 = DateTime.Parse("6/30/2010 9:33:00.7654321 AM"); TimeSpan ts = dt1 - dt2; Console.WriteLine(string.Format( "{0:d.hh:mm:ss.ff}", ts )); This is representative of a piece of code that I've had working since .NE...

How does C# create an instance of a class?

public class MyClass { int i = 0; string str = "here"; MyStruct mystruct; B b; ArrayList myList = new ArrayList(10); public MyClass() { } .... } public struct MyStruct { public int i; public float f; } public class B { ... } Want to learn how an instance of a class is created in the ba...

Converting a custom date format (string) to a datetime

I have a large set (100+ million) of observations with the date represented as a custom string format. We did not generate the date strings, I just need to convert the date string to a datetime type. How do I convert a string date (eg, 12 JUN 2010) to a datetime? My thoughts are to parse the string into components, assemble them in the...

WCF binding translation

1) I have an external customer who will be hitting a web service. This external webservice will be using SSL and signed with a certificate. No prob here... This uses wsHttpBinding. 2) I have an internal service that does all the actual work. It uses SSL without any client credentials. In other words, we trust our front box. This u...

Add nothing selected as default in a .net comboBox

Hi, I am working in C# with Visual Studio 2008. I am trying to create a comboBox for a simple search form in a windows application. What I want to do is have a comboBox with some options from a table in my database so I bound a table to it and selected the columns to display. What I want to do is add a default blank value(to represent ...

Selected items on a sharepoint 2010 listitemcollection

Is there a way to get just the selected items of a document library from the server side? I was looking for something like this: SPDocumentLibrary docLib = web.Lists[list.Title] as SPDocumentLibrary; SPListItemCollection items = docLib.Items; foreach (SPListItem item in items){ //if (item.Selected) } ...