class-library

Read from App.config in a Class Library project

梦想的初衷 提交于 2019-11-28 11:58:22
I am developing a simple class library project, which will give me a dll. I wanted a particular value to be read from a config file. So I have added an App.config file to my project. <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="serviceUrl" value="test value" /> </appSettings> </configuration> Above is my App.config file, and now I am trying to read it as following string strVal = System.Configuration.ConfigurationManager.AppSettings["serviceUrl"]; But I am not getting any value in my string variable. I had done this for a web application in a similar way and

Java Array sort: Quick way to get a sorted list of indices of an array

一笑奈何 提交于 2019-11-28 04:39:57
The problem: Consider the following floats[]: d[i] = 1.7 -0.3 2.1 0.5 What I want is an array of int[] that represents the order of the original array with indices. s[i] = 1 3 0 2 d[s[i]] = -0.3 0.5 1.7 2.1 Of course it could be done with a custom comparator, a sorted set of custom objects, or by simply sorting the array and then searching for the indices in the original array (shudder). What I am in fact looking for is the equivalent for the second return argument of Matlab's sort function . Is there an easy way to do that (<5 LOC)? May there be a solution that does not need to allocate a new

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

邮差的信 提交于 2019-11-28 02:34:15
问题 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

Where is the implementation of InternalEquals(object objA, object objB)

雨燕双飞 提交于 2019-11-28 00:16:30
While disassembling the .Net Source Code using Reflector, I came upon the Equals implementation in the Object Class and it refers to bool InternalEquals(object objA, object objB); Which again refers to internal static extern bool InternalEquals(object objA, object objB); I am now confused regarding where to find the implementation of this InternalEquals(object objA, object objB) function and how is it using this function and in which .Net assembly is this function defined and also if each and everything is written from scratch for the .Net Source Code, then why am I unable to find this

Add connectionstring in app.config

喜欢而已 提交于 2019-11-27 22:43:43
问题 I have a class library in C# has has several classes and a app.config. I have put ConnectionString in app.config as follows: <connectionStrings> <add name="TRN_DB" connectionString="Database=TRN;Server=NDTSSN;User ID=ln_users2;Password=%4nu$r!;Connection Timeout=30;pooling=false;" providerName="System.Data.SqlClient" /> </connectionStrings> I try to open connection string in one of the classes in my project as follows: string connectionString = ConfigurationManager.ConnectionStrings["TRN_DB"]

Adding System.Web.Script reference in class library

随声附和 提交于 2019-11-27 18:03:37
I am currently moving code from my app_code folder to a class library. I have tagged several methods with [System.Web.Script.Serialization.ScriptIgnore] attributes. My class library cannot see this namespace. My add references dialog cannot see this namespace. How do I properly use this tag from a class library? Here is the error: The type or namespace name 'ScriptIgnoreAttribute' could not be found (are you missing a using directive or an assembly reference?) M4N The ScriptIgnoreAttribute class is in the System.Web.Extensions.dll assembly (Located under Assemblies > Framework in the VS

Cannot find Bitmap Class in Class Library (.NET Standard)

家住魔仙堡 提交于 2019-11-27 16:01:27
I want to make a Class Library (.NET Standard) and I'm using System.Drawing, but I get the error: CS0246 C# The type or namespace name 'Bitmap' could not be found (are you missing a using directive or an assembly reference?) I'm using .NET Standard 2.0. Update As of last month (May 2018), Microsoft have a production release (previously it was preview/RC) of System.Drawing.Common , a NuGet package which supersedes both versions of the CoreCompat.System.Drawing package. This should be used going forwards. For now you can use the CoreCompat.System.Drawing nuget package. We've been using it in

Add ResourceDictionary to class library

流过昼夜 提交于 2019-11-27 13:50:16
问题 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

What is the difference between a class library and a framework

醉酒当歌 提交于 2019-11-27 13:39:09
I hear the whole day the terms class library, base class library, Framework, ... What highlights a framework and what a base class library? The distinguishing feature between a class library and a software framework is that in a framework, the flow of control is not determined by the user´s code, but by the framework. This is also known as Hollywood principle (don´t call us, we call you). By the way, there is also a nice Wikipedia article on this topic. You use a class library in writing your code, but you code within a framework. The term "framework" is meant to invoke a sense of "being

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

こ雲淡風輕ζ 提交于 2019-11-27 11:41:16
问题 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