.net

Is it possible to define a default generic type?

public class StuffDoer<T> { // do stuff } I want that this is always of type string, so instead of doing this: StuffDoer<string> stuffer = new StuffDoer<string>(); I want to be able to do this: StuffDoer stuffer = new StuffDoer(); and if I need a StuffDoer of type int, just define that with generics. StuffDoer<int> stuffer =...

How bind the mouse...

Hi All,i wish bind the mouse icon in a Visual Brush,i.e i have a Canvas and so i add A visual Brush to bind whole content of the Canvas but now i wish bind also when the mouse move the Visual Brush can reproduce the movement of the mouse into the Canvas. Do you have any idea how work out this step/feature? Thanks so much. ahh i forget ...

[NonSerialized] in C++/CLI

When I'm trying serialize a class containing this property: [NonSerialized] property System::Collections::ObjectModel::ReadOnlyCollection<String^>^ IgnoredWords I get a compilation error saying: fatal error C1093: API call 'DefineCustomAttribute' failed '0x801311c0' How do I tell the serializer that I do not want to serializ...

.Net and multiplication of singles

Can anyone explain this weirdness: Dim result as single = 0 result = CType("8.01", Single) * 100 ' result=801.0 as expected result = CType("8.02", Single) * 100 ' result=802.000061 --- not expected Further to the above result = 8.02 * 100 ' result = 802.0 as expected ...

Appropriate Situation for Using IoC Container?

Let's say I have a common WCF service and console app project that do not change across client specific deployments. I have some interfaces in the common projects that are implemented by specific client code. The client code obviously changes from client to client. I'm thinking this would be an appropriate use for an IoC container. In my...

Silverlight and callbacks in non-UI threads

Does Silverlight ever callback in the non-UI thread after an Async task (such as event listening or network request)? Assume that I've created no threads of my own. Thanks, Rui ...

WCF Http to Tcp Proxy

I have a number of WCF services on my internal network which are hosted by IIS 6 using the basicHttpBinding. There are several existing applications which use these services by using the dynamic proxy "CreateChannel()" method. I'm building a mobile application which runs outside of our network, using a cellular connection, where it is ...

Different options for XmlSerialization and derived type

I have the following object graph: public class BaseType { } public class DerivedType : BaseType { } When I pass DerivedType to XmlSerializer I need to have it reflect on BaseType instead of DerivedType. Is there a way to control this with attributes without implementing IXmlSerializer on DerivedType? ...

How does protobuf-net achieve respectable performance?

I want to understand why the protocol buffers solution for .NET developed by Marc Gravell is as fast as it is. I can understand how the original Google solution achieved its performance: it pre-generates optimized code for object serialization; I've written some serialization by hand and know that it is possible to write pretty fast co...

How to proper initialize the nvelocity engine?

As I saw in some examples, and tried to understand throughout the velocity site, there are three ways of initializing the velocityengine: - With the default configurations : .Init() - With the default configurations, plus the properties in a file : .Init(string) - With the default configurations, plus the properties in a collection : .In...

Does anyone know how to send a message to MSN Messenger?

Hi folks, I'm trying to have my windows application send a message to two msn messenger accounts. So, I grabbed the code from the MSNPSharp library and had a look in that. I can authenticate/sign in without a problem. But once i've done that, I have no idea how to send a simple text message to two other users. Do those users need to b...

How to disable WPF Menu's transparency?

I am writing an WPF application with a menu. it needs 2 to 4 seconds to show the submenu. during that 2~4 seconds, the submenu showed in transparency state. So here is the Question, How Can I disable the transparency state of the menu? or something to avoid the 2~4 seconds' delay? Thanks in advance. ...

Error 0x80005000 and DirectoryServices

I'm trying to run a simple LDAP query using directory services in .Net. DirectoryEntry directoryEntry = new DirectoryEntry("LDAP://someserver.contoso.com/DC=contoso,DC=com"); directoryEntry.AuthenticationType = AuthenticationTypes.Secure; DirectorySearcher directorySearcher = new DirectorySearcher(directoryEntry); dire...

Inject Index of Current item when binding to a repeater

I am binding a List<HtmlImage> to a repeater Its actually a nested repeater and the list is one of the properties that the parent repeater is binding to I want to spit out the index of the current dataitem into the id property of the <li> I've put a comment where I want the index to appear below I have the following: <asp:Repeater...

MVC - Model View inside of another Model View

Is it good practice to use one model view inside of another one and how will AutoMapper work with it? Example: public class CustomerModelView { public string FullName {get;set;} public string IList<OrderListModelView>(get;set;) } ...

Hex vs decimal as OracleCommand parameters

I'm looking at some code written by a former employee where I work and I'm noticing that he sometimes uses hexadecimal notation, and other times decimal. Since he's long gone I can't ask him why, so I hope someone here could take a look and enlighten me. command.Parameters.Add("PI_EMPLOYEE_NUM", OracleDbType.Varchar2, T...

Open a form with Form.Show: The first mouse click is ignored. Winforms, .Net

Using the code below: Private Sub ShowDropDown() Using f As New DropDownForm f.Visible = True Do While f.Visible Application.DoEvents() // Call to not take up 100% resources Loop End Using End Sub If the ShowDropDown method is called by anything other than a button click, then th...

When to use try/catch blocks?

I've done my reading and understand what a Try/Catch block does and why it's important to use one. But I'm stuck on knowing when/where to use them. Any advice? I'll post a sample of my code below in hopes that someone has some time to make some recommendations for my example. public AMPFileEntity(string filename) { tr...

Initializing ArrayList with constant literal

Can the ArrayList below be initialized directly without the need for aFileExt string array? private static string[] aFileExt = {"css", "gif", "htm", "html", "txt", "xml" }; private System.Collections.ArrayList alFileTypes = new System.Collections.ArrayList(aFileExt); The line below is the goal, but my .Net Compiler does not...

How to tell if a SqlConnection has an attached SqlDataReader?

This is something now more of curiosity than actual purpose. If you have a SqlConnection opened and attach a SqlDataReader to it, and then try to run another query using the same SqlConnection then it will throw an error. My question is how does the SqlConnection know that a reader is attached to it. There is not a public property or any...