.net

In WPF/XAML, should every container control contain a layout control?

When designing WPF application UI's in XAML, should every container-type control contain a layout control to house all children controls? Take a group box, for instance. I can either throw controls onto the group box directly, or I can use a layout control and place the layout control inside of the group box and then controls in that. ...

Problem with excluding namespace from XmlWriter.WriteStartElement.

Hello fellow coders, I have a little problem that perhaps you can help me with. I try to use the XmlWriter to write an XML-tag that looks like this (w3c feed recommendation): <atom:link href="http://localhost" rel="self" type="application/rss+xml" /> The problem is that I can't use the WriteStartElement-method as I would want to (at...

How can I always enable raising a dialog asking for a smart card pin?

Scenario I'm trying to use certificates to sign documents. The first time that I sign, the OS prompts a dialog for user to set the PIN, but the next times it doesn’t. For security reasons, I need that every time that I sign, the OS asks the PIN to the user. Anyone knows how to do that? This is the code: ''// create ContentInfo Dim co...

Is it possible to alias/reference a delegate from a delegate?

Hi, I'm restructuring opur code to use generics. We do use (out of necessity, no changes possible here) own code to attach/detach/iterate/calls delegates. Before there were classes X, Y, Z which declared their own: public delegate void Event_x_Delegate(ref ComParam pVal, out bool result); At the moment I'm passing this delegate to the...

Deserialize session object without type reference?

I have a POCO (plain old clr object) stored in session, and would like to be able to reference properties from that object from within another process (B). I don't want the stand-alone process (B) to require a reference to the dll in which the poco's class is defined. Is it possible to convert the saved object (in session) to something...

What is the best strategy to avoid hard coded SQL statements

The other day I was showing a colleague some code I was working on, and in the passing he commented on the fact that I have hard coded SQL statements. Now these SQL Statements are extremely static and the ones that do tend to change I made into views on the database and have a hardcoded "select columns from view where ''" kind of affair....

Unit Testing Code that calls VirtualPathUtility.ToAbsolute

I'm trying to unit test some code that calls into VirtualPathUtility.ToAbsolute Is this possible with the unit testing tools provided with VS 2008. ...

Keeping passwords in the registry as "secrets"

I need to store my users' name/password somewhere (preferably the Registry) so my .Net application can use them to log in to some remote service on behalf of the user. I know it's possible to store values in the registry as "secrets", which means their encrypted using the Windows domain user token or something. In other words, I don't wa...

How can I detect changes to item properties in the BindingList<T> ?

I have a custom class Foo with properties A and B. I want to display it in a databinding control. I have created a class Foos : BindingList<Foo> . In order to update some internal properties of the Foos class I need to be notified of property changes (I can handle insertions, removals etc.) on the items in the list. How would you imple...

How does the DLR work?

.Net 4 will have the a DLR (Dynamic Language Runtime). I know that it will be used for things like Iron Python and Iron Ruby. But is that all it's good for? How is the DLR useful? How does the DLR work? ...

databinding tooltip in listbox

Hi, I am working with binding an xml structure to a listbox. I am quite confused hoe to do this.How to put a datatemplate inside a datatemplate or i need to use a hirarchialdatatemplate...for example from the xml, I want to display the Make Name of the cars in a list box and i want to show the corresponding Suvs's as a tooltip or context...

What permission do I need to use SqlBulkCopy in SQL Server 2008?

Using .NET's SqlBulkCopy, what permission do I need to give to the user in SQL Server 2008? ...

what is common implementation for server-side XSLT + .Net?

What are the common class structure for using XSLT + .Net? (server-side XSLT) My aim is to avoid standard webforms, tending to pure MVC, but still keep all the opportunities of ASP.net (caching, session management etc). Is it better to implement it as handler(s), or on Page level, or as Control? Does it absolutely depends on particular ...

How can I embed web service settings in a DLL?

Hi, I am writing a DLL in VB.NET which will be referenced by an ASP.NET website. The DLL project has a reference to a web service in it. When I added the web service to the project, a chunk of configuration information was added to the 'app.config' file. In order to get this to work in the host website, I had to copy the information ...

Looping question

When you do stuff like: for (int i = 0; i < collection.Count; ++i ) is collection.Count called on every iteration? Would the result change if the Count property dynamically gets the count on call? ...

How to impersonate a user when calling a .NET web service from a SharePoint webpart?

What is the best practice for impersonating the current SharePoint user when accessing a web service that uses NTLM authentication? The webpart has the user name but not password, and apparently, passing the network credential from the webpart does not work. The remote web service uses NTLM to authorize the user. ...

Is Multiplying the Inverse Better or Worse?

When dealing with double data types is multiplying by the inverse better or worse? Which way is faster? Which way uses less memory? Which way is preferred? How does MSIL handle this? SquareInches = MMSquared / 645.16 SquareInches = MMSquared * 0.0015500031000062000124000248000496 NB: 10K users will note that this is a duplica...

How do I read from standard input in a WPF application?

I'm trying to figure out how to read from the standard input stream of my own WPF application but I can't find a way to get the stream. The standard way to do it, Console.ReadLine() returns Null(Nothing) immediately. I'm assuming because it's not a console application and no console window is open. How can I read from standard input ...

(0 == variable) or (null == obj): An outdated practice in C#?

Exact duplicate: Why does one often see “null != variable” instead of “variable != null” in C#? I have seen senior developers using syntaxes mentioned in the title. Is there a need for specifying a constant first in .NET? (as opposed to in C/C++ world) ...

Data Access Layer newbie

Newbie to .NET data apps here, coming from a Visual Foxpro background. I'm planning on an ASP.NET and/or Silverlight UI, and maybe some WPF client stuff too on our LAN too, so I want to craft a data access layer that can support all these front ends. My data will be in SQL server. I have already made a test run of pushing the data from...