wpf窗体项目 生成dll类库文件

我想把一个wpf应用程序的输出类型由windows应用程序改为类库该怎么做,直接在项目属性里改的话报错为 库项目文件无法指定applicationdefinition属性

wpf窗体项目运行之后bin/debug下面只有.exe文件,现在想要生成dll文件供其他第三方引用的实现方法。

1、删除App.xaml文件

2、将项目属性--应用程序--输出类型 改为类库。

下面可以没有,经测试,上面两步就可以实现,下面的内容是其他文章中的内容,备用。

    • 打开解决方案中的 Properties目录下的 AssemblyInfo.cs文件
    • 修改增加以下这个标签:
      [assembly: ThemeInfo(
          ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
        //(used if a resource is not found in the page, 
        // or application resource dictionaries)
          ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
        //(used if a resource is not found in the page, 
        // app, or any theme specific resource dictionaries)
      )]
    • 然后你就需要在项目增加一个名为 Themes 的目录,在目录里面添加一个名为 Generic.xaml 的ResourceDictionary
    • 这样,你就可以把在App.xaml中定义的资源全部放在Generic.xaml中了,系统根据程序集的设置会默认从这个资源目录中去寻找资源

原文地址:https://www.cnblogs.com/chiyueqi/p/4010938.html