我正在Visual Studio 2008中的类库(DLL)项目; 用C#编程.为了测试我的DLL,我刚刚创建了第二个项目,它是一个控制台应用程序,在该项目中我可以引用第一个和运行测试.有更简单的方法吗?我可以在我的类库项目中创建另一个文件,其中包含测试,然后以某种方式告诉Visual Studio运行该文件吗?
我知道一种方法是将一个文本文件添加到我的项目中,然后用JScript编写我的测试代码.然后在调试菜单上的项目设置中,我可以告诉它启动外部程序(JScript).然后,我的测试文件的名称将test.js进入"命令行参数"框.但是,我想知道是否有办法使用C#代码而不是JScript?
当从另一个程序集实例化时,我想在类库中执行某些代码.是否有类库的入口点或引导程序?我认为一个静态方法Main可以做到这一点,但我错了.此应用程序可能是配置和实例化记录器单例,未处理的异常处理程序等.
如何在 .NET Core 库项目中将一个类注入到另一个类中?我应该在哪里配置 DI,因为它是在 API 项目中的 StartUp Class ConfigureServices 中完成的?
我正在为AutoCAD 2009开发一个附加组件.项目输出是一个类库.当我尝试调试并加载类库时,我得到了"LoaderLock被检测到的消息".我一直在写这些附加组件,这是我见过的第一个这种类型的消息.
检测到LoaderLock消息:尝试在OS Loader锁定内执行托管执行.不要尝试在DllMain或图像初始化函数中运行托管代码,因为这样做会导致应用程序挂起.
我去了Debug -> Exceptions -> "Managed Debugging Assistants",找到"LoaderLock"并取消选中了"Thrown"复选框.
我可以再次调试,但我做了什么,为什么我必须这样做?这会给我带来其他问题吗?
我找不到类似的帖子,所以我希望这不是重复的.
我有一个ac #class库,我正在尝试在Visual Studio 2012中运行单元测试.我在我的解决方案中添加了一个新的单元测试项目,并在那里添加了我的主项目作为参考.我已将我的单元测试项目设置为启动项目.当我尝试调试时,收到错误消息
无法直接启动具有类库的输出类型的项目.
要调试此项目,请将可执行项目添加到此解决方案,该项目引用库项目.将可执行项目设置为启动项目.
根据msdn的演练,我应该在调试时运行测试.有什么想法吗?这是我的单元测试代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Common;
using Messages;
namespace MessageUnitTests
{
[TestClass]
class RegistrationTester
{
[TestMethod]
public void RegistrationRequest_TestConstructorsAndFactories()
{
RegistrationRequest rr1 = new RegistrationRequest("myhandle");
Assert.AreEqual("myhandle", rr1.Handle);
rr1 = new RegistrationRequest("longHandle-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789'|;:',.=-_+!@#$%^&*()");
Assert.AreEqual("longHandle-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789'|;:',.=-_+!@#$%^&*()", rr1.Handle);
rr1 = new RegistrationRequest("");
Assert.AreEqual("", rr1.Handle);
rr1 = new RegistrationRequest(null);
Assert.AreEqual(null, rr1.Handle);
rr1 = new RegistrationRequest("myhandle");
ByteList bytes = new ByteList();
rr1.Encode(bytes);
RegistrationRequest rr2 = RegistrationRequest.Create(bytes);
Assert.IsNotNull(rr2);
Assert.AreEqual(rr1.IsARequest, rr2.IsARequest);
Assert.AreEqual(rr1.MessageNr.ProcessId, rr2.MessageNr.ProcessId); …Run Code Online (Sandbox Code Playgroud) 您好
我想创建一个类库(.NET标准),我正在使用System.Drawing,但是我收到错误:
CS0246 C# The type or namespace name 'Bitmap' could not be found
(are you missing a using directive or an assembly reference?)
Run Code Online (Sandbox Code Playgroud)
我正在使用.NET Standard 2.0.谢谢.
我是一个从未真正使用.dll文件的程序员.当然,当我需要第三方软件时,例如图形库,帮助我创建图形等的库.我会将reference/ddl文件添加到我的程序中并在我的代码中使用它们.
此外,似乎你可以使用.dll来做很多不同的事情,所以我想把这个话题集中在C#上.
现在我正在开发一个消毒库(?)(我认为这是正确的术语),它将充满相关的方法,可以用各种不同的方式消毒变量.
我想知道的是:
会有什么好处:
1)将方法写入类库 - >编译/构建它 - >添加库作为程序的引用 - 需要清理一些变量吗?
或者如果我在哪里:它会完全相同:
2)在程序中创建一个新的SanitizeClass - >添加所有的sanitize方法 - >从需要清理变量的程序中的不同类中调用SanitizeClass中的方法
一般来说,我也想知道何时使用编译的类库是有利的.我在想速度,安全性,所有这一切.
任何人都可以启发我吗?:)
我正在开发一个ASP.NET MVC应用程序,但是我试图从我的项目中删除除了Controller代码之外的所有东西,并将它放在它自己的类库中.
我有一些代码
Using System.Web.Mvc;
但它似乎并没有让我访问它.我System.Web在项目中引用了命名空间.
我在iActionFilter和FilterAttribute上遇到错误.
我错过了什么?
我正在尝试使用Visual Studio 2012,.NET 4来检测ASP.NET Web应用程序.该解决方案包含一个Web应用程序和一个类库.问题是我看不到步骤进入类库,我收到一条消息说明:
Matching symbols could not be found. Choose the 'Symbol Settings...' link to add the symbol file location and then reload the report.
Run Code Online (Sandbox Code Playgroud)
分析时的输出看起来很好:
Preparing web server for profiling.
Profiling started.
Instrumenting C:\Users\kipusoep\Documents\InfoCaster\svn\instances\PerformanceTest\\bin\PerformanceTest.dll in place
Info VSP3049: Small functions will be excluded from instrumentation.
Microsoft (R) VSInstr Post-Link Instrumentation 11.0.50727 x86
Copyright (C) Microsoft Corp. All rights reserved.
File to Process:
C:\Users\kipusoep\Documents\InfoCaster\svn\instances\PerformanceTest\bin\PerformanceTest.dll --> C:\Users\kipusoep\Documents\InfoCaster\svn\instances\PerformanceTest\bin\PerformanceTest.dll
Original file backed up to C:\Users\kipusoep\Documents\InfoCaster\svn\instances\PerformanceTest\bin\PerformanceTest.dll.orig
Successfully instrumented file C:\Users\kipusoep\Documents\InfoCaster\svn\instances\PerformanceTest\bin\PerformanceTest.dll.
Warning VSP2013: …Run Code Online (Sandbox Code Playgroud) class-library ×10
c# ×6
dll ×2
.net ×1
.net-core ×1
asp.net ×1
asp.net-core ×1
autocad ×1
bitmap ×1
class ×1
debugging ×1
frameworks ×1
unit-testing ×1