class-library

Using MATLAB MWArray.dll in C# Class Library

孤者浪人 提交于 2019-12-10 10:03:53
问题 I'm trying to use .dll, built in MATLAB with Matlab .net Complier, in C# Class Library , but program throws an exception every time object from MWArray.dll is initialized, for example: MWNumericArray m = new MWNumericArra(10,10); Exception: System.TypeInitializationException was caught HResult=-2146233036 Message=The type initializer for 'MathWorks.MATLAB.NET.Arrays.MWNumericArray' threw an exception. Source=MWArray TypeName=MathWorks.MATLAB.NET.Arrays.MWNumericArray StackTrace: at MathWorks

Debugging with my own custom Class Libraries

风流意气都作罢 提交于 2019-12-08 07:19:12
问题 I want my class library conditionally compiled so that it is in debugging mode when my project is, and is not when my project isn't. For example, I have this Module in my class library: Module MyDebug <Conditional("DEBUG")> Sub print(ByVal msg As String) Debug.Print(Now.ToString("yyyy-MM-dd HH:mm:ss.fff") & " " & msg) End Sub <Conditional("DEBUG")> Sub debugEnd(Byval bool As Boolean) Environment.Exit(0) End Sub End Module When I debug my project which references this library it run any of

A global error handler for a class library in C#

我的梦境 提交于 2019-12-07 05:46:15
问题 Is there a way to catch and handle an exception for all exceptions thrown within any of the methods of a class library? I can use a try catch construct within each method as in sample code below, but I was looking for a global error handler for a class library. The library could be used by ASP.Net or Winforms apps or another class library. The benefit would be easier development, and no need to repeatedly do the same thing within each method. public void RegisterEmployee(int employeeId) { try

Log4Net does not log from a class library

白昼怎懂夜的黑 提交于 2019-12-06 22:33:58
问题 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"/>

Using Windows UWP Windows.Devices.SerialCommunication.SerialDevice from Universal Class library

﹥>﹥吖頭↗ 提交于 2019-12-06 04:31:11
问题 I'm making a Modbus library (again...). This time it is meant to run on Windows 10 IoT Core. I've encountered an interesting problem. This chunk of code: string aqs = SerialDevice.GetDeviceSelector(); var dis = await DeviceInformation.FindAllAsync(aqs); var port = await SerialDevice.FromIdAsync(dis[0].Id); if (port != null) { port.BaudRate = 9600; port.DataBits = 8; port.StopBits = SerialStopBitCount.One; port.Parity = SerialParity.None; port.Handshake = SerialHandshake.None; port.ReadTimeout

How to access a connection string from within a library

五迷三道 提交于 2019-12-06 02:38:20
问题 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=

Different configuration settings per developer for c# class library

為{幸葍}努か 提交于 2019-12-06 02:17:10
问题 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

Using MATLAB MWArray.dll in C# Class Library

三世轮回 提交于 2019-12-05 22:33:13
I'm trying to use .dll, built in MATLAB with Matlab .net Complier, in C# Class Library , but program throws an exception every time object from MWArray.dll is initialized, for example: MWNumericArray m = new MWNumericArra(10,10); Exception: System.TypeInitializationException was caught HResult=-2146233036 Message=The type initializer for 'MathWorks.MATLAB.NET.Arrays.MWNumericArray' threw an exception. Source=MWArray TypeName=MathWorks.MATLAB.NET.Arrays.MWNumericArray StackTrace: at MathWorks.MATLAB.NET.Arrays.MWNumericArray.op_Implicit(Double[] values) at VolCalc.Vol.CalculateVolatility(Double

Where shall I put my utilities classes in a ASP.NET MVC3 application?

谁说我不能喝 提交于 2019-12-05 22:32:04
问题 I am developing a web application in ASP.NET MVC3 with C# and Razor. I need to create an utility class where I put functions to convert string into dates(years, months, days, etc...). In ASP.NET Web Forms I used to place this kind of classes inside the App_Code folder. In MVC there is not such folder and I don't think utility classes belong neither to Models nor to Helpers (a folder I created to put my extensions on HTML Helpers). I read that is a good practice to place the utility classes in

Console unavailable in class library c#

孤街浪徒 提交于 2019-12-05 14:39:42
问题 This question here seems contrary to what I have experienced. I cannot access the console from within a new class library. I have using System; at the top. I am using visual studio 11 on windows 8. I doubt that this has been lost in the update, so that means that I am doing something wrong. Also, once this is working, is the console available in a portable class library? EDIT here is just a test file I made using System; using System.Collections.Generic; using System.Linq; using System.Text;