.net-4.0

Problem hosting WCF service in IIS Express

霸气de小男生 提交于 2019-12-04 03:03:39
问题 We are trying to host a WCF service in IIS Express 7.5 (7.5.1046). IIS Express starts correctly, but when trying to connect to our .svc file, we get an exception with the message "Unable to load DLL 'nativerd.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)". We have searched for this dll and it is present at %WINDIR%\system32\inetsrv\nativerd.dll. The applicationHost.config file that we are using is based on the templates that IIS Express install in the

ObjectDisposedExecption after closing a .NET SerialPort

ⅰ亾dé卋堺 提交于 2019-12-04 03:00:26
I am using a .NET 4 SerialPort object to talk to a device attached to COM1. When I am done with the device, I call Close on the SerialPort. I do not call Dispose, but I believe that Close and Dispose are synonymous here. Usually this works just fine. Sometimes, however, I get the following exception some time later (The times I've seen range from 5 ms to 175 ms): System.ObjectDisposedException: Safe handle has been closed at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean& success) at System.StubHelpers.StubHelpers.SafeHandleAddRef(SafeHandle pHandle, Boolean& success) at

Locking on field or local variable?

萝らか妹 提交于 2019-12-04 02:59:46
问题 After I read this question with an answer from Marc.... I sometimes see people locking on a local variable. Is this code broken? public void Do() { object o = new Object(); lock (o) { ... } } I believe object o = new Object(); should be outside the method as a Field . Since each thread is getting a new instance of o , there will be multiple locks. What am I missing here? Shouldn't it lock on fields in this specific case? 回答1: I believe object o = new Object(); should be outside the method as

IDataErrorInfo vs IValidatableObject?

寵の児 提交于 2019-12-04 02:59:45
问题 Currently my business objects implement IDataErrorInfo . Since I intend to use these libraries in ASP.NET MVC 3, I figure I should implement IValidatableObject as well or maybe instead of. Does WPF work with IValidatableObject ? How do DataAnnotations fit into the picture? 回答1: IValidatableObject is an interface for verifying whole object level errors. It is your responsibility to implemts it by verifying data annotations or other techniques. MVC has native support for data annotations so you

Using EF 4 on .NET 3.5 SP1

梦想与她 提交于 2019-12-04 02:59:23
问题 I was using the latest EF 4 bits in Visual Studio 2010 RC and have fallen in love with it. However, I have to develop a small web application using .NET 3.5 SP1 (VS 2008) for work... I was wondering if it was possible to somehow utilize EF 4 in .NET 3.5 SP1/VS 2008. Regards. 回答1: EF4 requires .NET 4 (it's part of .NET 4), and you can't use that from a .NET 3.5 application. 来源: https://stackoverflow.com/questions/2500609/using-ef-4-on-net-3-5-sp1

.Net 4: How to reference a dynamic object with property named “return”

大憨熊 提交于 2019-12-04 02:58:05
问题 I'm retrieving json from a public api and converting it into a dynamic object using JsonFx. JsonFx.Json.JsonReader reader = new JsonFx.Json.JsonReader(); dynamic response = reader.Read(jsonAsString); The json contains a property named return. e.g. {"result":"success","return":{"high":{"value":"3.85001","value_int":"385001","display":"3.85001\u00a0\u20ac","currency":"EUR"}} JsonFx creates the dynamic object fine and I can also debug into it and see the values. The problem is when I try to

System.Windows.Shell Reference missing

假如想象 提交于 2019-12-04 02:56:17
问题 I have a windows form application and i want to make my own custom jumplist. To do this i need to use the namespace System.Windows.Shell but i can't access it, and i can't find a reference for it in the list of references either. I have checked some tutorials but they all use XAML (WPF Application) and some of them just mentions this can be done by coding as well. So my question is, is it possible to access the namespace needed in a windows form app or do i need to use WPF? And if it is

App.Config errors with “Configuration system failed to initialize”

不问归期 提交于 2019-12-04 02:54:28
I have a console application written in C# under .net 4.0 It has a bunch of variables which I want to move into App.Config (so it will be all in one place). Added this part of code to App.Config (between configuration tags): <configuration> <appSettings> <add key="RemoteDirectory" value="Some Text Here"/> </appSettings> </configuration> In my program trying to test it with this code Console.WriteLine(ConfigurationManager.AppSettings["RemoteDirectory"]); but I keep getting "Configuration system failed to initialize" error. Try looking the Inner Exception for more detailed information. It helped

Why does Mage.exe not generate a compatibleFrameworks attribute?

我怕爱的太早我们不能终老 提交于 2019-12-04 02:50:50
问题 We are using Mage.exe to generate our application's manifests as part of our build process. Upon upgrading to .NET 4 we now find it generates an invalid manifest. The reason is there isn't a compatibleFrameworks attribute being set in the application manifest which we generate every build. Is there a way we can make Mage.exe add this element or should we only ever update existing manifests? 回答1: Add this to your GenerateDeploymentManifest MSBuild task TargetFrameworkMoniker=".NETFramework

BC30560: 'ExtensionAttribute' is ambiguous in the namespace 'System.Runtime.CompilerServices'

旧城冷巷雨未停 提交于 2019-12-04 02:35:46
I have asp.net project (in .net 2.0) and I converted project to .net 4.0. After I built the project successfully, I launched the website on browser, it throws error as following: Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: BC30560: 'ExtensionAttribute' is ambiguous in the namespace 'System.Runtime.CompilerServices'. Source Error: [No relevant source lines] Source File: InternalXmlHelper.vb Line: 9 .....