.net-4.0

How to pin a pointer to managed object in C#?

北慕城南 提交于 2019-12-04 18:52:43
问题 Unmanaged code calls my functions. In first function I should pass back pointer to my managed object. Sometimes later some of my other functions get called with that same pointer as one of parameters . I should dereference it and use it to perform some calculations and then if it is not needed dispose of it. To cut the story short I need to pin that object so that GC won't move it til I dispose of it. How to do that in C# ? Thanks in advance. 回答1: To pin an object in C#, you can use GCHandle

What gacutil.exe should I use?

霸气de小男生 提交于 2019-12-04 18:42:40
问题 So, on a Win 2008 R2 Std x64, I have 6 (six) gacutil.exe all different (not counting ones in VS folders), in: c:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin c:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\x64 c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\x64 c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\x64 Questions are: Does

Reading .NET 4.0 dump files in WinDBG

安稳与你 提交于 2019-12-04 18:33:51
I'm familiar with the WinDBG paradigm. Been reviewing a lot of dump files using WinDBG x64 version. For the most part dump files were .NET 2.0 applications and psscor2.dll. Current WinDBG version I am using is 6.12.0002.633. Recently, I've been trying to open x64 dump IIS dump files generated from a .NET 4.0 application pool using psscor4.dll. Any command I run returns, "Failed to request information" I've mscordacwks.dll from c:\Windows\Microsoft.NET\Framework64\v4.0.30319 on the server Renamed to mscordackwks_AMD64_AMD64_4.0.30319.xxxx.dll. xxxx matches the compiled version in the file Open

Sending Email via GMail and .NET 4

南笙酒味 提交于 2019-12-04 18:30:03
Does .NET 4 has any problems in sending emails? I had a .NET 3.5 solution and it was working then migrated the solution to .NET 4 and It does not works; nothing changed! Notes: I get this exception: System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response) at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, String from) at System.Net.Mail.SmtpTransport.SendMail

Replace relative urls to absolute

有些话、适合烂在心里 提交于 2019-12-04 18:16:55
I have the html source of a page in a form of string with me: <html> <head> <link rel="stylesheet" type="text/css" href="/css/all.css" /> </head> <body> <a href="/test.aspx">Test</a> <a href="http://mysite.com">Test</a> <img src="/images/test.jpg"/> <img src="http://mysite.com/images/test.jpg"/> </body> </html> I want to convert all the relative paths to absolute. I want the output be: <html> <head> <link rel="stylesheet" type="text/css" href="http://mysite.com/css/all.css" /> </head> <body> <a href="http://mysite.com/test.aspx">Test</a> <a href="http://mysite.com">Test</a> <img src="http:/

Why does a direct cast fail but the “as” operator succeed when testing a constrained generic type?

扶醉桌前 提交于 2019-12-04 18:16:46
问题 ``I've run across an interesting curiosity when compiling some C# code that uses generics with type constraints. I've written a quick test case for illustration. I'm using .NET 4.0 with Visual Studio 2010. namespace TestCast { public class Fruit { } public class Apple : Fruit { } public static class Test { public static void TestFruit<FruitType>(FruitType fruit) where FruitType : Fruit { if (fruit is Apple) { Apple apple = (Apple)fruit; } } } } The cast to Apple fails with the error: "Cannot

NSIS Installer with .NET 4.0

风流意气都作罢 提交于 2019-12-04 17:57:55
问题 Is there a standard/preferred method for automatically downloading and installing the .NET 4.0 Framework from an NSIS installer, if the machine doesn't already have it? There are several examples for making this work on older versions of the framework, but seemingly none of them work for 4.0. Before I hack something together myself, I wanted to see if anyone here knew of something already out there. Thank you for your time. 回答1: What is the problem? The solution should be the same as for any

Migrating ASP.NET (MVC 2) on .NET 3.5 over to .NET 4 #gotchas

无人久伴 提交于 2019-12-04 17:51:30
I've currently got a ASP.NET MVC 2 application on .NET 3.5 and I want to migrate it over to the new .NET 4.0 with Visual Studio 2010. Reason being that it's always good to stay on top of these things - plus I really like the new automatic encoding with <%: %> and clean web.config :-) So, does anyone have any experience they could share? Looking for gotchas and the likes. I guess this could also apply to any ASP.NET Forms projects aswell. TIA, Charles Charlino Gotcha #1 - Changes application pool If your ASP.NET project is setup to use IIS and not Cassini, during the upgrade to .NET 4.0 process

Thread Safety with Dictionary

家住魔仙堡 提交于 2019-12-04 17:35:52
问题 If I have a Dictionary<int, StreamReader> myDic = new Dictionary<int, StreamReader> //Populate dictionary One thread does myDic[0] = new StreamReader(path); Another thread does myDic[1] = new StreamReader(otherpath) Is this thread safe because the actual item in the dictionary getting modified is different to the one on the other thread or will I get a InvalidOperationException: Collection was modified 回答1: You will only get InvalidOperationException: Collection was modified if you enumerate

C# webBrowser Control how to get data under mouse pointer

时光怂恿深爱的人放手 提交于 2019-12-04 17:17:58
Hi If I open a site in the WebBrowser control is there anyway to code a function to get data under the mouse pointer? So what I'm wanting to do, but don't have a clue how to! is load a website (most any website) the user places the mouse over some data on the page and presses control click and on doing so the code works out what the HTML tag below the cursor and reads the inner value of it. hope that makes sense! in fact just like the pointer control in the MS Developer tool for IE does it even manages to place a box around what would be selected... I'm only looking for the text no images...