.net-4.0

Force protobuf-net to ignore IEnumerable/ICollection interfaces

心不动则不痛 提交于 2019-12-06 00:52:13
问题 How can I get v2 of protobuf-net to ignore the fact that my class implements ICollection, IEnumerable, etc? For this particular scenario, I only want the fields I have flagged as [ProtoMember] to be serialized. I am currently in the process of converting from using protobuf-net v1 to using v2. I have a particular structure which is now serializing incorrectly because of the change. It looks something like the following: [ProtoContract] public class FileTree : ICollection<FilePath>,

Does PostedFile.FileName work differently in .Net 4.0?

青春壹個敷衍的年華 提交于 2019-12-06 00:21:59
I'm working on an ASP.Net site which allows users to link documents using a UNC path. This site is used by a customer of ours for internal processes, so all users on their domain should have access to the UNC path. When a user wants to add a linked document, they select the file using a FileUpload control. Previously in .Net 2.0, the control's PostedFile.FileName property returned the filename and the full UNC path. Now we are using .Net 4.0 and it only returns the filename. Here's my main question: Does PostedFile.FileName work differently in .Net 4.0 compared to 2.0? If not, what else could

c# Linq's - GroupedEnumerable usages?

不羁岁月 提交于 2019-12-06 00:05:40
Fruit[] data = new[] { new Fruit {Name = "Gala",Type = "Apple",Price = 0.75m,Quantity = 10}, new Fruit {Name = "Granny Smith",Type = "Apple",Price = 0.80m,Quantity = 7}, new Fruit {Name = "Tasty",Type = "Strawberries",Price = 1.90m,Quantity = 20} }; var grouped = from fruit in data group fruit by fruit.Type; grouped type is : System.Linq.GroupedEnumerable<ConsoleApplication15.Fruit,string,ConsoleApplication15.Fruit> have a look on it : my question : if grouped contains items ( implements ienumerable ) - why its type is GroupedEnumerable and not IEnumerable <System.Linq.IGrouping<string

Using UNC path with credentials

心不动则不痛 提交于 2019-12-05 23:40:50
问题 I'm working on an app that uses an UNC path to access remote files in the same LAN. The problem is that when access is attempted it throws an exception related to Windows credentials. Is there a way to add credentials to my UNC path? Thank you 回答1: It might be useful for you to use the NetUseAdd function from the windows api http://msdn.microsoft.com/en-us/library/windows/desktop/aa370645(v=vs.85).aspx. It allows you to access a directory through its UNC path. 回答2: Looks like Win32 APIs are

Which Table/Grid Control in WPF?

纵饮孤独 提交于 2019-12-05 23:22:57
问题 I am looking to display tabular data (tv channels), but with options such as DataGrid/UniformGrid/Table with FlowDocument/etc. I cannot figure out what would be the best option. The main issues is that the cells aren't uniform in size as it varies based on length of time, and I would like to put padding between them as well. Additionally, I need to only be able to display a portion of the table, and allow them to scroll Up/Down/Right to view the rest. What would be the best WPF Control Option

How to convert PNG to BMP at runtime?

帅比萌擦擦* 提交于 2019-12-05 23:05:13
I need to convert PNG file to BMP file on runtime. I can't do it like Image dummy = Image.FromFile("image.png"); dummy.Save("image.bmp", ImageFormat.Bmp); because i can't save the bmp image on the local disk as a file. Thanks for any help. You can save to stream using(MemoryStream stream = new MemoryStream()) { Dummy.Save(stream, ImageFormat.Bmp); } sgokhales Precise answer given here. Image Dummy = Image.FromFile("image.png"); Dummy.Save("image.bmp", ImageFormat.Bmp); Since you don't want to follow this method, you can do it the way Stecya answered. Just do it this way. Stream stream; Dummy

How do I specify events deep inside “Applications and Services Logs”?

感情迁移 提交于 2019-12-05 23:00:00
The following code snippet fires an event when an event is logged. The sample code works fine but the log I want to monitor is actually "Applications and Services Logs > Microsoft > Windows > Task Scheduler > Operational". What do I insert in place of "Application" in the code sample? ... EventLog myNewLog = new EventLog("Application", ".", "testEventLogEvent"); myNewLog.EntryWritten += new EntryWrittenEventHandler(MyOnEntryWritten); myNewLog.EnableRaisingEvents = true; ... The log name is Microsoft-Windows-TaskScheduler/Operational but I don't think you can access it using the EventLog class.

c++/cli static constructor of derived class is not called

限于喜欢 提交于 2019-12-05 22:24:22
As described in another SO post of me I saw a strange behaviour of my application after moving from VS 2008 (.net 3.5) to VS 2013 (and using .net 4.0, not 4.5). I found that the static constructor (cctor) of a class was not called any more. Therefore I broke the application down into a small test program: DLLs testAssembly_2-0 and testAssembly_4-0 (similar content; testAssembly_4-0 has names with 40 instead of 20 ) namespace testAssembly_20 { public ref class Class20 { public: Class20 () { Console::WriteLine (__FUNCTION__"()"); } static Class20 () { Console::WriteLine (__FUNCTION__"()" + " ms

asp.net gridview DataNavigateUrlFormatString from DataSource

两盒软妹~` 提交于 2019-12-05 22:20:52
I have a gridview that is being populated from a datasouce. The Stored procedure that is populating the datasource, has a field "Client" and a field "Client WebSite". I want to populate the field "Client" in the gridview column called "Client" which would be a hyperlink field and the hyperlink field would be the "Client WebSite" value from the dataset. The client website is an external site (not within my asp project) Below is my html code. How can I get the "Client WebSite" appear as the DataNavigatrURL value? <asp:HyperLinkField DataTextField="Client" HeaderText="Client"

What does BlockingCollection.Dispose actually do?

橙三吉。 提交于 2019-12-05 21:38:14
问题 What does BlockingCollection.Dispose actually do? 回答1: This allows the internal wait handles to be disposed of properly. BlockingCollection<T> , internally, uses a pair of event wait handles, which in turn have an associated native HANDLE . Specifically, BlockingCollection<T>.Dispose() releases these two handles back to the operating system, by eventually (through SemaphoreSlim->ManualResetEvent) calling the native CloseHandle method on the two native HANDLE instances. 回答2: Having a quick