.net

Finding a type's instance data in .net heap

ぃ、小莉子 提交于 2021-02-07 10:22:24
问题 Let's say I have two class Foo and Bar as follows public class Foo { private Bar _bar; private string _whatever = "whatever"; public Foo() { _bar = new Bar(); } public Bar TheBar { get { return _bar; } } } public class Bar { public string Name { get; set; } } I have an application that attaches to a process that is using these classes. I would like to see all instances of Foo type in .NET heap and inspect the TheBar.Name property or _whatever field of all Foo instances present in .NET heap. I

JSON Objects are serialized to empty brackets when returned using JsonResult

瘦欲@ 提交于 2021-02-07 10:20:20
问题 I am operating in the .NET Framework using ASP.NET MVC 5. I have an MVC Controller that is using Newtonsoft.Json (or json.net) to build a nice JSON object. The trouble I'm running into is that when I return my json using the JsonResult method Json(JSONdotnetObject) , I end up with a result that has the same structure as what I would expect but everything is empty JArrays like so: Expected: { "prop": { ... some stuff ... }, "another prop": { ... more stuff ... } } Actual: [ [ ... empty ... ],

JSON Objects are serialized to empty brackets when returned using JsonResult

↘锁芯ラ 提交于 2021-02-07 10:19:20
问题 I am operating in the .NET Framework using ASP.NET MVC 5. I have an MVC Controller that is using Newtonsoft.Json (or json.net) to build a nice JSON object. The trouble I'm running into is that when I return my json using the JsonResult method Json(JSONdotnetObject) , I end up with a result that has the same structure as what I would expect but everything is empty JArrays like so: Expected: { "prop": { ... some stuff ... }, "another prop": { ... more stuff ... } } Actual: [ [ ... empty ... ],

Convert a table with different relational values to excel columns

你离开我真会死。 提交于 2021-02-07 09:47:56
问题 I have these tables: Category CategoryId CategoryTitle ... ICollection<Article> Articles Each category can have several articles: Article ArticleId ArticleTitle NumberOfComment NumberOfView ... ICollection<ArticleReview> Reviews And each article has several reviews by some user: ArticleReview ArticleReviewId ReviewPoint ArticleId ReviewerId i am trying to export excel report using EPPlus package Here is my ExcelExport class : public class excelExport { public string ArticleTitle { get; set; }

Controlling GPIO in CP210x C#

跟風遠走 提交于 2021-02-07 09:39:47
问题 I need to control the GPIO pins of a CP210x device using CP210xManufacturing.dll and CP210xRuntime.dll provided by Silicon Labs. I manage to open and close the device and to get the part number. (In my case a CP2105). I think I successfully read the latch, but I'm not sure. I also call the write latch function, and no error is returned and neither do any pins toggle. According to the provided utility (CP21xxCustomizationUtility.exe) it shows that both ports are in GPIO mode. Here is my code:

Controlling GPIO in CP210x C#

风流意气都作罢 提交于 2021-02-07 09:38:55
问题 I need to control the GPIO pins of a CP210x device using CP210xManufacturing.dll and CP210xRuntime.dll provided by Silicon Labs. I manage to open and close the device and to get the part number. (In my case a CP2105). I think I successfully read the latch, but I'm not sure. I also call the write latch function, and no error is returned and neither do any pins toggle. According to the provided utility (CP21xxCustomizationUtility.exe) it shows that both ports are in GPIO mode. Here is my code:

IronPython unable to run script that imports numpy

家住魔仙堡 提交于 2021-02-07 09:36:28
问题 Disclaimer - I'm not familiar with Python. I'm a C# developer who has written an application to execute Python scripts (authored by others) using IronPython. These scripts have so far have only needed to use import math , but one of our users has asked for the application to support for Numpy. I have installed Numpy on my PC (using the 'numpy-1.9.2-win32-superpack-python2.7.exe' file), which has created a numpy folder under \Lib\site-packages. I've written a two-line Python script to test

IronPython unable to run script that imports numpy

♀尐吖头ヾ 提交于 2021-02-07 09:36:27
问题 Disclaimer - I'm not familiar with Python. I'm a C# developer who has written an application to execute Python scripts (authored by others) using IronPython. These scripts have so far have only needed to use import math , but one of our users has asked for the application to support for Numpy. I have installed Numpy on my PC (using the 'numpy-1.9.2-win32-superpack-python2.7.exe' file), which has created a numpy folder under \Lib\site-packages. I've written a two-line Python script to test

How can I check that PowerPoint or point viewer is installed on the machine?

痞子三分冷 提交于 2021-02-07 09:27:23
问题 I need to play PowerPoint slides but first I want to check whether PowerPoint or viewer is installed on the machine or not. How can I do that using .NET? 回答1: It depends on whether you are trying to tell whether you can view a presentation (*.ppt, *.pptx, etc) or whether you can access the PowerPoint object model. To check whether there is an associated handler for ppt files, you can do the following: // using Microsoft.Win32; private bool CheckPowerPointAssociation() { var key = Registry

Does Linq's IEnumerable.Select return a reference to the original IEnumerable?

醉酒当歌 提交于 2021-02-07 09:26:56
问题 I was trying to clone an List in my code, because I needed to output that List to some other code, but the original reference was going to be cleared later on. So I had the idea of using the Select extension method to create a new reference to an IEnumerable of the same elements, for example: List<int> ogList = new List<int> {1, 2, 3}; IEnumerable<int> enumerable = ogList.Select(s => s); Now after doing ogList.Clear() , I was surprised to see that my new enumerable was also empty. So I