.net

.NET: Can I unload an assmebly loaded for reflection?

Possible Duplicate: ReflectionOnlyLoadFrom & Unload? I know you can't noramlly unload assemblies in .NET without messing around with App Domains. But is there a way to unload it if I only load it for relection? Reflection.Assembly.ReflectionOnlyLoadFrom ...

Rolling back call to stored procedure in MySql

I have a scenario where I need to insert, call and drop a stored procedure in several databases. This is done in a powershell script. I want to be able to roll back the changes made by the stored procedure if some situations occur further down the in the script. The problem is that I'm not able to roll back the changes made by the stor...

Page not rendering until BackgroundWorker.RunWorkerAsync completes

I have an aspx page that on a button click creates a BackgroundWorker and then calls the RunWorkerAsync method. In my aspx file I have set Async='true' but when I run the application and click the button it appears as though the page waits to refresh until the processing of the BackgroundWorker is done. How do I get control to return t...

youtube - video upload failure - unable to convert file - encoding the video wrong?

I am using .NET to create a video uploading application. Although it's communicating with YouTube and uploading the file, the processing of that file fails. YouTube gives me the error message, "Upload failed (unable to convert video file)." This supposedly means that "your video is in a format that our converters don't recognize..." I h...

Service reference not generating client types

I am trying to consume a WCF service in a class library by adding a service reference to it. In one of the class libraries it gets consumed properly and I can access the client types in order to generate a proxy off of them. However in my second class library (or even in a console test app), when i add the same service reference, it only...

How to create chronological Folder using c#?

When I am saving a file to the filesystem, I need to store it in chronological order (only three level deep). Year -> Month -> Day -> then store file. (2010 -> June -> 01-06-2010 -> file1.txt. If folders are already in File System then don't create them just save the file. Whats the best approach? ...

Add new row to asp .net grid view using button

Hi, I am working in ASP .net 2.0. I am a learner. I have a grid view which has a button in it. Please find the asp mark up below <form id="form1" runat="server"> <div> <asp:GridView ID="myGridView" runat="server"> <Columns> <asp:TemplateField> <ItemTemplate> <asp:Button Command...

Can I use a attribute to make .net impersonate another user?

I am familiar with impersonating an account in .net by using: dim myIdentity as WindowsIdentity = someIdentity using ctx as WindowsImpersonationContext = myIdentity.Impersonate() doStuff() end using Is it possible to define a .net attribute so that I could write something like: < runAsUser(someIdentity) > public sub doStuff...

Why are Stack<T> and Queue<T> implemented with an array?

I'm reading C# 4.0 in a Nutshell by the Albahari brothers and I came across this: Stacks are implemented internally with an array that's resized as required, as with Queue and List. (pg 288, paragraph 4) I can't help but wonder why. LinkedList provides O(1) head and tail inserts and deletes (which should work well for a stack or qu...

Installation of an assembly to GAC both for mono/.NET

As far as I know, for installation of an assmebly for .NET is as follows. 'gacutil /i nunit.framework.dll' And for the mono, set the directory to MONO_PATH is doing the job. Is this correct? With .NET/windows, where does the assembly installed? I couldn't see any change in c:\Windows\Microsoft.NET\GAC_MSIL, after running the gacu...

Using NLog as a rollover file logger

How - if possible - can I use NLog as a rollover file logger? as if: I want to have at most 31 files for 31 days and when a new day started, if there is an old day log file ##.log, then it should be deleted but during that day all logs are appended and will be there at least for 27 days. ...

arp protocol, mac and ip

Hello, interested in ARP and wanted to check. ARP protocol is used found MAC and IP addresses, yes? How is it different from this: IPHostEntry iphostentry = Dns.GetHostByName(strHostName); ...

How to call memcmp() on two parts of byte[] (with offset)?

Hi, I want to compare parts of byte[] efficiently - so I understand memcmp() should be used. I know I can using PInvoke to call memcmp() - http://stackoverflow.com/questions/43289/comparing-two-byte-arrays-in-net But, I want to compare only parts of the byte[] - using offset, and there is no memcmp() with offset since it uses pointers...

Is it possible to capture a "file not found" from another process and then return a file to that process?

I have a legacy application that looks for files in a directory. It does not handle missing files very well. What I want to do is "capture" the file not found errors, and send another file back to the calling app instead. Similar to how you could handle a 404 error on a webserver and return something based on what the requested URL was...

MVC2 DataAnnotations on ViewModel - Don't understand using it with MVVM pattern

I have an MVC2 Application that uses MVVM pattern. I am trying use Data Annotations to validate form input. In my ThingsController I have two methods: [HttpGet] public ActionResult Index() { return View(); } public ActionResult Details(ThingsViewModel tvm) { if (!ModelState.IsValid) return View(t...

Output caching in HTTP Handler and SetValidUntilExpires

I'm using output caching in my custom HTTP handler in the following way: public void ProcessRequest(HttpContext context) { TimeSpan freshness = new TimeSpan(0, 0, 0, 60); context.Response.Cache.SetExpires(DateTime.Now.Add(freshness)); context.Response.Cache.SetMaxAge(freshness); context.Response.C...

NameValueCollection vs Dictionary<string,string>

Possible Duplicate: IDictionary<string, string> or NameValueCollection Any reason I should use Dictionary<string,string> instead of NameValueCollection? (in C# / .NET Framework) Option 1, using NameValueCollection: //enter values: NameValueCollection nvc = new NameValueCollection() { {"key1", "value1"}, {"key2", "value2...

SharePoint Primer

I recently started working on my first SharePoint (2007) project (C#), so I was wondering if anyone can point me to some good resources that will get me up and running with SharePoint programming basics quickly. I'd like to have a deeper understanding of the various terms I'm hearing such as Features, Lists, wsp, etc. ...

WPF DataGrid HeaderTemplate Mysterious Padding

I am placing a single button with an image in the header of a column of a DataGrid. The cell template is also just a simple button with an image. <my:DataGridTemplateColumn> <my:DataGridTemplateColumn.HeaderTemplate> <DataTemplate> <Button ToolTip="Add New Template" Name="AddNewTemplate" Click="AddNewTemplate_Cli...

How to catch key press on a form c# .net

Hi, I have a parent form that contains a lot of controls. What I am trying to do is filter all of the key presses for that form. The trouble is that if the focus is on one of the controls on the form then the parent form is not getting the key press event, so how do I capture the key down event? Thanks, R. ...