ElH*_*aix 1 .net c# windows-services namespaces
我完全正在改写(更准确地说)我正在体验丢失对C#Windows服务中引用的类库的引用.
流程:创建全新的C#.Net v4.0 Windows服务.在该解决方案中,我创建了一个新的类库,它将从服务的OnStart()方法中调用,并在Windows服务中引用类库.我导入了RssToolkit项目(在这里找到).RssToolkit项目框架是2.0(尽管无关紧要),但仅供参考.从类库中引用RssToolkit.
所以,我们有Windows服务 - >类库 - > RssToolkit.
Windows服务:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using ClassLibraryToExecuteRss;
namespace WindowsService1
{
public partial class Service1 : ServiceBase
{
public Service1()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
Class1.DoSomeWork();
}
protected override void OnStop()
{
}
}
}
Run Code Online (Sandbox Code Playgroud)
班级图书馆:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RssToolkit.Rss;
namespace ClassLibraryToExecuteRss
{
public static class Class1
{
public static void DoSomeWork()
{
//RssDocument rssDocument = new RssDocument();
//rssDocument = RssDocument.Load(new System.Uri("http://www.somerssurl.com"));
}
}
}
Run Code Online (Sandbox Code Playgroud)
如您所见,使用RssDocument类的代码行被注释掉了.有了这些注释,我可以很好地编译解决方案......但它没什么用处.
取消注释后,我在服务代码中收到以下编译错误:
错误3找不到类型或命名空间名称'ClassLibraryToExecuteRss'(您是否缺少using指令或程序集引用?)C:\ Projects\TestBed\TestingServiceWithXLibs\WindowsService1\WindowsService1\Service1.cs 9 7 WindowsService1
...和...
错误4当前上下文中不存在名称"Class1"C:\ Projects\TestBed\TestingServiceWithXLibs\WindowsService1\WindowsService1\Service1.cs 22 13 WindowsService1
那么这里发生了什么?我构建了一个工作正常的TDD解决方案,但是当从我的单元测试中调用该类库的代码到解决方案时,我得到了这个.
我没有更改任何名称空间,并将所有内容保留为默认值.
顺便说一句,我确实将RssToolkit的目标框架更改为4.0 ...没有变化,我遇到了同样的问题,因为我在我的类库中使用了另一个外部库(SubSonic).
任何人都可以对此有所了解吗?
归档时间: |
|
查看次数: |
4848 次 |
最近记录: |