.net-2.0

How can I prevent unauthorized code from accessing my assembly in .NET 2.0?

In .NET 1.x, you could use the StrongNameIdentityPermissionAttribute on your assembly to ensure that only code signed by you could access your assembly. According to the MSDN documentation, In the .NET Framework version 2.0 and later, demands for identity permissions are ineffective if the calling assembly has full trust. Th...

.Net 2.0 application from network share without FullTrust

I am trying to run a .Net 2.0 application from a network share without using the FullTrust permission set. I want to create a new permission set that has just the permissions my assemblies require, and then assign that to the exe on the shared path. Is it possible to do this? From my limited experiments, I find that I am unable to do get...

Using DateTime in a SqlParameter for Stored Procedure, format error

I'm trying to call a stored procedure (on a SQL 2005 server) from C#, .NET 2.0 using DateTime as a value to a SqlParameter. The SQL type in the stored procedure is 'datetime'. Executing the sproc from SQL Management Studio works fine. But everytime I call it from C# I get an error about the date format. When I run SQL Profiler to w...

How to format a string of HTML programatically.

I've got unformatted html in a string. I am trying to format it nicely and output the formatted html back into a string. I've been trying to use The System.Web.UI.HtmlTextWriter to no avail: System.IO.StringWriter wString = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter wHtml = new System.Web.UI.HtmlTextWriter(wString); wH...

Can I add Silverlight 2.0 projects to my web app and still target .NET Framework 2.0?

Can I add new Silverlight 2.0 projects to my ASP.NET 2.0 web app and still target .NET Framework 2.0 in Visual Studio 2008? ScottGu doesn't mention Silverlight in his post on multi-targeting. Michael Scwartz's posts on Silverlight with Visual Studio .NET 2005 and How to create Silverlight Applications with Notepad refer to VS2005 or to...

Dropdowns filled with same list item

I have a Gridview in which i have two templatefields of dropdownlist. I bound them on runtime with same list item. li = new listitem ("1","1"); dl1.items.add(li); dl2.items.add(li); li = new listitem ("2","2"); dl1.items.add(li); dl2.items.add(li); li = new listitem ("3","3"); dl1.items.add(li); dl2.items.add(li); dl1.selectedvalue =...

Fluent NHibernate API and .NET 2.0

Can I use Fluent NHibernate API for .NET 2.0 applications. ...

Why my ASP.NET application broke after a migration?

My web application worked very well in a Windows Server 2003 with .NET Framework 2.0. When I migrated to Windows Server 2008 with .NET Framework 3.5. With the same code running in both servers the difference between them was the following: for a given async ASHX (IHttpAsyncHandler) the previous server automatically answered the request ...

Is there a way to disable .NET browser detection?

Hi, I failed to find a way to disable the browser detection feature added by asp.net 2.0. I want all the request to my page to be treated as if IE is requesting them. My fix was to add an App_Browsers folder to my project and in it have the following .browser file: <browsers> <browser refID="Default"> <capabilities> <capab...

How to improve data access layer select method Pattern

Lately I find myself writing data access layer select methods where the code all takes this general form: public static DataTable GetSomeData( ... arguments) { string sql = " ... sql string here: often it's just a stored procedure name ... "; DataTable result = new DataTable(); // GetOpenConnection() is a private method i...

Can a .net project discover and use a WCF service?

I have created a basic WCF service in IIS. I am aware that this should be developed in .net 3.0 and .net 3.5. My question is this. Can a client running .net 2.0 access and consume the WCF service? Cheers ...

Uri.AbsolutePath messes up path with spaces

In a WinApp I am simply trying to get the absolute path from a Uri object: Uri myUri = new Uri(myPath); //myPath is a string //somewhere else in the code string path = myUri.AbsolutePath; This works fine if no spaces in my original path. If spaces are in there the string gets mangled; for example 'Documents and settings' becomes 'Docu...

Showing help for a command-line utility

I have a command-line utility that gets quite a bit of downloads from my site. I'm trying to show the usage when a user uses the /? or /help parameters. I have a function called ShowUsage() that has nicely formatted text on the parameters available. I see that ShowUsage() gets called fine from Visual Studio 2008, when I'm using the comm...

Visual Studios 2005 - Clear custom properties in designer/property window

Morning all, I've created a custom control with an image property. That image property is a get/set to a private Image variable. Can anyone tell me how I enable that get/set to clear the property from the designer? I.e. if I add an image to a standard PictureBox, I can hit Del to clear the image from the PictureBox. How can I replicat...

Fastest way to convert datatable to generic list

I have a data tier select method that returns a datatable. It's called from a business tier method that should then return a strongly typed generic List. What I want to do is very similar (but not the same as) this question: http://stackoverflow.com/questions/208532/how-do-you-convert-a-datatable-into-a-generic-list What's different i...

Get DateTime For Another Time Zone Regardless of Local Time Zone

Regardless of what the user's local time zone is set to, using C# (.NET 2.0) I need to determine the time (DateTime object) in the Eastern time zone. I know about these methods but there doesn't seem to be an obvious way to get a DateTime object for a different time zone than what the user is in. DateTime.Now DateTime.UtcNow TimeZon...

Is there some sort of secure local storage on Windows?

I was thinking of making a small tool. It is not important what the tool will do. The important thing, is that the tool will need to store some sensitive information on the user's HDD. EDIT: The information that will be stored is USER'S information - I'm not trying to protect my own content, that I distribute with the app. I understand ...

c# hosting a usercontrol in IE

Our web page is only available internally in our company and we am very intrested in being able to offer interactive .net usercontrols on our departments website in the .Net 2.0 enviorment. I have been successful with embeding the object as so: <object id="Object1" classid="http:EmbedTest1.dll#EmbedTest1.UserControl1" width="4...

How do I prevent print screen

I have a requirement that an application I am working on prevent the user from being able to easily capture the contents of the screen. I have communicated that there is no feasible way to completely prevent this from happening, but I'm looking for methods to introduce some hurdles to the process. I'm using C#/.NET 2.0 and WinForms ...

Reflection on structure differs from class - but only in code

Code snippet: Dim target As Object ' target gets properly set to something of the desired type Dim field As FieldInfo = target.GetType.GetField("fieldName", _ BindingFlags.Instance Or BindingFlags.Public Or BindingFlags.NonPublic) field.SetValue(target,newValue) This snippet works perfectly IF target is set to an instance of a CLASS...