.net

Clipboard.SetImage with WPF canvas leaves clipboard empty for large images

I'm rendering a WPF canvas to an image and sticking it on the clipboard. If the canvas is small (< 900px square) it all works fine. I have a larger canvas (3000+px square) and the clipboard is empty (paste option disabled in photoshop/word etc) var transform = canvas.LayoutTransform; canvas.LayoutTransform = null; var size = new Size...

How do I decode a PDEV_BROADCAST_DEVICEINTERFACE::dbcc_name?

I've been trying to watch a USB subsystem to detect when devices are added or removed, but I'm having trouble decoding the PDEV_BROADCAST_DEVICEINTERFACE::dbcc_name field. My code is based on an example over on codeproject. If I right-click in my C++/CLI application in visual studio and go to the declaration in Dbt.h I get: typedef str...

Resizing labels in Winforms to Left

I have 15 to 20 labels with variable text sizes and text boxes arranged in the forms. Text boxes are arranged next to labels. The font and color of the form and hence the form controls can be configured by the user at run time. When I right align the labels and set auto grow property to true and whenever the font style changes (say from ...

Could not load file or assembly

This is my Errormessage: Could not load file or assembly 'file:///C:\Windows\system32\Rule.dll'. The system cannot find the file specified. The problem is that the same exe works in my development environment but not on productive server. The program is a tool that should run as a Scheduled Task on Windows Server 2008. It consists of an...

Executing stored proc from DotNet takes very long but in SSMS it is immediate

I have a stored proc on SQL Server 2000 that takes 3 parameters. When I call the stored proc from DotNet using SqlCommand.ExecuteReader () it takes about 28 seconds. When I run the same query inside SSMS directly it returns immediately. When I take the query out of the stored proc and run it directly using DotNet it also returns immed...

Render partial in an extension method fails

I'm creating a tabcontainer that shows information from partials. The code that i've created is as follows: //Entering extension method, m_helper is of type HtmlHelper foreach (var tab in m_tabList) { sb.AppendLine("<div class='tabContent'>"); m_helper.RenderPartial(tab.PartialName); sb.AppendLine("</div>"); } //Returni...

Will ConfigurationManager.AppSettings["blah"] throw an exception if "blah" doesn't exist?

Will ConfigurationManager.AppSettings["blah"] throw an exception if "blah" doesn't exist in the web/app.config? Sincere apologies for the super lazy question. ...

Build Errors When Migrating to VS 2010 and .NET4.0 from VS 2008 and .NET3.5

Hi, I have a VS 2008 project. This project's target framework 3.5. Everything is Ok in this situation. I migrated this project to VS 2010 and I also changed target framework to .Net 4.0. Then I tried to build the project. But I got an error which says me to about to use "NetFx40_LegacySecurityPolicy" switch. So I used that switch and e...

SqlCeResultSet.Close - Do I need to call it?

I have seen some examples that after data is read using SqlCeResultSet that a Close is called. Do I really need to call close? What are the drawbacks if I don't close it? (does something else bad happen? Do I get memory leaks?....) ...

Requested registry access not allowed

When running my Windows Forms application on Windows 7 I get the following exception message: Requested registry access is not allowed. at System.ThrowHelper.ThrowSecurityException(ExceptionResource resource) at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable) at Microsoft.Win32.RegistryKey.Ope...

Application Registration into Database on Server

Hi All I am using WinHost.com (.NET Framework Support) for my hosting and need to be able to allow my users to login to their desktop application using their credentials that will be stored on the server. The users will register through the desktop application itself and the details will be sent to the server, and then I need a way to ...

IronPython - Adding items very fast to a GUI ListView object

Hello, I'm using IronPython 2.6, Sharpdevelop 3.2 for GUI building and compiling, Pydev on Eclipse for writing the code and debugging. I recently had some trouble using IronPython and ListView objects. In my usecase I wanted to add ListViewItems i created in a thread very fast to an GUI ListView object. First problem I ran into was ...

How can I set the background color of individual cells in a DataGridView

i have datagridviewer in c#() and i try that change cell beckground, this cell Should be for example 5(integer!) if in my datagridwiewer Will be 5(whatwhich should be take in my base_database_) its back color will be for example blue.. please help me. ___change the backcolor of individual cells. Sorry for My English.(I am a little). ...

What to take care of when using NHibernate with WCF?

I am just a simple beginner with both NHibernate and WCF. I would like to use NHibernate as my ORM in the class library where my repositories are. I also need to use WCF to expose my business logic, and behind that my repositories, to the rest of the company. Is there some good documentation on how to accomplish this task? Are there pit...

Using Moles to mock user-made classes

I have searched the forums and all over the web and have not really seen a straight answer for this. I have just been introduced to moles and I read that it can mock any .NET class or function call. However, I am wondering if it is possible to use Moles to mock classes that I have created myself. I have used MOQ before and I have read ...

Is the MS DAAB 4.1 Database object threadsafe?

I've come across some code that has a singleton which creates / reuses a static instance of the MSDAAB Database object. Is the Database object threadsafe after creation? I couldn't find anything one way or the other in the MSDAAB docs. ...

ConstraintException on DataTable.Rows.Add with AutoIncrement Column

Hi, I've got some DataTables with an ID column with AutoIncrement enabled both on the MySQL server side and the ADO.NET schema side (loaded from an XML schema file). I'd like not to have to care about these IDs when inserting rows because their sole use is to have a primary key for the table – there are no foreign key references. Howe...

What is a good lightweight ORM for our needs?

Ok I know "what X should I use" is very broad so let me narrow down our usage scenario. Basically, we should have been using an ORM a long time ago. Now though there is no way we can go through and rewrite every line of generated SQL Queries in our C# code. But we want to at least take a few steps in the right direction. So when we write...

One Time initialization for Nunit

Where should I place code that should only run once (and not once per class)? An example for this would be a statement that initializes the DB connection string. And I only need to run that once and I don't want to place a new method within each "TestFixture" class just to do that. ...

Any DI Frameworks that convert from string to constructor Types?

I'm just wondering if there is a DI Framework for .net that handles string-to-some type conversion for me? Basically I have this constructor: public MyImplTwo(bool someParam) and a string like "true" or "1". I've tried Unity, but this throws an error saying that no constructor with the signature MyImplTwo(string) exists: container.R...