class-library

Class library does not recognize CommandManager class

随声附和 提交于 2019-12-01 02:11:10
I'm developing WPF applications and I want to reuse my classes that are the same in all those applications so I can add them as a reference. In my case I have a class for my Commands: public class RelayCommand : ICommand { #region Fields readonly Action<object> _execute; readonly Predicate<object> _canExecute; #endregion // Fields #region Constructors public RelayCommand(Action<object> execute) : this(execute, null) { } public RelayCommand(Action<object> execute, Predicate<object> canExecute) { if (execute == null) throw new ArgumentNullException("execute"); _execute = execute; _canExecute =

Class library does not recognize CommandManager class

让人想犯罪 __ 提交于 2019-11-30 21:37:36
问题 I'm developing WPF applications and I want to reuse my classes that are the same in all those applications so I can add them as a reference. In my case I have a class for my Commands: public class RelayCommand : ICommand { #region Fields readonly Action<object> _execute; readonly Predicate<object> _canExecute; #endregion // Fields #region Constructors public RelayCommand(Action<object> execute) : this(execute, null) { } public RelayCommand(Action<object> execute, Predicate<object> canExecute)

References from class library are not copied to running project bin folder

怎甘沉沦 提交于 2019-11-30 11:51:41
问题 I have a class library that represents my logic layer. To that library I've added a nuget package for Google.Apis.Analytics.v3 - it installed the package and all it's dependencies. I have a console application that uses that logic class library (regular reference). everything is written and compiled fine. The problem is that during runtime it threw an exception that Google.Apis.dll wasn't found. This DLL is a dependency that was downloaded with the nuget. Checking the BIN folders, I've found

Cannot debug a unit testing project in Visual Studio 2012

不问归期 提交于 2019-11-30 08:08:44
问题 I couldn't find a post similar to this, so I hope this isn't a duplicate. I have a c# class library that I'm trying to run unit tests on in Visual Studio 2012. I've added a new Unit Test Project to my solution, and added my main project as a reference there. I've set my unit test project as the Startup Project. When I try to debug, I get an error message A project with an Output Type of Class Library cannot be started directly. In order to debug this project, add an executable project to this

Using ASP.Net MVC Data Annotation outside of MVC

心已入冬 提交于 2019-11-30 08:00:26
问题 i was wondering if there is a way to use ASP.Net's Data annotation without the MVC site. My example is that i have a class that once created needs to be validated, or will throw an error. I like the data annotations method, instead of a bunch of if blocks fired by the initaliser. Is there a way to get this to work? I thought it would be something like: Add data annotations Fire a method in the initialiser that calls the MVC validator on the class any ideas? i must admit i havent added the MVC

Is there an equivalent of Application_Start for a class library in c#

眉间皱痕 提交于 2019-11-30 06:52:54
I would like to execute certain code in a class library when it is instantiated from another assembly. Is there an entry point or bootstrap for a class library? I thought that a static method Main would do the trick but I was wrong. Applications for this might be configuring and instantiating a logger singleton, unhandled exception handler, etc. CharithJ AppDomain.AssemblyLoad Event which occurs when an assembly is loaded. Probably that can be used to call an initialize method in your class library. public static void Main() { AppDomain currentDomain = AppDomain.CurrentDomain; currentDomain

'System.Configuration.ConfigurationSettings.AppSettings' is obsolete

可紊 提交于 2019-11-30 06:21:54
问题 I got the following warning 'System.Configuration.ConfigurationSettings.AppSettings' is obsolete: '"This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings"' How do you fix it? 回答1: Add a reference to the assembly System.Configuration . Then at the top (assuming C#) using System.Configuration (Imports System.Configuration in VB.NET). Use ConfigurationManager.AppSettings["MySetting"] to access the settings! 回答2: as its a

References from class library are not copied to running project bin folder

一个人想着一个人 提交于 2019-11-30 01:56:12
I have a class library that represents my logic layer. To that library I've added a nuget package for Google.Apis.Analytics.v3 - it installed the package and all it's dependencies. I have a console application that uses that logic class library (regular reference). everything is written and compiled fine. The problem is that during runtime it threw an exception that Google.Apis.dll wasn't found. This DLL is a dependency that was downloaded with the nuget. Checking the BIN folders, I've found that in the class library bin folder this DLL was present, but in the console application BIN folder it

Is it necessary to deploy the XML file in a class library?

早过忘川 提交于 2019-11-29 13:26:33
I have developed a lot of class library projects in VS 2012 to be used in Windows Forms and Web forms applications. The question is simple. Do I need to deploy the DLL file itself together with the XML file that is created? For example, the class library project is called DataWare. Upon building, I got 5 files in Release folder (this project reference Entity Framework): DataWare.dll DataWare.pdb DataWare.dll.config EntityFramework.dll EntityFramework.xml I know that ".pdb" file contains debugging information, so there is no need to deploy. The ".config" file is not taken into account. Instead

Referencing mscorlib 4.0.0.0 from .NET Core 1.0 class library

大憨熊 提交于 2019-11-29 09:41:28
I have a .NET Core 1.0 class library which targets .NET 4.6.1 and references the .NET Standard Library 1.6.0 and Identity Framework 2.2.1 project.json { "version": "1.0.0-*", "dependencies": { "Microsoft.AspNet.Identity.EntityFramework": "2.2.1", "System.Runtime": "4.1.0", "NETStandard.Library": "1.6.0" }, "frameworks": { "netstandard1.6": { "imports": [ "net461" ] } } } In my project I'm just creating the identity models, which extend the base Identity Framework models (User, Role etc). When I try to compile, this happens... Any ideas how to resolve this? There are two problems with your