class-library

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

做~自己de王妃 提交于 2019-11-29 06:24:07
问题 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. 回答1: AppDomain.AssemblyLoad Event which occurs when an assembly is loaded. Probably that can be used to call an initialize method in your class

Cannot debug a unit testing project in Visual Studio 2012

天大地大妈咪最大 提交于 2019-11-29 05:49: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 solution which references the library project. Set the executable project as the startup project.

Why am I getting the “LoaderLock was detected” warning when debugging?

て烟熏妆下的殇ゞ 提交于 2019-11-29 05:47:06
I'm developing an add-on for AutoCAD 2009. The project output is a class library. When I attempt to debug and load the class library, I get this "LoaderLock was detected message." I've been writing these add-ons for awhile and this is the first message of this type I've seen. Where do I start trying to figure this out? What is LoaderLock and why is it bothering me now? LoaderLock was detected Message: Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang. I went

Using ASP.Net MVC Data Annotation outside of MVC

不打扰是莪最后的温柔 提交于 2019-11-29 05:34:30
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 framework to my project as i was hoping i could just use the data annotations class System

Add ResourceDictionary to class library

◇◆丶佛笑我妖孽 提交于 2019-11-29 01:11:01
I created a class library which is contained of WPF Windows and some user controls inherited from my c# classes that helps me to customize certain wpf controls. Now I want to add ResourceDictionary, to help me share styles between my wpf classes. Is it possible? Thx. EDIT: resource dictionary file located in MY.WpfPresentation.Main project (named Styles.xaml): <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid" xmlns:dxgt="http://schemas

How can I make a .NET class library read its own configuration file?

若如初见. 提交于 2019-11-28 18:50:24
I have a .NET class library that provides a set of helper functions that are used by several Web Services. This class library must store a single setting, specifically, a connection string, which need not be seen by the Web Services themselves, since they all must query the same datbase. Unfortunately, .NET provides no means to easily read a DLL's app.config file. The only "easy" solution would be to store the connection string in every single Web Service configuration file, which is completely bollocks. Normally, I care about code elegance, but this time I really need a solution, even if it

How to debug class library that called from external app?

社会主义新天地 提交于 2019-11-28 18:18:48
There is an external workflow that executes C# scripts and is able to work with DLL files(my class library). Is it possible to attach debug to my class library project so breakpoint will hit once this WF will call it? Thanks Yes, you can do this with Visual Studio. You have two options: Configure your project to start the external program Open your DLL project. On the properties for the project, go to the Debug tab. Choose Start external program and give the path of the external program that will call your DLL, along with any command-line arguments you may need to supply, and the working

'System.Configuration.ConfigurationSettings.AppSettings' is obsolete

心已入冬 提交于 2019-11-28 18:07:40
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? Mike Cheel 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! as its a warning i dont think it matters unless you have turned off a treat warnings as errors setting add a

How to convert a Class Library project to a Web Application project?

…衆ロ難τιáo~ 提交于 2019-11-28 16:39:49
Long story short, because of some issues with architecture and the fact that someone already put a few .aspx files in a class library, I'd like to just finish off the change and convert a class library to a web application. This is using Visual Studio 2010 and .NET 4.0. Is there an easy way of doing this? Thanks! EDIT: I was hoping for a better method than recreating the project, I had too many issues with broken references when I tried just creating a new project, including one I could never seem to fix. Create a new web application project in your solution and drag and drop all files from

How to open .dll files to see what is written inside?

假如想象 提交于 2019-11-28 15:30:29
I lost the solution of class-library, can I open .dll file which is created by class-library . you are better off with a decompiler like redgates .net reflector or jetbrains resharper decompiler. there are open source ones also like http://www.jetbrains.com/decompiler/ http://ilspy.net/ Abhi Follow below steps.. Go to Start Menu. Type Visual Studio Tool. Go to the above folder. Click on "Developer Command Prompt for VS 2013" in the case of VS 2013 or just "Visual Studio Command Prompt " in case of VS 2010. After command prompt loaded to screen type ILDASM.EXE press ENTER. ILDASM window will