.net-4.0

Did P/Invoke environment change in .NET 4.0?

一笑奈何 提交于 2019-12-04 00:10:33
I've started upgrading a .NET 2.0 WinForms application to .NET 4.0. Well, OK, the upgrade process was just a matter of switching platform target, but making it actually work. I assumed that's all there would be to it. But it seems that something drastically changed in .NET 4.0 regarding interop. Using DllImport(), the application embeds a couple Delphi dlls. When the application targets .NET 2.0, everything works normally. But when I changed it to target .NET 4.0, stuff starts going haywire, like something is corrupting memory. For example, it replaces single digits with "0" in strange places.

Why is my assembly not visible in “Add Reference > .Net” when installed to the GAC?

老子叫甜甜 提交于 2019-12-04 00:10:19
Just have a quick question about the GAC I created an assembly Awesome.DLL. Had it signed, then installed into the GAC: C:\MyApps\Awesome\Awesome\Awesome\bin\Release>sn -k Awesome.snk Microsoft (R) .NET Framework Strong Name Utility Version 4.0.30319.1 Copyright (c) Microsoft Corporation. All rights reserved. Key pair written to Awesome.snk C:\MyApps\Awesome\Awesome\Awesome\bin\Release>gacutil /i Awesome.dll Microsoft (R) .NET Global Assembly Cache Utility. Version 4.0.30319.1 Copyright (c) Microsoft Corporation. All rights reserved. Assembly successfully added to the cache C:\MyApps\Awesome

MembershipProvider in .NET 4.0

大兔子大兔子 提交于 2019-12-04 00:06:07
How can I add the MembershipProvider class to my .NET 4.0 project in VS 2010 B2? I want to customize a MembershipProvider, but I cannot without adding this class. Please guide me through this process. Interesting. However, build errors are your friend ;) Attempting to build a class library built as you describe, I get the following build error: The type name 'MembershipProvider' could not be found. This type has been forwarded to assembly 'System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Consider adding a reference to that assembly. Following

Should methods that return Task throw exceptions?

╄→гoц情女王★ 提交于 2019-12-04 00:05:52
The methods that return Task have two options for reporting an error: throwing exception right away returning the task that will finish with exception Should the caller expect both types of error reporting or is there some standard/agreement that limits task behavior to the second option? Example: class PageChecker { Task CheckWebPage(string url) { if(url == null) // Argument check throw Exception("Bad URL"); if(!HostPinger.IsHostOnline(url)) // Some other synchronous check throw Exception("Host is down"); return Task.Factory.StartNew(()=> { // Asynchronous check if(PageDownloader

Visual Studio 2012 Test Project Mixed Mode Runtime

拥有回忆 提交于 2019-12-03 23:31:08
I'm currently working in the Visual Studio 2012 RC with a test project. I have included the following assemblies: Microsoft.SqlServer.Smo Microsoft.SqlServer.SmoExtend Microsoft.SqlServer.ConnectionInfo Microsoft.SqlServer.Management.Sdk.Sfc These assemblies are build in version 2.0.50727 and I have a test project in .NET 4.0. So based on this information I have added an app.config file into the project with the following lines: <?xml version="1.0" encoding="utf-8" ?> <configuration> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0"/> </startup> <

IDisposable implementation - What should go in 'if (disposing)'

不打扰是莪最后的温柔 提交于 2019-12-03 23:29:50
I have been fixing some memory leak issues in a winforms application and noticed some disposable objects that are not Disposed explicitly (developer hasn't called Dispose method). Implementation of Finalize method also doesn't help because it doesn't go in if (disposing) clause. All the static event unregistering and collection clearing have been put in if (disposing) clause. The best practice is calling the Dispose if the object is disposable, but unfortunately this happens sometimes If there are unmanaged objects, static event handlers and some managed collections that needs to clear when

EF6/SQL Server Compact, code-based configuration

好久不见. 提交于 2019-12-03 22:50:08
问题 I'm trying to move my EF6 configuration from myexe.exe.config to code as a workaround for the empty DbProviderFactories node in machine.config -issue (described here: https://stackoverflow.com/a/24273922/600559). I don't want to change the machine.config file. I have read the Code-Based Configuration (EF6 onwards). I have tried implementations like this: https://stackoverflow.com/a/23130602/600559, however I cannot get it to work. Does anyone have a working EF6/SQL CE/code-based configuration

Linq context object isn't registering as a type of System.IDisposable object

大兔子大兔子 提交于 2019-12-03 22:38:13
I'm trying to use my 'context' object in a using statement. It works on one project, but on another, I'm getting the following error. '...': type used in a using statement must be implicitly convertible to 'System.IDisposable' When I'm referring to the 'context' object, I'm referring to the object automatically created when you're working with LINQ to SQL. The class I'm working within, implements another interface, could that be screwing up this context object? using (TGDC context = new TGDC()) { } the word using has the red squigly line under it (error). You should add a reference to System

.net construct for while loop with timeout

纵然是瞬间 提交于 2019-12-03 22:29:06
I commonly employ a while loop that continues to try some operation until either the operation succeeds or a timeout has elapsed: bool success = false int elapsed = 0 while( ( !success ) && ( elapsed < 10000 ) ) { Thread.sleep( 1000 ); elapsed += 1000; success = ... some operation ... } I know there a couple of way to implement this, but the basic point is that I repeatedly try some operation with a sleep until success or I've slept too long in aggregate. Is there a built-in .net class/method/etc to save me from re-writing this pattern all over the place? Perhaps input is an Func(of bool) and

How do I trigger or supress the display of Windows Virtual Keyboard

六眼飞鱼酱① 提交于 2019-12-03 22:28:49
In WPF I have a screen for login which has a textbox for username and a password box for password. I ideally need to prevent the on-screen keyboard from displaying so I can use a custom keyboard in the perfect location in the app. Failing that I need to somehow force the on-screen keyboard to display for the password box. I've found the Microsoft.Ink.TextInput.TextInputPanel seems to have most of this functionality in .net 3.5, but I can't find an equivalent in .net 4.0 P.S. Any textboxes on other forms need to work as normal, and other applications on the same tablet should ideally also be