Visual Studio中提供了不同类型的类库,例如Silverlight类库,可移植类库和类库.这些类型有什么区别?我们如何确定带有File.dll文件的类库的类型?我们如何将类库从自己的类型更改为另一种类库?
有一个执行C#脚本的外部工作流,可以使用DLL文件(我的类库).
是否可以将调试附加到我的类库项目中,这样一旦这个WF调用它就会遇到断点?
谢谢
c# debugging class-library visual-studio visual-studio-debugging
WCF服务库对常规类库没有做什么?
编辑:我发布了自己的答案.我错过了什么吗?它们基本上只是添加了几个模板类的类库吗?
我创建了一个类库,它包含WPF Windows和一些从我的c#类继承的用户控件,可以帮助我自定义某些wpf控件.
现在我想添加ResourceDictionary,以帮助我在我的wpf类之间共享样式.可能吗?
谢谢.
编辑:位于MY.WpfPresentation.Main项目中的资源字典文件(名为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.devexpress.com/winfx/2008/xaml/grid/themekeys"
xmlns:MYNetMisc="clr-namespace:MY.Net.Misc;assembly=MY.Net"
>
<Style x:Key="customRowStyle" BasedOn="{StaticResource {dxgt:GridRowThemeKey ResourceKey=RowStyle}}" TargetType="{x:Type dxg:GridRowContent}">
<Setter Property="Foreground" Value="{Binding Path=DataContext.balance, Converter={MYNetMisc:BalanceToColor OnlyNegative=false}}" />
</Style>
</ResourceDictionary>
Run Code Online (Sandbox Code Playgroud)
使用它:
<MYNetPresentation:frmDockBase.Resources>
<ResourceDictionary x:Key="style">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MY.WpfPresentation.Main;component/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
<DataTemplate x:Key="TabTemplate">
<dxlc:LayoutControl Padding="0" ScrollBars="None" Background="Transparent">
<Image Source="/Images/Icons/table-32x32.png" Width="12" Height="12" />
<TextBlock Text="{Binding}" HorizontalAlignment="Left" VerticalAlignment="Center" />
</dxlc:LayoutControl>
</DataTemplate>
</MYNetPresentation:frmDockBase.Resources>
Run Code Online (Sandbox Code Playgroud) 我正在开发WPF应用程序,我想重用我在所有这些应用程序中相同的类,所以我可以添加它们作为参考.
在我的情况下,我有一个我的命令类:
public class RelayCommand : ICommand
{
#region Fields
readonly Action<object> _execute;
readonly Predicate<object> _canExecute;
#endregion // Fields
#region Constructors
public RelayCommand(Action<object> execute)
: this(execute, null)
{
}
public RelayCommand(Action<object> execute, Predicate<object> canExecute)
{
if (execute == null)
throw new ArgumentNullException("execute");
_execute = execute;
_canExecute = canExecute;
}
#endregion // Constructors
#region ICommand Members
public bool CanExecute(object parameter)
{
return _canExecute == null ? true : _canExecute(parameter);
}
public event EventHandler CanExecuteChanged
{
add { CommandManager.RequerySuggested += value; } …Run Code Online (Sandbox Code Playgroud) 我想知道是否有一种方法可以在没有MVC网站的情况下使用ASP.Net的数据注释.
我的例子是我有一个曾经创建过的类需要验证,否则会抛出错误.我喜欢数据注释方法,而不是initaliser发出的一堆if块.
有没有办法让这个工作?
我以为它会是这样的:
有任何想法吗?我必须承认我没有将MVC框架添加到我的项目中,因为我希望我可以使用数据注释类System.ComponentModel.DataValidation
我在VS 2012中开发了许多类库项目,用于Windows窗体和Web窗体应用程序.
问题很简单.我是否需要将DLL文件本身与创建的XML文件一起部署?
例如,类库项目称为DataWare.在构建时,我在Release文件夹中获得了5个文件(此项目参考实体框架):
我知道".pdb"文件包含调试信息,因此无需部署.不考虑".config"文件.相反,App.config或Web.config是.
关于这一点,我认为我必须只部署DataWare.dll和EntityFramework.dll.
但是,主要的疑问是我是否还需要部署EntityFramework.xml.
关心Jaime
我有一个.NET类库,它提供了一组由多个Web服务使用的辅助函数.此类库必须存储单个设置,特别是连接字符串,Web服务本身无需查看,因为它们都必须查询相同的数据库.
不幸的是,.NET没有提供轻松读取DLL app.config文件的方法.唯一的"简单"解决方案是将连接字符串存储在每个 Web服务配置文件中,这完全是bollocks.
通常,我关心代码优雅,但这次我真的需要一个解决方案,即使它是一个黑客.有没有办法让.NET类库有自己的配置?
编辑:从技术上讲,我可以将所有这些Web服务合并到一个Web服务中.但是,出于商业原因(每个Web服务将单独出售),我不能这样做.
我有一个类库项目(NotificationTemplate),它返回文件的内容:
public static class Template
{
public static string NotificatioEmail
{
get { return File.ReadAllText("Templates\\NotificatioEmail.cshtml"); }
}
}
Run Code Online (Sandbox Code Playgroud)
在这个项目中找到Templates带NotificatioEmail.cshtml文件的文件夹.
另外,我有两个应用程序:控制台应用程序和ASP.NET MVC应用程序.该文件在控制台应用程序中返回正常,但在MVC中我收到错误file not found.怎么写普遍?
我试过这个:
Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "Templates",
"NotificatioEmail.cshtml")
Run Code Online (Sandbox Code Playgroud)
但BaseDirectory不包括bin文件夹.
我正在开发一个简单的类库项目,它将给我一个DLL.
我想从配置文件中读取特定值.所以我在我的项目中添加了一个App.config文件.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="serviceUrl" value="test value" />
</appSettings>
</configuration>
Run Code Online (Sandbox Code Playgroud)
上面是我的App.config文件,现在我正在尝试将其读取如下
string strVal = System.Configuration.ConfigurationManager.AppSettings["serviceUrl"];
Run Code Online (Sandbox Code Playgroud)
但是我的字符串变量没有任何值.

我以类似的方式为Web应用程序完成了这项工作.但不知怎的,我无法让这个工作.
是否首先在类库项目中使用App.config是正确的?
class-library ×10
c# ×7
.net ×3
asp.net-mvc ×2
wpf ×2
app-config ×1
c#-4.0 ×1
command ×1
debugging ×1
deployment ×1
mvvm ×1
wcf ×1