c#-4.0

Overloaded Action Method not found at Runtime from test

孤者浪人 提交于 2020-01-15 22:12:36
问题 I have two action methods : public ActionResult Edit(int id) { } public ActionResult Edit(Modelname model, string[] strParam) { } And I am calling the Edit(Modelname,string[]) from the unit test. var actionResult = controller.Edit(model, strParam); The code compiles at runtime , but when i debug the test method it gives me a method not found "MissingMethodException" . I tried commenting the Edit(int id) method and then debugging, still the same thing. Other tests are running fine, any help

DocumentElement.AppendChild throws object reference not set to an instance of an object

只愿长相守 提交于 2020-01-15 20:57:11
问题 I'm trying to create a new xml file, write data into it and than save. Here is the code: XmlDocument doc= new XmlDocument(); XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", null, null); doc.AppendChild(dec); XmlElement rootnode = doc.CreateElement("Root"); foreach (var item in list) { XmlElement parent = ordersNIA.CreateElement("ParentElement"); XmlElement childOne = ordersNIA.CreateElement("childOne"); childOne.InnerText = "This is the first child"; parent.AppendChild(childOne);

Sonar to display results generated by FxCop

半世苍凉 提交于 2020-01-15 15:36:41
问题 How can I use Sonar to display results of the output produced by FxCop. I used FxCop to run static code analysis on .NET Project and FxCop generate the result report in an XML format. Can I use Sonar to take this XML file an input and display the output with it? How can this be done? I am looking for an open source dash board tool to present the output the result produced by FxCop to the end user. 回答1: Sonar has a C# plug-in, documented here: http://docs.codehaus.org/display/SONAR/C-Sharp

Sonar to display results generated by FxCop

眉间皱痕 提交于 2020-01-15 15:36:12
问题 How can I use Sonar to display results of the output produced by FxCop. I used FxCop to run static code analysis on .NET Project and FxCop generate the result report in an XML format. Can I use Sonar to take this XML file an input and display the output with it? How can this be done? I am looking for an open source dash board tool to present the output the result produced by FxCop to the end user. 回答1: Sonar has a C# plug-in, documented here: http://docs.codehaus.org/display/SONAR/C-Sharp

Pattern for concurrent cache sharing

ε祈祈猫儿з 提交于 2020-01-15 15:12:24
问题 Ok I was a little unsure on how best name this problem :) But assume this scenarion, you're going out and fetching some webpage (with various urls) and caching it locally. The cache part is pretty easy to solve even with multiple threads. However, imagine that one thread starts fetching an url, and a couple of milliseconds later another want to get the same url. Is there any good pattern for making the seconds thread's method wait on the first one to fetch the page , insert it into the cache

Retrieving Windows Password Hint from the registry

随声附和 提交于 2020-01-15 12:25:11
问题 I have been trying to extract the Windows login password hint for Windows 7 programmatically and I came to know it can be retrieved from the following location in the registry HKLM\SAM\SAM\Domains\Account\Users\"userkey"\UserPasswordHint However, I am not able to figure out is there any way to find out userkey for the currently logged-on user programmatically? 回答1: If you can get the current user name, it's quite easy, using the same registry tree. Take a look in HKLM\SAM\SAM\Domains\Account

How do I move a AutoGenerate,IsolateApps machine key system onto a load balanced server?

痴心易碎 提交于 2020-01-15 09:22:50
问题 I just found, web.config with below settings in all the environments including prod. <machineKey validationKey="AutoGenerate,IsolateApps" decryptionKey="AutoGenerate,IsolateApps" validation="SHA1" decryption="Auto" /> Now, application is going to start using with load balancing. Would it create problem as its not using static machine keys ? If I change this key now to static validaitnKey and static decrptionKey then it creates another problem for already protected keys unable to decrypt.

Putting data from SqlDataReader into HTML table

戏子无情 提交于 2020-01-15 08:55:08
问题 I have some data in a database that I read out with SqlDataReader . I want to put these in a HTML table in my ASP.NET site, but I can't figure out how to do so. 回答1: You can use a gridview. It is an asp.net control which you just bind your datareader to your gridview, and it will display every row that is returned from your database as an html table row. You can even combine two or more columns, and add pictures or links instead of just displaying the data with a templated row. Google it and

Add Performance Counter Category Hangs Computers

不问归期 提交于 2020-01-15 07:36:07
问题 I am trying from a ASP.NET MVC Application (with VS 2012 on Windows 8 x64 PC) to add a Perfomance Counter but I have the problem that if I check the category exists or add a new Performance Counter Category the computer hangs My code is: namespace TestMvcCounter { public class MvcApplication : System.Web.HttpApplication { protected void Application_Start() { AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters

Oracle query is not working in C#

会有一股神秘感。 提交于 2020-01-15 07:15:53
问题 When I run this code it always returning zero while when i run this query in oracle sql client it returns 1. var strSQL = string.Format("SELECT COUNT(*) FROM GANTNER.GAT_REASONS WHERE CODE ='{0}'", StatusCode); objCmd = new OracleCommand(strSQL, objConn); objCmd.CommandType = CommandType.Text; int val = int.Parse(objCmd.ExecuteScalar().ToString()); For try I remove condition on column name CODE and it works but when I put column name CODE it does not then I tried to put "CODE" 'CODE' all not