.net

A .NET DLL question

I created a C# file and wish to compile it into a DLL for future use. However, this .cs file depends on another DLL. In my code inside my .cs file I am doing something like: using anotherlib.dll; When I try to compile it into a DLL, the compiler tells me that it can't find that anotherlib.dll (missing directive or assembly reference)....

How to create collapsible panels as custom controls in WInforms?

The closest I can think of using is the GroupBox control which has a custom drawing at the top identifying the panel. Is it doable? I have done independent custom controls like buttons, sliders, color pickers, but not totally sure if this sort of drawing can be done on a GroupBox? I would need the grouping of a GroupBox or a TabPanel. ...

What makes MVVM uniquely suited to WPF?

The Model-View-ViewModel is very popular with WPF and Silverlight. I've been using this for my most recent projects, and am a very large fan. I understand that it's a refinement of MVP. However, I am wondering exactly what unique characteristics of WPF (and Silverlight) allow MVVM to work, and prevent (or at least make difficult) this...

How to store sets of controls in an assembly?

I have sets of controls contained in individual GroupBox controls. So say GroupBoxCommon contains Common UI Items, GroupBoxSpecific contains Specific UI items, etc. I have a way of stacking them in a single UI (floating panel) based on the current selection in the app. I am just wondering how I should store these sets of controls? Sho...

how can I get the set of open handles for all processes

I would like to know if a file is open by any process (including the caller) There are a number of suggestions already posted, which tend to revolve around trying to open the file exclusively and catching the exception. This has not proven to be a fool-proof method in my instance. I beleive in my specific situation I can get by with s...

StreamReader to file?

I have an input stream wrapped in a System.IO.StreamReader... I wish to write the content of the stream to a file (i.e. StreamWriter). The length of the inputstream is unknown. Could be a few bytes and to gigabytes in length. How is this done the easiest that does not take up too much memory? ...

When happens to value types when they're removed from a collection?

Suppose I have some simple struct like this: public struct WeightedInt { public int value; public double weight; } Then let's say I have a collection of instances of this structure: List<WeightedInt> weightedInts = new List<WeightedInt>(); As I understand value types versus reference types, value types are allocated on the ...

Difference between DebuggerDisplayAttribute and DebuggerDisplay

[DebuggerDisplayAttribute("{_name}")] vs [DebuggerDisplay("{_name}")] Is there a difference? Is one an alias of the other? Does VS automatically check for a class named fooAttribute when using an attribute named foo? ...

MS Word Interop: Cancel (Don't Show) the 'Save Changes' Dialog on Close

Hi, I'm using MS Interop to open a generated file for a user, allow them to edit it and then close it, after which I save it for them (it's part of a larger process). Since the user doesn't need to save the file manually I would like to cancel that pop up dialog to save the file when the user tries to close the document. The following d...

web.config secure directory with gal group

So, I have the following in the web.config <authentication mode="Windows"/> <authorization> <allow users="domain\johndoe" /> <!--Deny All Others--> <deny users="*" /> </authorization> But, what I want to do, is only allow users in a specific GAL group on our AD server and that doesn't seem to work with these settin...

Using XPath to find the value of an attribute in a node based on another attribute in the same node?

I have an xml document that is constructed pretty poorly-- instead of child nodes, the items have multiple attributes. For Example: <makes> <option make="FORD" year_start="1950" year_end="2009" /> <option make="CHEVROLET" year_start="1965" year_end="2009" /> ... </makes> I'm trying to use XPath to select the value of the other attri...

How to set the default value of Colors in a custom control in Winforms?

I got the value to show up correctly using: [DefaultValue ( typeof ( Color ), "255, 0, 0" )] public Color LineColor { get { return lineColor; } set { lineColor = value; Invalidate ( ); } } But after I reload the project the control is used, this value is set to White, which I can invoke Reset to get back to Red again, but I do...

Weighted Random Number Generation in C#

Question How can I randomly generate one of two states, with the probability of 'red' being generated 10% of the time, and 'green' being generated 90% of the time? Background Every 2 second either a green or a red light will blink. This sequence will continue for 5 minutes. The total number of occurrences of a blinking light should...

"Method xxx can not be reflected" error in webservice call

Before obfuscation, the call to the webservice works like a charm. After obfuscation i get this error. Method obfuscatedText.GetStringFromWebService can not be reflected. There was an error reflecting ". What could i do? Why do i get this error after obfuscation? ...

.NET 3.5 CE Deployment

Hi All, I have an C#.NET application for pocket PC. Application needs .NET3.5 framework to run on device. If I deploy the application through VS2008 by connecting device through ActiveSync then it deploys framework also. Is there any way if I can deploy framework without VS2008??? Cheers ...

MVC moq unit test the object before RedirecToAction()

I want to test the data inside the "item" object before it redirect to another action. public ActionResult WebPageEdit(WebPage item, FormCollection form) { if (ModelState.IsValid) { item.Description = Utils.CrossSiteScriptingAttackCheck(item.Description); item.Content = Utils.CrossSiteS...

What's going to happen if I use OLE Automation to load up a 32 bit control in a 64 bit app?

The .NET application for which I'm responsible uses a third-party control that is only available as a 32 bit COM component. I've been banging my head against walls for a while trying to find a way to allow the component and the app to work together in 64-bit mode. We got some help from the control vendor - they don't plan on supplying ...

Very strange evaluation problem

I'm working on some VB.net code that I inherited and am seeing some very strange behavior when trying to lookup a value in a Interop.Scripting.Dictionary object. Here's the output from my watches. The expressions are in italics and the return values are bolded: oAwayBalanceTeam.Dates("40068") 1 {Integer} Object CStr(Int(oTempBooking.S...

Can web methods be overloaded?

I have built a regular .NET asmx service. How do i overload web methods in this service? ...

Using extension methods in .NET 2.0 ?

I want to do this, but getting this error: Error 1 Cannot define a new extension method because the compiler required type 'System.Runtime.CompilerServices.ExtensionAttribute' cannot be found. Are you missing a reference to System.Core.dll? [snipped some path stuff] I have seen some answers here that says, you have to define this attri...