class-library

How to read connection string inside .NET Standard Class library project from ASP.NET Core

孤街醉人 提交于 2019-12-05 07:39:57
问题 In my solution, I have a ASP.NET Core web project and a .NET Standard class library project. Class library project is the data access layer and I want to read the connection string from my appsettings.json (ASP.NET Core project) in my data access layer. I have found few answers such as by Andrii Litvinov which looks like quite straight forward to implement but he also mentioned about implementing through Dependency Injection. I don't want to choose the easy shortcut way but looking for the

How to get user's location while chatting with bots?

烂漫一生 提交于 2019-12-05 05:03:24
I am developing a Bot Framework application that integrates with Slack using Microsoft Bot technology. In the bot project, I was trying to get the user location when the user sends a message. What I am trying to achieve is that, when a user types the message "Show me nearby hospitals", I want to get the users Geo coordinates and pass them to an API that will return a list of hospitals near that location. So any idea on how to get the user's current location in the Microsoft Bot project? I tried using the Geo location class, however I am not able to add the class reference directly and when I

Log4Net does not log from a class library

十年热恋 提交于 2019-12-05 03:49:24
I am working on .NET Framework 4.0 using C# in Windows 7, and trying to log from a class library but it's not working. I'm running my application without errors, but also nothing happens to my log file, neither to my console. So, here is my code: This is my App.config file: <?xml version="1.0"?> <configuration> <configSections> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" /> </configSections> <add key="log4net.config" value="config.log4net"/> <log4net> <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender"> <layout type="log4net

How can I call C# extension methods in VB code

独自空忆成欢 提交于 2019-12-04 18:23:56
问题 I have a class library with some extension methods written in C# and an old website written in VB. I want to call my extension methods from the VB code but they don't appear in intelisense and I get compile errors when I visit the site. I have got all the required Import s because other classes contained in the same namespaces are appearing fine in Intelisense. Any suggestions EDIT: More info to help with some comments. my implementation looks like this //C# code compiled as DLL namespace x.y

different between class library and portable class library in visual studio

*爱你&永不变心* 提交于 2019-12-04 15:20:32
问题 There are different types of Class libraries available in Visual Studio such as Silverlight Class Library, Portable Class library and Class Library. What are the differences between these types? How can we determine the type of a Class library with File.dll file? How can we change a Class library from own type to another type of Class library? 回答1: The Portable Class Library project type enables you to write and build managed assemblies that work on more than one Microsoft platform, whereas

How to create a C# session object wrapper?

岁酱吖の 提交于 2019-12-04 11:02:53
How do I create a class library where I can get and set like the IIS Session object where I use var x = objectname("key") to get the value or objectname("key") = x to set the value? Normally I just have a static class that wraps my session data and makes it type safe like: public static class MySessionHelper { public static string CustomItem1 { get { return HttpContext.Current.Session["CustomItem1"] as string; } set { HttpContext.Current.Session["CustomItem1"] = value; } } public static int CustomItem2 { get { return (int)(HttpContext.Current.Session["CustomItem2"]); } set { HttpContext

How to access a connection string from within a library

心已入冬 提交于 2019-12-04 06:58:09
I have a web project (mvc) and data access layer in a separated class library project. I need to access to a connection string in app.config which sits in that library project. ConfigurationManager.ConnectionStrings[0].ConnectionString pulls something strange. I don't have this kind of settings neither in the library's config nor in the web project's config files. the App.config looks like that: <?xml version="1.0" encoding="utf-8" ?> <configuration> <connectionStrings> <add name="DALConnectionString" connectionString="User ID=sa;Password=pass;Initial Catalog=db;Data Source=srv\SQL2005;" /> <

Azure class library access GetConfigurationSettingValue vs. web.config

雨燕双飞 提交于 2019-12-04 06:35:35
I have a class library shared between an Azure Worker Role and a ASP.NET Website. A method in the library needs to pull a value from the config to determine if it should send an email or not. In the ASP.NET site, the setting is in web.config: <add key="SendEmails" value="true"/> And in the Azure worker role it is in ServiceConfiguration.Cloud.cscfg: <Setting name="SendEmails" value="true"/> What I am trying to do is have my class library be able to access either config setting, depending on what environment it is running under. Create your own class to retrieve configuration values and in it

Different configuration settings per developer for c# class library

做~自己de王妃 提交于 2019-12-04 06:24:55
We're a small team, working on a asp.net web project, as well as service, both projects dependent on a shared class library. We'd like to have the class library settings different per developer (and later on for production). In settings are included sensitive information, such as passwords, as well as hostnames. How should we assign these settings ? Unless I'm wrong, web.config/application settings aren't good enough, as they don't work for the shared class library. ps: Also, some variables should be statically linked, and the rest (such as connectionstrings) should be dynamic. The web.config

Missing xaml.xr of a class library file in UWP

て烟熏妆下的殇ゞ 提交于 2019-12-04 03:41:45
问题 I have a class library project which I am using in a UWP project. If I add any usercontrol xaml file in the class library and build it it builds fine. But the UWP project gives an error that it cannot find the .xr file. Do I need to add the .xr file externally in any folder to my UWP project? 回答1: Yeah, for a class library with XAML files, if we want to reference the dll in other project, we need not only the dll itself but also the .xr.xaml file and some other files. Because in UWP